@@ -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
@@ -2158,7 +2161,7 @@ set starting_gitk_msg [mc "Starting gitk... please wait..."]
2158
2161
2159
2162
proc do_gitk {revs {is_submodule false}} {
2160
2163
global current_diff_path file_states current_diff_side ui_index
2161
- global _gitdir _gitworktree
2164
+ global _gitworktree
2162
2165
2163
2166
# -- Always start gitk through whatever we were loaded with. This
2164
2167
# lets us bypass using shell process on Windows systems.
@@ -2170,12 +2173,19 @@ proc do_gitk {revs {is_submodule false}} {
2170
2173
} else {
2171
2174
global env
2172
2175
2176
+ if {[ info exists env(GIT_DIR)] } {
2177
+ set old_GIT_DIR $env(GIT_DIR)
2178
+ } else {
2179
+ set old_GIT_DIR {}
2180
+ }
2181
+
2173
2182
set pwd [ pwd ]
2174
2183
2175
2184
if {!$is_submodule } {
2176
2185
if {![ is_bare] } {
2177
2186
cd $_gitworktree
2178
2187
}
2188
+ set env(GIT_DIR) [ file normalize [gitdir] ]
2179
2189
} else {
2180
2190
cd $current_diff_path
2181
2191
if {$revs eq {--}} {
@@ -2196,18 +2206,15 @@ proc do_gitk {revs {is_submodule false}} {
2196
2206
}
2197
2207
set revs $old_sha1 ...$new_sha1
2198
2208
}
2199
- # GIT_DIR and GIT_WORK_TREE for the submodule are not the ones
2200
- # we've been using for the main repository, so unset them.
2201
- # TODO we could make life easier (start up faster?) for gitk
2202
- # by setting these to the appropriate values to allow gitk
2203
- # to skip the heuristics to find their proper value
2204
- unset env(GIT_DIR)
2205
- unset env(GIT_WORK_TREE)
2209
+ if {[ info exists env(GIT_DIR)] } {
2210
+ unset env(GIT_DIR)
2211
+ }
2206
2212
}
2207
2213
eval exec $cmd $revs " --" " --" &
2208
2214
2209
- set env(GIT_DIR) $_gitdir
2210
- set env(GIT_WORK_TREE) $_gitworktree
2215
+ if {$old_GIT_DIR ne {}} {
2216
+ set env(GIT_DIR) $old_GIT_DIR
2217
+ }
2211
2218
cd $pwd
2212
2219
2213
2220
ui_status $::starting_gitk_msg
@@ -2228,20 +2235,22 @@ proc do_git_gui {} {
2228
2235
error_popup [ mc " Couldn't find git gui in PATH" ]
2229
2236
} else {
2230
2237
global env
2231
- global _gitdir _gitworktree
2232
2238
2233
- # see note in do_gitk about unsetting these vars when
2234
- # running tools in a submodule
2235
- unset env(GIT_DIR)
2236
- unset env(GIT_WORK_TREE)
2239
+ if {[ info exists env(GIT_DIR)] } {
2240
+ set old_GIT_DIR $env(GIT_DIR)
2241
+ unset env(GIT_DIR)
2242
+ } else {
2243
+ set old_GIT_DIR {}
2244
+ }
2237
2245
2238
2246
set pwd [ pwd ]
2239
2247
cd $current_diff_path
2240
2248
2241
2249
eval exec $exe gui &
2242
2250
2243
- set env(GIT_DIR) $_gitdir
2244
- set env(GIT_WORK_TREE) $_gitworktree
2251
+ if {$old_GIT_DIR ne {}} {
2252
+ set env(GIT_DIR) $old_GIT_DIR
2253
+ }
2245
2254
cd $pwd
2246
2255
2247
2256
ui_status $::starting_gitk_msg
0 commit comments