git-gui: (un)stage a range of changes at once
v3 cover git-gui: (un)stage a range of changes at once
From: Jeff Epler <[email protected]>
This set of patches allows git-gui to stage multiple lines at once by selecting the range and then using the "apply lines" item in the context menu.
Compared to the earlier versions, I've fixed all the bugs I became aware of. I've also added the missing signed-off-by.
The first patch fixes an existing bug in git-gui when staging a deletion followed by another deletion followed by the end of the file.
Jeff Epler (2):
Fix applying a line when all following lines are deletions Make it possible to apply a range of changes at once
git-gui.sh | 15 +++- lib/diff.tcl | 241 ++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 153 insertions(+), 103 deletions(-)
PATCH v3 1/2 Fix applying a line when all following lines are deletions
From: Jeff Epler <[email protected]>
If a diff looked like
@@
context
-del1
-del2
and you wanted to stage the deletion 'del1', the generated patch wouldn't apply because it was missing the line 'del2' converted to context, but this line was counted in the @@-line
--- lib/diff.tcl | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
lib/diff.tcl +1 -0
@@ -664,6 +664,7 @@ proc apply_line {x y} { } set i_l $next_l } + set patch "$patch$pre_context" set patch "@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\n$patch" if {[catch {
Signature · 1 line
1.6.3.3
PATCH v3 2/2 Make it possible to apply a range of changes at once
In reply to [email protected]From: Jeff Epler <[email protected]>
--- git-gui.sh | 15 +++- lib/diff.tcl | 242 ++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 153 insertions(+), 104 deletions(-)
git-gui.sh +12 -3
@@ -3199,7 +3199,7 @@ set ui_diff_applyhunk [$ctxm index last] lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state] $ctxm add command \ -label [mc "Apply/Reverse Line"] \ - -command {apply_line $cursorX $cursorY; do_rescan} + -command {apply_range_or_line $cursorX $cursorY; do_rescan} set ui_diff_applyline [$ctxm index last] lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state] $ctxm add separator
@@ -3239,12 +3239,21 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} { if {[string first {U} $state] >= 0} { tk_popup $ctxmmg $X $Y } else { + set has_range [expr {[$::ui_diff tag nextrange sel 0.0] != {}}] if {$::ui_index eq $::current_diff_side} { set l [mc "Unstage Hunk From Commit"] - set t [mc "Unstage Line From Commit"] + if {$has_range} { + set t [mc "Unstage Lines From Commit"] + } else { + set t [mc "Unstage Line From Commit"] + } } else { set l [mc "Stage Hunk For Commit"] - set t [mc "Stage Line For Commit"] + if {$has_range} { + set t [mc "Stage Lines For Commit"] + } else { + set t [mc "Stage Line For Commit"] + } } if {$::is_3way_diff || $::is_submodule_diff || $current_diff_path eq {}
lib/diff.tcl +141 -101
271 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Shawn O. Pearce
AppliedRe: [PATCH 2/2] Make it possible to apply a range of changes at once
Quoted 7 lines · [email protected] wrote:
From: Jeff Epler <[email protected]>
Signed-off-by Jeff Epler <[email protected]>--- git-gui.sh | 15 +++- lib/diff.tcl | 242 ++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 153 insertions(+), 104 deletions(-)
Thanks, applied.
Signature · 1 line
Shawn.