emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] vc-git: Do not show `.git/*' files with vc-dir


From: Eric James Michael Ritz
Subject: [PATCH] vc-git: Do not show `.git/*' files with vc-dir
Date: Wed, 30 Jun 2010 08:38:15 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4

When using vc-dir to work with a directory under source control by
Git, it is possible for vc-dir to show files under the top-level
`.git' directory as being unregistered.  As correctly guessed by Dan
Nicolescu, this is caused when a user has $EDITOR configured to be
emacsclient, and he performs certain Git operations outside of
vc-mode, e.g. running `git-commit' from the command line.

It is unlikely that any user would want to perform operations on a
file inside of the `.git' directory via vc-dir.  Therefore we can
prevent those files from appearing by teaching `vc-git-state' to
return nil for any file in those directories.

Signed-off-by: Eric James Michael Ritz <address@hidden>
---
 lisp/vc-git.el |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index 24062a0..ae5b0ff 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -171,16 +171,21 @@ If nil, use the value of `vc-diff-switches'.  If t, use 
no switches."

 (defun vc-git-state (file)
   "Git-specific version of `vc-state'."
-  ;; FIXME: This can't set 'ignored yet
-  (if (not (vc-git-registered file))
-      'unregistered
-    (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
-    (let ((diff (vc-git--run-command-string
-                 file "diff-index" "-z" "HEAD" "--")))
-      (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} 
[0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
-                                 diff))
-         (vc-git--state-code (match-string 1 diff))
-       (if (vc-git--empty-db-p) 'added 'up-to-date)))))
+  ;; We never want to perform VC operations on files in the `.git'
+  ;; directory.
+  (cond ((string-match ".git" file)
+         nil)
+        ;; FIXME: This can't set 'ignored yet.
+        ((not (vc-git-registered file))
+         'unregistered)
+        (t
+         (vc-git--call nil "add" "--refresh" "--" (file-relative-name file))
+         (let ((diff (vc-git--run-command-string
+                      file "diff-index" "-z" "HEAD" "--")))
+           (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} 
[0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0"
+                                       diff))
+               (vc-git--state-code (match-string 1 diff))
+             (if (vc-git--empty-db-p) 'added 'up-to-date))))))

 (defun vc-git-working-revision (file)
   "Git-specific version of `vc-working-revision'."
--
1.7.2.rc0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]