Skip to content

Commit

Permalink
git-gui: work from the .git dir
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Giuseppe Bilotta authored and Shawn O. Pearce committed Jan 23, 2010
1 parent 390425b commit 87cd09f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]} {
Expand All @@ -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]}
}
Expand Down

0 comments on commit 87cd09f

Please sign in to comment.