emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107680: * vc/vc-git.el (vc-git-state


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107680: * vc/vc-git.el (vc-git-state): Avoid unnecessarily locking.
Date: Mon, 26 Mar 2012 11:08:15 +0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107680
author: Ami Fischman <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Mon 2012-03-26 11:08:15 +0800
message:
  * vc/vc-git.el (vc-git-state): Avoid unnecessarily locking.
modified:
  lisp/ChangeLog
  lisp/vc/vc-git.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-03-26 01:35:47 +0000
+++ b/lisp/ChangeLog    2012-03-26 03:08:15 +0000
@@ -1,3 +1,7 @@
+2012-03-26  Ami Fischman  <address@hidden>
+
+       * vc/vc-git.el (vc-git-state): Avoid unnecessarily locking.
+
 2012-03-26  Glenn Morris  <address@hidden>
 
        * files.el (save-buffers-kill-emacs): Doc fix.

=== modified file 'lisp/vc/vc-git.el'
--- a/lisp/vc/vc-git.el 2012-03-01 09:01:08 +0000
+++ b/lisp/vc/vc-git.el 2012-03-26 03:08:15 +0000
@@ -217,12 +217,21 @@
   ;; 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)


reply via email to

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