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>
Alexandre Julliard committed
Mar 4, 2006 at 17:38 UTC
b23761d9ac0851f1af7edde1075f78835f539428
1 file changed
+8
-3
contrib/emacs/git.el
+8
-3
@@ -213,14 +213,19 @@ If not set, fall back to `add-log-mailing-address' and then `user-mail-address'.
213
"Add a file name to the ignore file in its directory."
214
(let* ((fullname (expand-file-name file))
215
(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))))
219
(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))
221
(goto-char (point-max))
222
(unless (zerop (current-column)) (insert "\n"))
223
(insert name "\n")
224
(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))))
229
230
231
;;;; Wrappers for basic git commands