@@ -1244,6 +1244,12 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
1244
1244
if {![ info exists env(SSH_ASKPASS)] } {
1245
1245
set env(SSH_ASKPASS) [ gitexec git-gui--askpass]
1246
1246
}
1247
+ if {![ info exists env(GIT_ASKPASS)] } {
1248
+ set env(GIT_ASKPASS) [ gitexec git-gui--askpass]
1249
+ }
1250
+ if {![ info exists env(GIT_ASK_YESNO)] } {
1251
+ set env(GIT_ASK_YESNO) [ gitexec git-gui--askyesno]
1252
+ }
1247
1253
1248
1254
######################################################################
1249
1255
##
@@ -1340,9 +1346,6 @@ if {[lindex $_reponame end] eq {.git}} {
1340
1346
set _reponame [ lindex $_reponame end]
1341
1347
}
1342
1348
1343
- set env(GIT_DIR) $_gitdir
1344
- set env(GIT_WORK_TREE) $_gitworktree
1345
-
1346
1349
######################################################################
1347
1350
##
1348
1351
## global init
@@ -2162,7 +2165,7 @@ set starting_gitk_msg [mc "Starting gitk... please wait..."]
2162
2165
2163
2166
proc do_gitk {revs {is_submodule false}} {
2164
2167
global current_diff_path file_states current_diff_side ui_index
2165
- global _gitdir _gitworktree
2168
+ global _gitworktree
2166
2169
2167
2170
# -- Always start gitk through whatever we were loaded with. This
2168
2171
# lets us bypass using shell process on Windows systems.
@@ -2174,12 +2177,19 @@ proc do_gitk {revs {is_submodule false}} {
2174
2177
} else {
2175
2178
global env
2176
2179
2180
+ if {[ info exists env(GIT_DIR)] } {
2181
+ set old_GIT_DIR $env(GIT_DIR)
2182
+ } else {
2183
+ set old_GIT_DIR {}
2184
+ }
2185
+
2177
2186
set pwd [ pwd ]
2178
2187
2179
2188
if {!$is_submodule } {
2180
2189
if {![ is_bare] } {
2181
2190
cd $_gitworktree
2182
2191
}
2192
+ set env(GIT_DIR) [ file normalize [gitdir] ]
2183
2193
} else {
2184
2194
cd $current_diff_path
2185
2195
if {$revs eq {--}} {
@@ -2200,18 +2210,15 @@ proc do_gitk {revs {is_submodule false}} {
2200
2210
}
2201
2211
set revs $old_sha1 ...$new_sha1
2202
2212
}
2203
- # GIT_DIR and GIT_WORK_TREE for the submodule are not the ones
2204
- # we've been using for the main repository, so unset them.
2205
- # TODO we could make life easier (start up faster?) for gitk
2206
- # by setting these to the appropriate values to allow gitk
2207
- # to skip the heuristics to find their proper value
2208
- unset env(GIT_DIR)
2209
- unset env(GIT_WORK_TREE)
2213
+ if {[ info exists env(GIT_DIR)] } {
2214
+ unset env(GIT_DIR)
2215
+ }
2210
2216
}
2211
2217
eval exec $cmd $revs " --" " --" &
2212
2218
2213
- set env(GIT_DIR) $_gitdir
2214
- set env(GIT_WORK_TREE) $_gitworktree
2219
+ if {$old_GIT_DIR ne {}} {
2220
+ set env(GIT_DIR) $old_GIT_DIR
2221
+ }
2215
2222
cd $pwd
2216
2223
2217
2224
ui_status $::starting_gitk_msg
@@ -2232,20 +2239,22 @@ proc do_git_gui {} {
2232
2239
error_popup [ mc " Couldn't find git gui in PATH" ]
2233
2240
} else {
2234
2241
global env
2235
- global _gitdir _gitworktree
2236
2242
2237
- # see note in do_gitk about unsetting these vars when
2238
- # running tools in a submodule
2239
- unset env(GIT_DIR)
2240
- unset env(GIT_WORK_TREE)
2243
+ if {[ info exists env(GIT_DIR)] } {
2244
+ set old_GIT_DIR $env(GIT_DIR)
2245
+ unset env(GIT_DIR)
2246
+ } else {
2247
+ set old_GIT_DIR {}
2248
+ }
2241
2249
2242
2250
set pwd [ pwd ]
2243
2251
cd $current_diff_path
2244
2252
2245
2253
eval exec $exe gui &
2246
2254
2247
- set env(GIT_DIR) $_gitdir
2248
- set env(GIT_WORK_TREE) $_gitworktree
2255
+ if {$old_GIT_DIR ne {}} {
2256
+ set env(GIT_DIR) $old_GIT_DIR
2257
+ }
2249
2258
cd $pwd
2250
2259
2251
2260
ui_status $::starting_gitk_msg
0 commit comments