summaryrefslogtreecommitdiff
path: root/lisp/vc
diff options
context:
space:
mode:
authorAmi Fischman <ami@fischman.org>2012-03-26 11:08:15 +0800
committerChong Yidong <cyd@gnu.org>2012-03-26 11:08:15 +0800
commitc0bf77531e26501546bbb3a1fc000c730c3fc89f (patch)
treea3b530b6a54557ed32be0233ece4abf4ff99d833 /lisp/vc
parent02243d9dc1b91f929ea0052e5079ca5c41fd99c0 (diff)
downloademacs-c0bf77531e26501546bbb3a1fc000c730c3fc89f.tar.gz
* vc/vc-git.el (vc-git-state): Avoid unnecessarily locking.
Diffstat (limited to 'lisp/vc')
-rw-r--r--lisp/vc/vc-git.el19
1 files changed, 14 insertions, 5 deletions
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 3ec32243796..bf7b7fb9e17 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -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)