@@ -1226,6 +1226,12 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
1226
1226
if {![ info exists env(SSH_ASKPASS)] } {
1227
1227
set env(SSH_ASKPASS) [ gitexec git-gui--askpass]
1228
1228
}
1229
+ if {![ info exists env(GIT_ASKPASS)] } {
1230
+ set env(GIT_ASKPASS) [ gitexec git-gui--askpass]
1231
+ }
1232
+ if {![ info exists env(GIT_ASK_YESNO)] } {
1233
+ set env(GIT_ASK_YESNO) [ gitexec git-gui--askyesno]
1234
+ }
1229
1235
1230
1236
######################################################################
1231
1237
##
@@ -1322,9 +1328,6 @@ if {[lindex $_reponame end] eq {.git}} {
1322
1328
set _reponame [ lindex $_reponame end]
1323
1329
}
1324
1330
1325
- set env(GIT_DIR) $_gitdir
1326
- set env(GIT_WORK_TREE) $_gitworktree
1327
-
1328
1331
######################################################################
1329
1332
##
1330
1333
## global init
@@ -2147,7 +2150,7 @@ set starting_gitk_msg [mc "Starting gitk... please wait..."]
2147
2150
2148
2151
proc do_gitk {revs {is_submodule false}} {
2149
2152
global current_diff_path file_states current_diff_side ui_index
2150
- global _gitdir _gitworktree
2153
+ global _gitworktree
2151
2154
2152
2155
# -- Always start gitk through whatever we were loaded with. This
2153
2156
# lets us bypass using shell process on Windows systems.
@@ -2159,12 +2162,19 @@ proc do_gitk {revs {is_submodule false}} {
2159
2162
} else {
2160
2163
global env
2161
2164
2165
+ if {[ info exists env(GIT_DIR)] } {
2166
+ set old_GIT_DIR $env(GIT_DIR)
2167
+ } else {
2168
+ set old_GIT_DIR {}
2169
+ }
2170
+
2162
2171
set pwd [ pwd ]
2163
2172
2164
2173
if {!$is_submodule } {
2165
2174
if {![ is_bare] } {
2166
2175
cd $_gitworktree
2167
2176
}
2177
+ set env(GIT_DIR) [ file normalize [gitdir] ]
2168
2178
} else {
2169
2179
cd $current_diff_path
2170
2180
if {$revs eq {--}} {
@@ -2185,18 +2195,15 @@ proc do_gitk {revs {is_submodule false}} {
2185
2195
}
2186
2196
set revs $old_sha1 ...$new_sha1
2187
2197
}
2188
- # GIT_DIR and GIT_WORK_TREE for the submodule are not the ones
2189
- # we've been using for the main repository, so unset them.
2190
- # TODO we could make life easier (start up faster?) for gitk
2191
- # by setting these to the appropriate values to allow gitk
2192
- # to skip the heuristics to find their proper value
2193
- unset env(GIT_DIR)
2194
- unset env(GIT_WORK_TREE)
2198
+ if {[ info exists env(GIT_DIR)] } {
2199
+ unset env(GIT_DIR)
2200
+ }
2195
2201
}
2196
2202
eval exec $cmd $revs " --" " --" &
2197
2203
2198
- set env(GIT_DIR) $_gitdir
2199
- set env(GIT_WORK_TREE) $_gitworktree
2204
+ if {$old_GIT_DIR ne {}} {
2205
+ set env(GIT_DIR) $old_GIT_DIR
2206
+ }
2200
2207
cd $pwd
2201
2208
2202
2209
ui_status $::starting_gitk_msg
@@ -2217,20 +2224,22 @@ proc do_git_gui {} {
2217
2224
error_popup [ mc " Couldn't find git gui in PATH" ]
2218
2225
} else {
2219
2226
global env
2220
- global _gitdir _gitworktree
2221
2227
2222
- # see note in do_gitk about unsetting these vars when
2223
- # running tools in a submodule
2224
- unset env(GIT_DIR)
2225
- unset env(GIT_WORK_TREE)
2228
+ if {[ info exists env(GIT_DIR)] } {
2229
+ set old_GIT_DIR $env(GIT_DIR)
2230
+ unset env(GIT_DIR)
2231
+ } else {
2232
+ set old_GIT_DIR {}
2233
+ }
2226
2234
2227
2235
set pwd [ pwd ]
2228
2236
cd $current_diff_path
2229
2237
2230
2238
eval exec $exe gui &
2231
2239
2232
- set env(GIT_DIR) $_gitdir
2233
- set env(GIT_WORK_TREE) $_gitworktree
2240
+ if {$old_GIT_DIR ne {}} {
2241
+ set env(GIT_DIR) $old_GIT_DIR
2242
+ }
2234
2243
cd $pwd
2235
2244
2236
2245
ui_status $::starting_gitk_msg
0 commit comments