diff options
author | Pratyush Yadav <me@yadavpratyush.com> | 2019-08-26 01:35:27 +0530 |
---|---|---|
committer | Pratyush Yadav <me@yadavpratyush.com> | 2019-08-26 01:35:27 +0530 |
commit | 5f0a516de9e8e6abdd37a79546f904a0ddbce58d (patch) | |
tree | 1d72cb689e7a423f0ecc16eeb1e4e38187a7e7cc /lib | |
parent | Merge remote-tracking branch 'philoakley/dup-gui' (diff) | |
download | tgif-5f0a516de9e8e6abdd37a79546f904a0ddbce58d.tar.xz |
git-gui: allow reverting selected lines
Just like the user can select lines to stage or unstage, add the
ability to revert selected lines.
Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diff.tcl | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl index 4cae10a4c7..d6bee29a13 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -55,7 +55,7 @@ proc reshow_diff {{after {}}} { proc force_diff_encoding {enc} { global current_diff_path - + if {$current_diff_path ne {}} { force_path_encoding $current_diff_path $enc reshow_diff @@ -640,7 +640,7 @@ proc apply_hunk {x y} { } } -proc apply_range_or_line {x y} { +proc apply_or_revert_range_or_line {x y revert} { global current_diff_path current_diff_header current_diff_side global ui_diff ui_index file_states @@ -660,19 +660,27 @@ proc apply_range_or_line {x y} { if {$current_diff_path eq {} || $current_diff_header eq {}} return if {![lock_index apply_hunk]} return - set apply_cmd {apply --cached --whitespace=nowarn} + set apply_cmd {apply --whitespace=nowarn} set mi [lindex $file_states($current_diff_path) 0] if {$current_diff_side eq $ui_index} { set failed_msg [mc "Failed to unstage selected line."] set to_context {+} - lappend apply_cmd --reverse + lappend apply_cmd --reverse --cached if {[string index $mi 0] ne {M}} { unlock_index return } } else { - set failed_msg [mc "Failed to stage selected line."] - set to_context {-} + if {$revert} { + set failed_msg [mc "Failed to revert selected line."] + set to_context {+} + lappend apply_cmd --reverse + } else { + set failed_msg [mc "Failed to stage selected line."] + set to_context {-} + lappend apply_cmd --cached + } + if {[string index $mi 1] ne {M}} { unlock_index return |