]> rtime.felk.cvut.cz Git - sojka/git-gui.git/blobdiff - git-gui.sh
git-gui: work from the .git dir
[sojka/git-gui.git] / git-gui.sh
index e3473a81a6b63bfb7b9cd1907ad384957235bbf4..1fb3cbfc78fe07e658aa299f46fd8f55dbab1378 100755 (executable)
@@ -1074,6 +1074,8 @@ if {[catch {
                set _prefix {}
                }]
        && [catch {
+               # beware that from the .git dir this sets _gitdir to .
+               # and _prefix to the empty string
                set _gitdir [git rev-parse --git-dir]
                set _prefix [git rev-parse --show-prefix]
        } err]} {
@@ -1082,6 +1084,14 @@ if {[catch {
        choose_repository::pick
        set picked 1
 }
+
+# we expand the _gitdir when it's just a single dot (i.e. when we're being
+# run from the .git dir itself) lest the routines to find the worktree
+# get confused
+if {$_gitdir eq "."} {
+       set _gitdir [pwd]
+}
+
 if {![file isdirectory $_gitdir] && [is_Cygwin]} {
        catch {set _gitdir [exec cygpath --windows $_gitdir]}
 }