Commit a76420cc authored by Paul Eggert's avatar Paul Eggert
Browse files

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
parent 56680580
...@@ -163,14 +163,23 @@ the VCS if we cannot find any information ourselves." ...@@ -163,14 +163,23 @@ the VCS if we cannot find any information ourselves."
(or (if in-linked-worktree (or (if in-linked-worktree
(emacs-repository--version-git-1 (emacs-repository--version-git-1
(expand-file-name "HEAD" sub-dir) base-dir) (expand-file-name "HEAD" sub-dir) base-dir)
(let ((files '("HEAD" "refs/heads/master")) (or
file rev) (let ((packed-refs (expand-file-name "packed-refs" base-dir)))
(while (and (not rev) (if (file-readable-p packed-refs)
(setq file (car files))) (with-temp-buffer
(setq file (expand-file-name file base-dir) (insert-file-contents packed-refs)
files (cdr files) (when (re-search-forward
rev (emacs-repository--version-git-1 file base-dir))) "^\\([0-9a-fA-F]\\{40\\}\\) refs/heads/master$"
rev)) 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). ;; AFAICS this doesn't work during dumping (bug#20799).
(emacs-repository-version-git dir)))))) (emacs-repository-version-git dir))))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment