That is, you get the path with symlinks instead of symlinks resolved.

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.
---
Hi,

Let's see if this works, I've never tried to send patches generated
with format-patch before.

-- 
Hannu

 magit.el |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/magit.el b/magit.el
index a911950..1e5f692 100644
--- a/magit.el
+++ b/magit.el
@@ -338,13 +338,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))
-- 
1.6.4.GIT


Reply via email to