]> git.eshelyaron.com Git - emacs.git/commitdiff
* vc/vc-git.el (vc-git-state): Avoid unnecessarily locking.
authorAmi Fischman <ami@fischman.org>
Mon, 26 Mar 2012 03:08:15 +0000 (11:08 +0800)
committerChong Yidong <cyd@gnu.org>
Mon, 26 Mar 2012 03:08:15 +0000 (11:08 +0800)
lisp/ChangeLog
lisp/vc/vc-git.el

index 799024ae42267eca54c470a7f36167f0e7bc9893..a9cb5a519d0471ac0abcf29e49442ccd986db70d 100644 (file)
@@ -1,3 +1,7 @@
+2012-03-26  Ami Fischman  <ami@fischman.org>
+
+       * vc/vc-git.el (vc-git-state): Avoid unnecessarily locking.
+
 2012-03-26  Glenn Morris  <rgm@gnu.org>
 
        * files.el (save-buffers-kill-emacs): Doc fix.
index 3ec322437964f887679c2bcc5b830b568b67189e..bf7b7fb9e170fa83ad2087c48fcc6bf81f11d8a1 100644 (file)
@@ -217,12 +217,21 @@ matching the resulting Git log output, and KEYWORDS is a list of
   ;; operation.
   (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))
+                 file "diff-index" "-p" "--raw" "-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\\(\\(?:.\\|\n\\)*\\)\\'"
+                            diff))
+          (let ((diff-letter (match-string 1 diff))
+                (diff-contents (match-string 2 diff)))
+            (if (not (string-match "\n." diff-contents))
+                ;; Empty diff: file contents is the same as the HEAD
+                ;; revision, but timestamps are different (eg, file
+                ;; was "touch"ed).  Update timestamp in index:
+                (prog1 'up-to-date
+                  (vc-git--call nil "add" "--refresh" "--"
+                                (file-relative-name file)))
+              (vc-git--state-code diff-letter)))
        (if (vc-git--empty-db-p) 'added 'up-to-date)))))
 
 (defun vc-git-working-revision (file)