@@ -1933,7 +1933,9 @@ proc incr_font_size {font {amt 1}} {
1933
1933
1934
1934
set starting_gitk_msg [ mc " Starting gitk... please wait..." ]
1935
1935
1936
- proc do_gitk {revs} {
1936
+ proc do_gitk {revs {is_submodule false}} {
1937
+ global current_diff_path file_states current_diff_side ui_index
1938
+
1937
1939
# -- Always start gitk through whatever we were loaded with. This
1938
1940
# lets us bypass using shell process on Windows systems.
1939
1941
#
@@ -1951,14 +1953,73 @@ proc do_gitk {revs} {
1951
1953
}
1952
1954
1953
1955
set pwd [ pwd ]
1954
- cd [ file dirname [gitdir] ]
1955
- set env(GIT_DIR) [ file tail [gitdir] ]
1956
1956
1957
+ if {!$is_submodule } {
1958
+ cd [ file dirname [gitdir] ]
1959
+ set env(GIT_DIR) [ file tail [gitdir] ]
1960
+ } else {
1961
+ cd $current_diff_path
1962
+ if {$revs eq {--}} {
1963
+ set s $file_states($current_diff_path)
1964
+ set old_sha1 {}
1965
+ set new_sha1 {}
1966
+ switch -glob -- [ lindex $s 0] {
1967
+ M_ { set old_sha1 [ lindex [lindex $s 2] 1] }
1968
+ _M { set old_sha1 [ lindex [lindex $s 3] 1] }
1969
+ MM {
1970
+ if {$current_diff_side eq $ui_index } {
1971
+ set old_sha1 [ lindex [lindex $s 2] 1]
1972
+ set new_sha1 [ lindex [lindex $s 3] 1]
1973
+ } else {
1974
+ set old_sha1 [ lindex [lindex $s 3] 1]
1975
+ }
1976
+ }
1977
+ }
1978
+ set revs $old_sha1 ...$new_sha1
1979
+ }
1980
+ if {[ info exists env(GIT_DIR)] } {
1981
+ unset env(GIT_DIR)
1982
+ }
1983
+ }
1957
1984
eval exec $cmd $revs " --" " --" &
1958
1985
1959
- if {$old_GIT_DIR eq {}} {
1986
+ if {$old_GIT_DIR ne {}} {
1987
+ set env(GIT_DIR) $old_GIT_DIR
1988
+ }
1989
+ cd $pwd
1990
+
1991
+ ui_status $::starting_gitk_msg
1992
+ after 10000 {
1993
+ ui_ready $starting_gitk_msg
1994
+ }
1995
+ }
1996
+ }
1997
+
1998
+ proc do_git_gui {} {
1999
+ global current_diff_path
2000
+
2001
+ # -- Always start git gui through whatever we were loaded with. This
2002
+ # lets us bypass using shell process on Windows systems.
2003
+ #
2004
+ set exe [ _which git]
2005
+ if {$exe eq {}} {
2006
+ error_popup [ mc " Couldn't find git gui in PATH" ]
2007
+ } else {
2008
+ global env
2009
+
2010
+ if {[ info exists env(GIT_DIR)] } {
2011
+ set old_GIT_DIR $env(GIT_DIR)
1960
2012
unset env(GIT_DIR)
1961
2013
} else {
2014
+ set old_GIT_DIR {}
2015
+ }
2016
+
2017
+ set pwd [ pwd ]
2018
+ cd $current_diff_path
2019
+
2020
+ eval exec $exe gui &
2021
+
2022
+ if {$old_GIT_DIR ne {}} {
1962
2023
set env(GIT_DIR) $old_GIT_DIR
1963
2024
}
1964
2025
cd $pwd
@@ -3154,15 +3215,6 @@ $ui_diff tag raise sel
3154
3215
#
3155
3216
3156
3217
proc create_common_diff_popup {ctxm} {
3157
- $ctxm add command \
3158
- -label [ mc " Show Less Context" ] \
3159
- -command show_less_context
3160
- lappend diff_actions [ list $ctxm entryconf [$ctxm index last] -state]
3161
- $ctxm add command \
3162
- -label [ mc " Show More Context" ] \
3163
- -command show_more_context
3164
- lappend diff_actions [ list $ctxm entryconf [$ctxm index last] -state]
3165
- $ctxm add separator
3166
3218
$ctxm add command \
3167
3219
-label [ mc Refresh] \
3168
3220
-command reshow_diff
@@ -3218,6 +3270,15 @@ $ctxm add command \
3218
3270
set ui_diff_applyline [ $ctxm index last]
3219
3271
lappend diff_actions [ list $ctxm entryconf $ui_diff_applyline -state]
3220
3272
$ctxm add separator
3273
+ $ctxm add command \
3274
+ -label [ mc " Show Less Context" ] \
3275
+ -command show_less_context
3276
+ lappend diff_actions [ list $ctxm entryconf [$ctxm index last] -state]
3277
+ $ctxm add command \
3278
+ -label [ mc " Show More Context" ] \
3279
+ -command show_more_context
3280
+ lappend diff_actions [ list $ctxm entryconf [$ctxm index last] -state]
3281
+ $ctxm add separator
3221
3282
create_common_diff_popup $ctxm
3222
3283
3223
3284
set ctxmmg .vpane.lower.diff.body.ctxmmg
@@ -3240,9 +3301,40 @@ $ctxmmg add command \
3240
3301
-command {merge_resolve_one 1}
3241
3302
lappend diff_actions [ list $ctxmmg entryconf [$ctxmmg index last] -state]
3242
3303
$ctxmmg add separator
3304
+ $ctxmmg add command \
3305
+ -label [ mc " Show Less Context" ] \
3306
+ -command show_less_context
3307
+ lappend diff_actions [ list $ctxmmg entryconf [$ctxmmg index last] -state]
3308
+ $ctxmmg add command \
3309
+ -label [ mc " Show More Context" ] \
3310
+ -command show_more_context
3311
+ lappend diff_actions [ list $ctxmmg entryconf [$ctxmmg index last] -state]
3312
+ $ctxmmg add separator
3243
3313
create_common_diff_popup $ctxmmg
3244
3314
3245
- proc popup_diff_menu {ctxm ctxmmg x y X Y} {
3315
+ set ctxmsm .vpane.lower.diff.body.ctxmsm
3316
+ menu $ctxmsm -tearoff 0
3317
+ $ctxmsm add command \
3318
+ -label [ mc " Visualize These Changes In The Submodule" ] \
3319
+ -command {do_gitk -- true}
3320
+ lappend diff_actions [ list $ctxmsm entryconf [$ctxmsm index last] -state]
3321
+ $ctxmsm add command \
3322
+ -label [ mc " Visualize Current Branch History In The Submodule" ] \
3323
+ -command {do_gitk {} true}
3324
+ lappend diff_actions [ list $ctxmsm entryconf [$ctxmsm index last] -state]
3325
+ $ctxmsm add command \
3326
+ -label [ mc " Visualize All Branch History In The Submodule" ] \
3327
+ -command {do_gitk --all true}
3328
+ lappend diff_actions [ list $ctxmsm entryconf [$ctxmsm index last] -state]
3329
+ $ctxmsm add separator
3330
+ $ctxmsm add command \
3331
+ -label [ mc " Start git gui In The Submodule" ] \
3332
+ -command {do_git_gui}
3333
+ lappend diff_actions [ list $ctxmsm entryconf [$ctxmsm index last] -state]
3334
+ $ctxmsm add separator
3335
+ create_common_diff_popup $ctxmsm
3336
+
3337
+ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
3246
3338
global current_diff_path file_states
3247
3339
set ::cursorX $x
3248
3340
set ::cursorY $y
@@ -3253,6 +3345,8 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
3253
3345
}
3254
3346
if {[ string first {U} $state ] >= 0} {
3255
3347
tk_popup $ctxmmg $X $Y
3348
+ } elseif {$::is_submodule_diff } {
3349
+ tk_popup $ctxmsm $X $Y
3256
3350
} else {
3257
3351
if {$::ui_index eq $::current_diff_side } {
3258
3352
set l [ mc " Unstage Hunk From Commit" ]
@@ -3261,7 +3355,7 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
3261
3355
set l [ mc " Stage Hunk For Commit" ]
3262
3356
set t [ mc " Stage Line For Commit" ]
3263
3357
}
3264
- if {$::is_3way_diff || $::is_submodule_diff
3358
+ if {$::is_3way_diff
3265
3359
|| $current_diff_path eq {}
3266
3360
|| {__} eq $state
3267
3361
|| {_O} eq $state
@@ -3276,7 +3370,7 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {
3276
3370
tk_popup $ctxm $X $Y
3277
3371
}
3278
3372
}
3279
- bind_button3 $ui_diff [ list popup_diff_menu $ctxm $ctxmmg %x %y %X %Y]
3373
+ bind_button3 $ui_diff [ list popup_diff_menu $ctxm $ctxmmg $ctxmsm %x %y %X %Y]
3280
3374
3281
3375
# -- Status Bar
3282
3376
#
0 commit comments