Fix magit-get-top-dir from ruining paths with symlinks.

One might argue that this also makes it work better in a case when GIT_DIR
points outside of a work tree, but because in that case any directory is a
valid "top dir" from GIT's point of view, that is debatable.  But at least
one can use Magit in that case by first making sure that default-directory
is the top dir and then executing magit-status.
This commit is contained in:
Hannu Koivisto 2009-10-14 21:28:07 +03:00
parent 01d58d4385
commit 6a1bb4f644

View file

@ -401,13 +401,11 @@ Many Magit faces inherit from this one by default."
(defun magit-get-top-dir (cwd)
(let ((cwd (expand-file-name cwd)))
(and (file-directory-p cwd)
(let* ((default-directory cwd)
(magit-dir
(magit-git-string "rev-parse" "--git-dir")))
(and magit-dir
(file-name-as-directory
(or (file-name-directory magit-dir) cwd)))))))
(when (file-directory-p cwd)
(let* ((default-directory cwd)
(cdup (magit-git-string "rev-parse" "--show-cdup")))
(when cdup
(file-name-as-directory (expand-file-name cdup cwd)))))))
(defun magit-get-ref (ref)
(magit-git-string "symbolic-ref" "-q" ref))