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