summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-06-01 10:28:43 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2016-06-01 11:03:37 -0700
commita76420cce2d1c2e1d5de0cdf50443006064c58af (patch)
tree822eca9887e70ed8fce2e1bb2bcb32d5a7a16797
parent5668058053d100f5c1053ab504ec01aa0017806b (diff)
downloademacs-a76420cce2d1c2e1d5de0cdf50443006064c58af.tar.gz
Fix emacs-repository-get-version with packed .git
* lisp/version.el (emacs-repository-get-version): Parse .git/packed-refs if it exists. Problem reported by Martin Rudalics in: http://lists.gnu.org/archive/html/emacs-devel/2016-05/msg00554.html
-rw-r--r--lisp/version.el25
1 files changed, 17 insertions, 8 deletions
diff --git a/lisp/version.el b/lisp/version.el
index dc228870d1e..2f71aeb228f 100644
--- a/lisp/version.el
+++ b/lisp/version.el
@@ -163,14 +163,23 @@ the VCS if we cannot find any information ourselves."
(or (if in-linked-worktree
(emacs-repository--version-git-1
(expand-file-name "HEAD" sub-dir) base-dir)
- (let ((files '("HEAD" "refs/heads/master"))
- file rev)
- (while (and (not rev)
- (setq file (car files)))
- (setq file (expand-file-name file base-dir)
- files (cdr files)
- rev (emacs-repository--version-git-1 file base-dir)))
- rev))
+ (or
+ (let ((packed-refs (expand-file-name "packed-refs" base-dir)))
+ (if (file-readable-p packed-refs)
+ (with-temp-buffer
+ (insert-file-contents packed-refs)
+ (when (re-search-forward
+ "^\\([0-9a-fA-F]\\{40\\}\\) refs/heads/master$"
+ nil t)
+ (match-string 1)))))
+ (let ((files '("HEAD" "refs/heads/master"))
+ file rev)
+ (while (and (not rev)
+ (setq file (car files)))
+ (setq file (expand-file-name file base-dir)
+ files (cdr files)
+ rev (emacs-repository--version-git-1 file base-dir)))
+ rev)))
;; AFAICS this doesn't work during dumping (bug#20799).
(emacs-repository-version-git dir))))))