Skip to content

Commit

Permalink
git.el: Automatically update .gitignore status.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexandre Julliard authored and Junio C Hamano committed Mar 4, 2006
1 parent a944652 commit b23761d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions contrib/emacs/git.el
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,19 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
"Add a file name to the ignore file in its directory."
(let* ((fullname (expand-file-name file))
(dir (file-name-directory fullname))
(name (file-name-nondirectory fullname)))
(name (file-name-nondirectory fullname))
(ignore-name (expand-file-name git-per-dir-ignore-file dir))
(created (not (file-exists-p ignore-name))))
(save-window-excursion
(set-buffer (find-file-noselect (expand-file-name git-per-dir-ignore-file dir)))
(set-buffer (find-file-noselect ignore-name))
(goto-char (point-max))
(unless (zerop (current-column)) (insert "\n"))
(insert name "\n")
(sort-lines nil (point-min) (point-max))
(save-buffer))))
(save-buffer))
(when created
(git-run-command nil nil "update-index" "--info-only" "--add" "--" (file-relative-name ignore-name)))
(git-add-status-file (if created 'added 'modified) (file-relative-name ignore-name))))


;;;; Wrappers for basic git commands
Expand Down

0 comments on commit b23761d

Please sign in to comment.