@@ -623,7 +623,11 @@ proc git_write {args} {
623
623
}
624
624
625
625
proc githook_read {hook_name args} {
626
- set pchook [ gitdir hooks $hook_name ]
626
+ if {[ package vcompare $::_git_version 2.5.0] >= 0} {
627
+ set pchook [ git rev-parse --git-path " hooks/$hook_name " ]
628
+ } else {
629
+ set pchook [ gitdir hooks $hook_name ]
630
+ }
627
631
lappend args 2>@1
628
632
629
633
# On Windows [ file executable] might lie so we need to ask
@@ -1229,6 +1233,12 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
1229
1233
if {![ info exists env(SSH_ASKPASS)] } {
1230
1234
set env(SSH_ASKPASS) [ gitexec git-gui--askpass]
1231
1235
}
1236
+ if {![ info exists env(GIT_ASKPASS)] } {
1237
+ set env(GIT_ASKPASS) [ gitexec git-gui--askpass]
1238
+ }
1239
+ if {![ info exists env(GIT_ASK_YESNO)] } {
1240
+ set env(GIT_ASK_YESNO) [ gitexec git-gui--askyesno]
1241
+ }
1232
1242
1233
1243
######################################################################
1234
1244
##
@@ -1325,9 +1335,6 @@ if {[lindex $_reponame end] eq {.git}} {
1325
1335
set _reponame [ lindex $_reponame end]
1326
1336
}
1327
1337
1328
- set env(GIT_DIR) $_gitdir
1329
- set env(GIT_WORK_TREE) $_gitworktree
1330
-
1331
1338
######################################################################
1332
1339
##
1333
1340
## global init
@@ -2152,7 +2159,7 @@ set starting_gitk_msg [mc "Starting gitk... please wait..."]
2152
2159
2153
2160
proc do_gitk {revs {is_submodule false}} {
2154
2161
global current_diff_path file_states current_diff_side ui_index
2155
- global _gitdir _gitworktree
2162
+ global _gitworktree
2156
2163
2157
2164
# -- Always start gitk through whatever we were loaded with. This
2158
2165
# lets us bypass using shell process on Windows systems.
@@ -2164,12 +2171,19 @@ proc do_gitk {revs {is_submodule false}} {
2164
2171
} else {
2165
2172
global env
2166
2173
2174
+ if {[ info exists env(GIT_DIR)] } {
2175
+ set old_GIT_DIR $env(GIT_DIR)
2176
+ } else {
2177
+ set old_GIT_DIR {}
2178
+ }
2179
+
2167
2180
set pwd [ pwd ]
2168
2181
2169
2182
if {!$is_submodule } {
2170
2183
if {![ is_bare] } {
2171
2184
cd $_gitworktree
2172
2185
}
2186
+ set env(GIT_DIR) [ file normalize [gitdir] ]
2173
2187
} else {
2174
2188
cd $current_diff_path
2175
2189
if {$revs eq {--}} {
@@ -2190,18 +2204,17 @@ proc do_gitk {revs {is_submodule false}} {
2190
2204
}
2191
2205
set revs $old_sha1 ...$new_sha1
2192
2206
}
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)
2207
+ if {[ info exists env(GIT_DIR)] } {
2208
+ unset env(GIT_DIR)
2209
+ }
2200
2210
}
2201
2211
eval exec $cmd $revs " --" " --" &
2202
2212
2203
- set env(GIT_DIR) $_gitdir
2204
- set env(GIT_WORK_TREE) $_gitworktree
2213
+ if {$old_GIT_DIR ne {}} {
2214
+ set env(GIT_DIR) $old_GIT_DIR
2215
+ } else {
2216
+ unset env(GIT_DIR)
2217
+ }
2205
2218
cd $pwd
2206
2219
2207
2220
ui_status $::starting_gitk_msg
@@ -2222,20 +2235,22 @@ proc do_git_gui {} {
2222
2235
error_popup [ mc " Couldn't find git gui in PATH" ]
2223
2236
} else {
2224
2237
global env
2225
- global _gitdir _gitworktree
2226
2238
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)
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
+ }
2231
2245
2232
2246
set pwd [ pwd ]
2233
2247
cd $current_diff_path
2234
2248
2235
2249
eval exec $exe gui &
2236
2250
2237
- set env(GIT_DIR) $_gitdir
2238
- set env(GIT_WORK_TREE) $_gitworktree
2251
+ if {$old_GIT_DIR ne {}} {
2252
+ set env(GIT_DIR) $old_GIT_DIR
2253
+ }
2239
2254
cd $pwd
2240
2255
2241
2256
ui_status $::starting_gitk_msg
@@ -2706,10 +2721,18 @@ if {![is_bare]} {
2706
2721
}
2707
2722
2708
2723
if {[ is_Windows] } {
2724
+ # Use /git-bash.exe if available
2725
+ set normalized [ file normalize $::argv0 ]
2726
+ regsub " /mingw../libexec/git-core/git-gui$" \
2727
+ $normalized " /git-bash.exe" cmdLine
2728
+ if {$cmdLine != $normalized && [ file exists $cmdLine ] } {
2729
+ set cmdLine [ list " Git Bash" $cmdLine &]
2730
+ } else {
2731
+ set cmdLine [ list " Git Bash" bash --login -l &]
2732
+ }
2709
2733
.mbar.repository add command \
2710
2734
-label [ mc " Git Bash" ] \
2711
- -command {eval exec [ auto_execok start] \
2712
- [ list " Git Bash" bash --login -l &] }
2735
+ -command {eval exec [ auto_execok start] $cmdLine }
2713
2736
}
2714
2737
2715
2738
if {[ is_Windows] || ![ is_bare] } {
0 commit comments