Skip to content

Commit 87cd09f

Browse files
Oblomovspearce
authored andcommitted
git-gui: work from the .git dir
When git-gui is run from a .git dir, _gitdir would be set to "." by rev-parse, something that confuses the worktree detection. Fix by expanding the value of _gitdir to pwd in this special case. Signed-off-by: Giuseppe Bilotta <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 390425b commit 87cd09f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

git-gui.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,8 @@ if {[catch {
10741074
set _prefix {}
10751075
}]
10761076
&& [catch {
1077+
# beware that from the .git dir this sets _gitdir to .
1078+
# and _prefix to the empty string
10771079
set _gitdir [git rev-parse --git-dir]
10781080
set _prefix [git rev-parse --show-prefix]
10791081
} err]} {
@@ -1082,6 +1084,14 @@ if {[catch {
10821084
choose_repository::pick
10831085
set picked 1
10841086
}
1087+
1088+
# we expand the _gitdir when it's just a single dot (i.e. when we're being
1089+
# run from the .git dir itself) lest the routines to find the worktree
1090+
# get confused
1091+
if {$_gitdir eq "."} {
1092+
set _gitdir [pwd]
1093+
}
1094+
10851095
if {![file isdirectory $_gitdir] && [is_Cygwin]} {
10861096
catch {set _gitdir [exec cygpath --windows $_gitdir]}
10871097
}

0 commit comments

Comments
 (0)