Skip to content

Commit b23761d

Browse files
julliardJunio C Hamano
authored andcommitted
git.el: Automatically update .gitignore status.
Update .gitignore files in the status list as they are created or modified. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent a944652 commit b23761d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

contrib/emacs/git.el

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,19 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
213213
"Add a file name to the ignore file in its directory."
214214
(let* ((fullname (expand-file-name file))
215215
(dir (file-name-directory fullname))
216-
(name (file-name-nondirectory fullname)))
216+
(name (file-name-nondirectory fullname))
217+
(ignore-name (expand-file-name git-per-dir-ignore-file dir))
218+
(created (not (file-exists-p ignore-name))))
217219
(save-window-excursion
218-
(set-buffer (find-file-noselect (expand-file-name git-per-dir-ignore-file dir)))
220+
(set-buffer (find-file-noselect ignore-name))
219221
(goto-char (point-max))
220222
(unless (zerop (current-column)) (insert "\n"))
221223
(insert name "\n")
222224
(sort-lines nil (point-min) (point-max))
223-
(save-buffer))))
225+
(save-buffer))
226+
(when created
227+
(git-run-command nil nil "update-index" "--info-only" "--add" "--" (file-relative-name ignore-name)))
228+
(git-add-status-file (if created 'added 'modified) (file-relative-name ignore-name))))
224229

225230

226231
;;;; Wrappers for basic git commands

0 commit comments

Comments
 (0)