git-gui: (un)stage a range of changes at once
v2 cover git-gui: (un)stage a range of changes at once
Compared to the first version, I fixed a bug concerning staging line(s) when all following lines are deletions (a preexisting bug in git-gui). This version is made based off the master branch of git-gui.git, rather than the master branch of git.git.
The first change fixes a long-standing git-gui bug in an area that the new feature is rewriting anyway. If there's interest in the new feature then maybe the two should just be squashed (using the message from the second). If not, it'd be nice to see the bugfix applied anyway.
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 | 224 ++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 135 insertions(+), 104 deletions(-)
RFC PATCH v2 1/2 Fix applying a line when all following lines are deletions
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.5.rc1.49.ge970
RFC PATCH v2 2/2 Make it possible to apply a range of changes at once
In reply to Jeff Epler---
The diff looks bigger than it is because it changed the indentation level of about 80 lines, and that made it necessary to reflow a lengthy commit block as well.
git-gui.sh | 15 +++- lib/diff.tcl | 225 ++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 135 insertions(+), 105 deletions(-)
git-gui.sh +12 -3
@@ -3194,7 +3194,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
@@ -3234,12 +3234,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 +123 -102
253 lines not on this page · raw message
Signature · 1 line
1.6.5.rc1.49.ge970
I've found another problem, which I'll work on as soon as I find a chance.
When staging multiple "+" lines preceded by a "-" line that must be turned into context, the converted "-" line must come after *all* the "+" lines, not just the first one.
Jeff
Quoted 11 lines · Jeff Epler
Compared to the first version, I fixed a bug concerning staging line(s) when all following lines are deletions (a preexisting bug in git-gui). This version is made based off the master branch of git-gui.git, rather than the master branch of git.git.
The first change fixes a long-standing git-gui bug in an area that the new feature is rewriting anyway. If there's interest in the new feature then maybe the two should just be squashed (using the message from the second). If not, it'd be nice to see the bugfix applied anyway.
Quoted 7 lines
Jeff Epler (2):
Fix applying a line when all following lines are deletions Make it possible to apply a range of changes at oncegit-gui.sh | 15 +++- lib/diff.tcl | 224 ++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 135 insertions(+), 104 deletions(-)
Cc ing Shawn as the git gui maintainer, as he might have missed this series during his away time.
The original series including user comments can be found at
http://thread.gmane.org/gmane.comp.version-control.git/130732
whereas the newest version is here:
http://thread.gmane.org/gmane.comp.version-control.git/130968
--
Peter
Re: [RFC PATCH 1/2] Fix applying a line when all following lines are deletions
In reply to Jeff EplerQuoted 17 lines · Jeff Epler
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 +0
-0
lib/diff.tcl proc apply_line {x y} { · line 667
Quoted 4 lines
lib/diff.tcl +1
-0@@ -664,6 +664,7 @@ proc apply_line {x y} { } set i_l $next_l } + set patch "$patch$pre_context"
Signed-off-by ?
Signature · 1 line
Shawn.
Quoted 6 lines · Jeff Epler
I've found another problem, which I'll work on as soon as I find a chance.
When staging multiple "+" lines preceded by a "-" line that must be turned into context, the converted "-" line must come after *all* the "+" lines, not just the first one.
So the reason this series got stuck was this message, this bug is enough to suggest we shouldn't apply it to my tree yet, so I've been waiting for an update on the topic.
Also, I need a Signed-off-by line.
Signature · 1 line
Shawn.
Quoted 11 lines · Shawn O. Pearce
Quoted 6 lines · Jeff Epler
I've found another problem, which I'll work on as soon as I find a chance.
When staging multiple "+" lines preceded by a "-" line that must be turned into context, the converted "-" line must come after *all* the "+" lines, not just the first one.
So the reason this series got stuck was this message, this bug is enough to suggest we shouldn't apply it to my tree yet, so I've been waiting for an update on the topic.
In an attempt to help this series forward I tried to reproduce this bug but were unsuccessfull. It seems that a change like this:
@@ -13,7 +13,9 @@ set appvers {@@GITGUI_VERSION@@}
set copyright [encoding convertfrom utf-8 { Copyright © 2006, 2007 Shawn Pearce, et. al.
-This program is free software; you can redistribute it and/or modify +Blabla
+blubblub
+lalala
it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
and then trying to stage part of the '+' lines is not enough. Jeff could you clarify or provide an example?
cheers Heiko
Hi,
Quoted 13 lines · Peter Baumann
Quoted 8 lines · Jeff Epler
Jeff Epler (2):
Fix applying a line when all following lines are deletions Make it possible to apply a range of changes at oncegit-gui.sh | 15 +++- lib/diff.tcl | 224 ++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 135 insertions(+), 104 deletions(-)Cc ing Shawn as the git gui maintainer, as he might have missed this series during his away time.
Quoted 7 lines
The original series including user comments can be found at
http://thread.gmane.org/gmane.comp.version-control.git/130732whereas the newest version is here:
http://thread.gmane.org/gmane.comp.version-control.git/130968
Ping? A short reminder for Shawn as I do not see the patches in his tree.
cheers Heiko
Quoted 6 lines · Heiko Voigt
Quoted 2 lines · Peter Baumann
Cc ing Shawn as the git gui maintainer, as he might have missed this series during his away time.
Ping? A short reminder for Shawn as I do not see the patches in his tree.
I have a stack of git-gui patches which I've just ignored in my inbox. I'll work through them this afternoon.
Signature · 1 line
Shawn.
Quoted 1 line · Heiko Voigt
Jeff could you clarify or provide an example?
If I recall correctly, the problem with the v2 patch was when the change was like
@@ -13,8 +13,8 @@ set appvers {@@GITGUI_VERSION@@}
set copyright [encoding convertfrom utf-8 {
Copyright © 2006, 2007 Shawn Pearce, et. al.
-This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by +blah blah
+blah blah
the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
and the 'blah blah' lines were both staged in the same operation.
When doing this, the staged change is actually
+blah blah
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
+blah blah
but the change that should have been staged is:
+blah blah
+blah blah
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
Since it requires staging multiple "+" lines in one go, this problem doesn't exist in git-gui before my changes.
The v3 patch I posted just a few minutes ago fixes this problem.
Jeff
Quoted 9 lines · Jeff Epler
Quoted 1 line · Heiko Voigt
Jeff could you clarify or provide an example?
If I recall correctly, the problem with the v2 patch was when the change was like
@@ -13,8 +13,8 @@ set appvers {@@GITGUI_VERSION@@}
set copyright [encoding convertfrom utf-8 {
Copyright © 2006, 2007 Shawn Pearce, et. al.
Quoted 7 lines
-This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by +blah blah
+blah blah
the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
and the 'blah blah' lines were both staged in the same operation.
Thanks Jeff that was the missing piece. I was able to reproduce the behavior and I can confirm it is gone with the new series. I was not yet able to read through all of the code.
cheers Heiko