Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 3715778

Browse files
hvoigtkasal
authored andcommitted
Revert "git-gui: set GIT_DIR and GIT_WORK_TREE after setup"
This reverts commit a9fa11f.
1 parent ec765f6 commit 3715778

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
@@ -1337,9 +1337,6 @@ if {[lindex $_reponame end] eq {.git}} {
13371337
set _reponame [lindex $_reponame end]
13381338
}
13391339
1340-
set env(GIT_DIR) $_gitdir
1341-
set env(GIT_WORK_TREE) $_gitworktree
1342-
13431340
######################################################################
13441341
##
13451342
## global init
@@ -2155,7 +2152,7 @@ set starting_gitk_msg [mc "Starting gitk... please wait..."]
21552152
21562153
proc do_gitk {revs {is_submodule false}} {
21572154
global current_diff_path file_states current_diff_side ui_index
2158-
global _gitdir _gitworktree
2155+
global _gitworktree
21592156
21602157
# -- Always start gitk through whatever we were loaded with. This
21612158
# lets us bypass using shell process on Windows systems.
@@ -2167,12 +2164,19 @@ proc do_gitk {revs {is_submodule false}} {
21672164
} else {
21682165
global env
21692166
2167+
if {[info exists env(GIT_DIR)]} {
2168+
set old_GIT_DIR $env(GIT_DIR)
2169+
} else {
2170+
set old_GIT_DIR {}
2171+
}
2172+
21702173
set pwd [pwd]
21712174
21722175
if {!$is_submodule} {
21732176
if {![is_bare]} {
21742177
cd $_gitworktree
21752178
}
2179+
set env(GIT_DIR) [file normalize [gitdir]]
21762180
} else {
21772181
cd $current_diff_path
21782182
if {$revs eq {--}} {
@@ -2193,18 +2197,15 @@ proc do_gitk {revs {is_submodule false}} {
21932197
}
21942198
set revs $old_sha1...$new_sha1
21952199
}
2196-
# GIT_DIR and GIT_WORK_TREE for the submodule are not the ones
2197-
# we've been using for the main repository, so unset them.
2198-
# TODO we could make life easier (start up faster?) for gitk
2199-
# by setting these to the appropriate values to allow gitk
2200-
# to skip the heuristics to find their proper value
2201-
unset env(GIT_DIR)
2202-
unset env(GIT_WORK_TREE)
2200+
if {[info exists env(GIT_DIR)]} {
2201+
unset env(GIT_DIR)
2202+
}
22032203
}
22042204
eval exec $cmd $revs "--" "--" &
22052205
2206-
set env(GIT_DIR) $_gitdir
2207-
set env(GIT_WORK_TREE) $_gitworktree
2206+
if {$old_GIT_DIR ne {}} {
2207+
set env(GIT_DIR) $old_GIT_DIR
2208+
}
22082209
cd $pwd
22092210
22102211
ui_status $::starting_gitk_msg
@@ -2225,20 +2226,22 @@ proc do_git_gui {} {
22252226
error_popup [mc "Couldn't find git gui in PATH"]
22262227
} else {
22272228
global env
2228-
global _gitdir _gitworktree
22292229
2230-
# see note in do_gitk about unsetting these vars when
2231-
# running tools in a submodule
2232-
unset env(GIT_DIR)
2233-
unset env(GIT_WORK_TREE)
2230+
if {[info exists env(GIT_DIR)]} {
2231+
set old_GIT_DIR $env(GIT_DIR)
2232+
unset env(GIT_DIR)
2233+
} else {
2234+
set old_GIT_DIR {}
2235+
}
22342236
22352237
set pwd [pwd]
22362238
cd $current_diff_path
22372239
22382240
eval exec $exe gui &
22392241
2240-
set env(GIT_DIR) $_gitdir
2241-
set env(GIT_WORK_TREE) $_gitworktree
2242+
if {$old_GIT_DIR ne {}} {
2243+
set env(GIT_DIR) $old_GIT_DIR
2244+
}
22422245
cd $pwd
22432246
22442247
ui_status $::starting_gitk_msg

0 commit comments

Comments
 (0)