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