@@ -3587,10 +3587,16 @@ set ui_diff_applyhunk [$ctxm index last]
3587
3587
lappend diff_actions [ list $ctxm entryconf $ui_diff_applyhunk -state]
3588
3588
$ctxm add command \
3589
3589
-label [ mc " Apply/Reverse Line" ] \
3590
- -command {apply_range_or_line $cursorX $cursorY ; do_rescan}
3590
+ -command {apply_or_revert_range_or_line $cursorX $cursorY 0 ; do_rescan}
3591
3591
set ui_diff_applyline [ $ctxm index last]
3592
3592
lappend diff_actions [ list $ctxm entryconf $ui_diff_applyline -state]
3593
3593
$ctxm add separator
3594
+ $ctxm add command \
3595
+ -label [ mc " Revert Line" ] \
3596
+ -command {apply_or_revert_range_or_line $cursorX $cursorY 1; do_rescan}
3597
+ set ui_diff_revertline [ $ctxm index last]
3598
+ lappend diff_actions [ list $ctxm entryconf $ui_diff_revertline -state]
3599
+ $ctxm add separator
3594
3600
$ctxm add command \
3595
3601
-label [ mc " Show Less Context" ] \
3596
3602
-command show_less_context
@@ -3687,15 +3693,19 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
3687
3693
set l [ mc " Unstage Hunk From Commit" ]
3688
3694
if {$has_range } {
3689
3695
set t [ mc " Unstage Lines From Commit" ]
3696
+ set r [ mc " Revert Lines" ]
3690
3697
} else {
3691
3698
set t [ mc " Unstage Line From Commit" ]
3699
+ set r [ mc " Revert Line" ]
3692
3700
}
3693
3701
} else {
3694
3702
set l [ mc " Stage Hunk For Commit" ]
3695
3703
if {$has_range } {
3696
3704
set t [ mc " Stage Lines For Commit" ]
3705
+ set r [ mc " Revert Lines" ]
3697
3706
} else {
3698
3707
set t [ mc " Stage Line For Commit" ]
3708
+ set r [ mc " Revert Line" ]
3699
3709
}
3700
3710
}
3701
3711
if {$::is_3way_diff
@@ -3706,11 +3716,24 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
3706
3716
|| [ string match {T?} $state ]
3707
3717
|| [ has_textconv $current_diff_path ] } {
3708
3718
set s disabled
3719
+ set revert_state disabled
3709
3720
} else {
3710
3721
set s normal
3722
+
3723
+ # Only allow reverting changes in the working tree. If
3724
+ # the user wants to revert changes in the index, they
3725
+ # need to unstage those first.
3726
+ if {$::ui_workdir eq $::current_diff_side } {
3727
+ set revert_state normal
3728
+ } else {
3729
+ set revert_state disabled
3730
+ }
3711
3731
}
3732
+
3712
3733
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
3713
3734
$ctxm entryconf $::ui_diff_applyline -state $s -label $t
3735
+ $ctxm entryconf $::ui_diff_revertline -state $revert_state \
3736
+ -label $r
3714
3737
tk_popup $ctxm $X $Y
3715
3738
}
3716
3739
}
0 commit comments