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 <giuseppe.bilotta@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Giuseppe Bilotta committed
Jan 23, 2010 at 11:03 UTC
87cd09f43e56de5235d09aef3ff5d840419fef49
1 file changed
+10
git-gui.sh
+10
@@ -1074,6 +1074,8 @@ if {[catch {
1074
set _prefix {}
1075
}]
1076
&& [catch {
1077
+ # beware that from the .git dir this sets _gitdir to .
1078
+ # and _prefix to the empty string
1079
set _gitdir [git rev-parse --git-dir]
1080
set _prefix [git rev-parse --show-prefix]
1081
} err]} {
@@ -1082,6 +1084,14 @@ if {[catch {
1084
choose_repository::pick
1085
set picked 1
1086
}
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
+
1095
if {![file isdirectory $_gitdir] && [is_Cygwin]} {
1096
catch {set _gitdir [exec cygpath --windows $_gitdir]}
1097
}