Skip to content

Commit a2b93fe

Browse files
hvoigtdscho
authored andcommitted
Revert "git-gui: set GIT_DIR and GIT_WORK_TREE after setup"
This reverts commit a9fa11f. Signed-off-by: Heiko Voigt <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d44acf7 commit a2b93fe

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

git-gui/git-gui.sh

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,9 +1325,6 @@ if {[lindex $_reponame end] eq {.git}} {
13251325
set _reponame [lindex $_reponame end]
13261326
}
13271327
1328-
set env(GIT_DIR) $_gitdir
1329-
set env(GIT_WORK_TREE) $_gitworktree
1330-
13311328
######################################################################
13321329
##
13331330
## global init
@@ -2152,7 +2149,7 @@ set starting_gitk_msg [mc "Starting gitk... please wait..."]
21522149
21532150
proc do_gitk {revs {is_submodule false}} {
21542151
global current_diff_path file_states current_diff_side ui_index
2155-
global _gitdir _gitworktree
2152+
global _gitworktree
21562153
21572154
# -- Always start gitk through whatever we were loaded with. This
21582155
# lets us bypass using shell process on Windows systems.
@@ -2164,12 +2161,19 @@ proc do_gitk {revs {is_submodule false}} {
21642161
} else {
21652162
global env
21662163
2164+
if {[info exists env(GIT_DIR)]} {
2165+
set old_GIT_DIR $env(GIT_DIR)
2166+
} else {
2167+
set old_GIT_DIR {}
2168+
}
2169+
21672170
set pwd [pwd]
21682171
21692172
if {!$is_submodule} {
21702173
if {![is_bare]} {
21712174
cd $_gitworktree
21722175
}
2176+
set env(GIT_DIR) [file normalize [gitdir]]
21732177
} else {
21742178
cd $current_diff_path
21752179
if {$revs eq {--}} {
@@ -2190,18 +2194,15 @@ proc do_gitk {revs {is_submodule false}} {
21902194
}
21912195
set revs $old_sha1...$new_sha1
21922196
}
2193-
# GIT_DIR and GIT_WORK_TREE for the submodule are not the ones
2194-
# we've been using for the main repository, so unset them.
2195-
# TODO we could make life easier (start up faster?) for gitk
2196-
# by setting these to the appropriate values to allow gitk
2197-
# to skip the heuristics to find their proper value
2198-
unset env(GIT_DIR)
2199-
unset env(GIT_WORK_TREE)
2197+
if {[info exists env(GIT_DIR)]} {
2198+
unset env(GIT_DIR)
2199+
}
22002200
}
22012201
eval exec $cmd $revs "--" "--" &
22022202
2203-
set env(GIT_DIR) $_gitdir
2204-
set env(GIT_WORK_TREE) $_gitworktree
2203+
if {$old_GIT_DIR ne {}} {
2204+
set env(GIT_DIR) $old_GIT_DIR
2205+
}
22052206
cd $pwd
22062207
22072208
ui_status $::starting_gitk_msg
@@ -2222,20 +2223,22 @@ proc do_git_gui {} {
22222223
error_popup [mc "Couldn't find git gui in PATH"]
22232224
} else {
22242225
global env
2225-
global _gitdir _gitworktree
22262226
2227-
# see note in do_gitk about unsetting these vars when
2228-
# running tools in a submodule
2229-
unset env(GIT_DIR)
2230-
unset env(GIT_WORK_TREE)
2227+
if {[info exists env(GIT_DIR)]} {
2228+
set old_GIT_DIR $env(GIT_DIR)
2229+
unset env(GIT_DIR)
2230+
} else {
2231+
set old_GIT_DIR {}
2232+
}
22312233
22322234
set pwd [pwd]
22332235
cd $current_diff_path
22342236
22352237
eval exec $exe gui &
22362238
2237-
set env(GIT_DIR) $_gitdir
2238-
set env(GIT_WORK_TREE) $_gitworktree
2239+
if {$old_GIT_DIR ne {}} {
2240+
set env(GIT_DIR) $old_GIT_DIR
2241+
}
22392242
cd $pwd
22402243
22412244
ui_status $::starting_gitk_msg

0 commit comments

Comments
 (0)