{"thread":{"id":"21317","subject":"[RFC PATCH 1/2] Fix applying a line when all following lines are deletions","startedAt":"2009-10-21T21:20:21Z","lastAt":"2009-12-11T18:57:06Z","messageCount":12,"participants":["Jeff Epler","Peter Baumann","Heiko Voigt","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"125649","messageId":"1256160023-29629-1-git-send-email-jepler@unpythonic.net","threadId":"21317","inReplyTo":null,"subject":"[RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Jeff Epler","fromEmail":"jepler@unpythonic.net","sentAt":"2009-10-21T21:20:21Z","receivedAt":"2009-10-21T21:20:21Z","isPatch":true,"sender":{"key":"jepler@unpythonic.net","avatar":"https://avatars.githubusercontent.com/u/1517291?v=4"},"body":"Compared to the first version, I fixed a bug concerning staging line(s)\nwhen all following lines are deletions (a preexisting bug in git-gui).\nThis version is made based off the master branch of git-gui.git, rather\nthan the master branch of git.git.\n\nThe first change fixes a long-standing git-gui bug in an area that the\nnew feature is rewriting anyway.  If there's interest in the new feature\nthen maybe the two should just be squashed (using the message from the\nsecond).  If not, it'd be nice to see the bugfix applied anyway.\n\n\nJeff Epler (2):\n  Fix applying a line when all following lines are deletions\n  Make it possible to apply a range of changes at once\n\n git-gui.sh   |   15 +++-\n lib/diff.tcl |  224 ++++++++++++++++++++++++++++++++--------------------------\n 2 files changed, 135 insertions(+), 104 deletions(-)\n"},{"id":"125648","messageId":"1256160023-29629-2-git-send-email-jepler@unpythonic.net","threadId":"21317","inReplyTo":"1256160023-29629-1-git-send-email-jepler@unpythonic.net","subject":"[RFC PATCH 1/2] Fix applying a line when all following lines are deletions","fromName":"Jeff Epler","fromEmail":"jepler@unpythonic.net","sentAt":"2009-10-21T21:20:22Z","receivedAt":"2009-10-21T21:20:22Z","isPatch":true,"sender":{"key":"jepler@unpythonic.net","avatar":"https://avatars.githubusercontent.com/u/1517291?v=4"},"body":"If a diff looked like\n @@\n  context\n -del1\n -del2\nand you wanted to stage the deletion 'del1', the generated patch\nwouldn't apply because it was missing the line 'del2' converted to\ncontext, but this line was counted in the @@-line\n---\n lib/diff.tcl |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex bd5d189..066755b 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -664,6 +664,7 @@ proc apply_line {x y} {\n \t\t}\n \t\tset i_l $next_l\n \t}\n+\tset patch \"$patch$pre_context\"\n \tset patch \"@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\\n$patch\"\n \n \tif {[catch {\n-- \n1.6.5.rc1.49.ge970\n"},{"id":"125650","messageId":"1256160023-29629-3-git-send-email-jepler@unpythonic.net","threadId":"21317","inReplyTo":"1256160023-29629-1-git-send-email-jepler@unpythonic.net","subject":"[RFC PATCH 2/2] Make it possible to apply a range of changes at once","fromName":"Jeff Epler","fromEmail":"jepler@unpythonic.net","sentAt":"2009-10-21T21:20:23Z","receivedAt":"2009-10-21T21:20:23Z","isPatch":true,"sender":{"key":"jepler@unpythonic.net","avatar":"https://avatars.githubusercontent.com/u/1517291?v=4"},"body":"---\nThe diff looks bigger than it is because it changed the indentation\nlevel of about 80 lines, and that made it necessary to reflow a lengthy\ncommit block as well.\n\n git-gui.sh   |   15 +++-\n lib/diff.tcl |  225 ++++++++++++++++++++++++++++++++--------------------------\n 2 files changed, 135 insertions(+), 105 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 09b2720..c69d904 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -3194,7 +3194,7 @@ set ui_diff_applyhunk [$ctxm index last]\n lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]\n $ctxm add command \\\n \t-label [mc \"Apply/Reverse Line\"] \\\n-\t-command {apply_line $cursorX $cursorY; do_rescan}\n+\t-command {apply_range_or_line $cursorX $cursorY; do_rescan}\n set ui_diff_applyline [$ctxm index last]\n lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]\n $ctxm add separator\n@@ -3234,12 +3234,21 @@ proc popup_diff_menu {ctxm ctxmmg x y X Y} {\n \tif {[string first {U} $state] >= 0} {\n \t\ttk_popup $ctxmmg $X $Y\n \t} else {\n+\t\tset has_range [expr {[$::ui_diff tag nextrange sel 0.0] != {}}]\n \t\tif {$::ui_index eq $::current_diff_side} {\n \t\t\tset l [mc \"Unstage Hunk From Commit\"]\n-\t\t\tset t [mc \"Unstage Line From Commit\"]\n+\t\t\tif {$has_range} {\n+\t\t\t\tset t [mc \"Unstage Lines From Commit\"]\n+\t\t\t} else {\n+\t\t\t\tset t [mc \"Unstage Line From Commit\"]\n+\t\t\t}\n \t\t} else {\n \t\t\tset l [mc \"Stage Hunk For Commit\"]\n-\t\t\tset t [mc \"Stage Line For Commit\"]\n+\t\t\tif {$has_range} {\n+\t\t\t\tset t [mc \"Stage Lines For Commit\"]\n+\t\t\t} else {\n+\t\t\t\tset t [mc \"Stage Line For Commit\"]\n+\t\t\t}\n \t\t}\n \t\tif {$::is_3way_diff || $::is_submodule_diff\n \t\t\t|| $current_diff_path eq {}\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 066755b..0fe3ec6 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -533,10 +533,23 @@ proc apply_hunk {x y} {\n \t}\n }\n \n-proc apply_line {x y} {\n+proc apply_range_or_line {x y} {\n \tglobal current_diff_path current_diff_header current_diff_side\n \tglobal ui_diff ui_index file_states\n \n+\tset selected [$ui_diff tag nextrange sel 0.0]\n+\n+\tif {$selected == {}} {\n+\t\tset first [$ui_diff index \"@$x,$y\"]\n+\t\tset last $first\n+\t} else {\n+\t\tset first [lindex $selected 0]\n+\t\tset last [lindex $selected 1]\n+\t}\n+\n+\tset first_l [$ui_diff index \"$first linestart\"]\n+\tset last_l [$ui_diff index \"$last lineend\"]\n+\n \tif {$current_diff_path eq {} || $current_diff_header eq {}} return\n \tif {![lock_index apply_hunk]} return\n \n@@ -559,120 +572,128 @@ proc apply_line {x y} {\n \t\t}\n \t}\n \n-\tset the_l [$ui_diff index @$x,$y]\n+\tset wholepatch {}\n \n-\t# operate only on change lines\n-\tset c1 [$ui_diff get \"$the_l linestart\"]\n-\tif {$c1 ne {+} && $c1 ne {-}} {\n-\t\tunlock_index\n-\t\treturn\n-\t}\n-\tset sign $c1\n-\n-\tset i_l [$ui_diff search -backwards -regexp ^@@ $the_l 0.0]\n-\tif {$i_l eq {}} {\n-\t\tunlock_index\n-\t\treturn\n-\t}\n-\t# $i_l is now at the beginning of a line\n+\twhile {$first_l < $last_l} {\n+\t\tset i_l [$ui_diff search -backwards -regexp ^@@ $first_l 0.0]\n+\t\tif {$i_l eq {}} {\n+\t\t\t# If there's not a @@ above, then the selected range\n+\t\t\t# must have come before the first_l @@\n+\t\t\tset i_l [$ui_diff search -regexp ^@@ $first_l $last_l]\n+\t\t}\n+\t\tif {$i_l eq {}} {\n+\t\t\tunlock_index\n+\t\t\treturn\n+\t\t}\n+\t\t# $i_l is now at the beginning of a line\n \n-\t# pick start line number from hunk header\n-\tset hh [$ui_diff get $i_l \"$i_l + 1 lines\"]\n-\tset hh [lindex [split $hh ,] 0]\n-\tset hln [lindex [split $hh -] 1]\n+\t\t# pick start line number from hunk header\n+\t\tset hh [$ui_diff get $i_l \"$i_l + 1 lines\"]\n+\t\tset hh [lindex [split $hh ,] 0]\n+\t\tset hln [lindex [split $hh -] 1]\n \n-\t# There is a special situation to take care of. Consider this hunk:\n-\t#\n-\t#    @@ -10,4 +10,4 @@\n-\t#     context before\n-\t#    -old 1\n-\t#    -old 2\n-\t#    +new 1\n-\t#    +new 2\n-\t#     context after\n-\t#\n-\t# We used to keep the context lines in the order they appear in the\n-\t# hunk. But then it is not possible to correctly stage only\n-\t# \"-old 1\" and \"+new 1\" - it would result in this staged text:\n-\t#\n-\t#    context before\n-\t#    old 2\n-\t#    new 1\n-\t#    context after\n-\t#\n-\t# (By symmetry it is not possible to *un*stage \"old 2\" and \"new 2\".)\n-\t#\n-\t# We resolve the problem by introducing an asymmetry, namely, when\n-\t# a \"+\" line is *staged*, it is moved in front of the context lines\n-\t# that are generated from the \"-\" lines that are immediately before\n-\t# the \"+\" block. That is, we construct this patch:\n-\t#\n-\t#    @@ -10,4 +10,5 @@\n-\t#     context before\n-\t#    +new 1\n-\t#     old 1\n-\t#     old 2\n-\t#     context after\n-\t#\n-\t# But we do *not* treat \"-\" lines that are *un*staged in a special\n-\t# way.\n-\t#\n-\t# With this asymmetry it is possible to stage the change\n-\t# \"old 1\" -> \"new 1\" directly, and to stage the change\n-\t# \"old 2\" -> \"new 2\" by first staging the entire hunk and\n-\t# then unstaging the change \"old 1\" -> \"new 1\".\n-\n-\t# This is non-empty if and only if we are _staging_ changes;\n-\t# then it accumulates the consecutive \"-\" lines (after converting\n-\t# them to context lines) in order to be moved after the \"+\" change\n-\t# line.\n-\tset pre_context {}\n-\n-\tset n 0\n-\tset i_l [$ui_diff index \"$i_l + 1 lines\"]\n-\tset patch {}\n-\twhile {[$ui_diff compare $i_l < \"end - 1 chars\"] &&\n-\t       [$ui_diff get $i_l \"$i_l + 2 chars\"] ne {@@}} {\n-\t\tset next_l [$ui_diff index \"$i_l + 1 lines\"]\n-\t\tset c1 [$ui_diff get $i_l]\n-\t\tif {[$ui_diff compare $i_l <= $the_l] &&\n-\t\t    [$ui_diff compare $the_l < $next_l]} {\n-\t\t\t# the line to stage/unstage\n-\t\t\tset ln [$ui_diff get $i_l $next_l]\n-\t\t\tif {$c1 eq {-}} {\n-\t\t\t\tset n [expr $n+1]\n+\t\t# There is a special situation to take care of. Consider this\n+\t\t# hunk:\n+\t\t#\n+\t\t#    @@ -10,4 +10,4 @@\n+\t\t#     context before\n+\t\t#    -old 1\n+\t\t#    -old 2\n+\t\t#    +new 1\n+\t\t#    +new 2\n+\t\t#     context after\n+\t\t#\n+\t\t# We used to keep the context lines in the order they appear in\n+\t\t# the hunk. But then it is not possible to correctly stage only\n+\t\t# \"-old 1\" and \"+new 1\" - it would result in this staged text:\n+\t\t#\n+\t\t#    context before\n+\t\t#    old 2\n+\t\t#    new 1\n+\t\t#    context after\n+\t\t#\n+\t\t# (By symmetry it is not possible to *un*stage \"old 2\" and \"new\n+\t\t# 2\".)\n+\t\t#\n+\t\t# We resolve the problem by introducing an asymmetry, namely,\n+\t\t# when a \"+\" line is *staged*, it is moved in front of the\n+\t\t# context lines that are generated from the \"-\" lines that are\n+\t\t# immediately before the \"+\" block. That is, we construct this\n+\t\t# patch:\n+\t\t#\n+\t\t#    @@ -10,4 +10,5 @@\n+\t\t#     context before\n+\t\t#    +new 1\n+\t\t#     old 1\n+\t\t#     old 2\n+\t\t#     context after\n+\t\t#\n+\t\t# But we do *not* treat \"-\" lines that are *un*staged in a\n+\t\t# special way.\n+\t\t#\n+\t\t# With this asymmetry it is possible to stage the change \"old\n+\t\t# 1\" -> \"new 1\" directly, and to stage the change \"old 2\" ->\n+\t\t# \"new 2\" by first staging the entire hunk and then unstaging\n+\t\t# the change \"old 1\" -> \"new 1\".\n+\n+\t\t# This is non-empty if and only if we are _staging_ changes;\n+\t\t# then it accumulates the consecutive \"-\" lines (after\n+\t\t# converting them to context lines) in order to be moved after\n+\t\t# the \"+\" change line.\n+\t\tset pre_context {}\n+\n+\t\tset n 0\n+\t\tset m 0\n+\t\tset i_l [$ui_diff index \"$i_l + 1 lines\"]\n+\t\tset patch {}\n+\t\twhile {[$ui_diff compare $i_l < \"end - 1 chars\"] &&\n+\t\t       [$ui_diff get $i_l \"$i_l + 2 chars\"] ne {@@}} {\n+\t\t\tset next_l [$ui_diff index \"$i_l + 1 lines\"]\n+\t\t\tset c1 [$ui_diff get $i_l]\n+\t\t\tif {[$ui_diff compare $first_l <= $i_l] &&\n+\t\t\t    [$ui_diff compare $i_l < $last_l] &&\n+\t\t\t    ($c1 eq {-} || $c1 eq {+})} {\n+\t\t\t\t# a line to stage/unstage\n+\t\t\t\tset ln [$ui_diff get $i_l $next_l]\n+\t\t\t\tif {$c1 eq {-}} {\n+\t\t\t\t\tset n [expr $n+1]\n+\t\t\t\t\tset patch \"$patch$pre_context$ln\"\n+\t\t\t\t} else {\n+\t\t\t\t\tset m [expr $m+1]\n+\t\t\t\t\tset patch \"$patch$ln$pre_context\"\n+\t\t\t\t}\n+\t\t\t\tset pre_context {}\n+\t\t\t} elseif {$c1 ne {-} && $c1 ne {+}} {\n+\t\t\t\t# context line\n+\t\t\t\tset ln [$ui_diff get $i_l $next_l]\n \t\t\t\tset patch \"$patch$pre_context$ln\"\n-\t\t\t} else {\n-\t\t\t\tset patch \"$patch$ln$pre_context\"\n-\t\t\t}\n-\t\t\tset pre_context {}\n-\t\t} elseif {$c1 ne {-} && $c1 ne {+}} {\n-\t\t\t# context line\n-\t\t\tset ln [$ui_diff get $i_l $next_l]\n-\t\t\tset patch \"$patch$pre_context$ln\"\n-\t\t\tset n [expr $n+1]\n-\t\t\tset pre_context {}\n-\t\t} elseif {$c1 eq $to_context} {\n-\t\t\t# turn change line into context line\n-\t\t\tset ln [$ui_diff get \"$i_l + 1 chars\" $next_l]\n-\t\t\tif {$c1 eq {-}} {\n-\t\t\t\tset pre_context \"$pre_context $ln\"\n-\t\t\t} else {\n-\t\t\t\tset patch \"$patch $ln\"\n+\t\t\t\tset n [expr $n+1]\n+\t\t\t\tset m [expr $m+1]\n+\t\t\t\tset pre_context {}\n+\t\t\t} elseif {$c1 eq $to_context} {\n+\t\t\t\t# turn change line into context line\n+\t\t\t\tset ln [$ui_diff get \"$i_l + 1 chars\" $next_l]\n+\t\t\t\tif {$c1 eq {-}} {\n+\t\t\t\t\tset pre_context \"$pre_context $ln\"\n+\t\t\t\t} else {\n+\t\t\t\t\tset patch \"$patch $ln\"\n+\t\t\t\t}\n+\t\t\t\tset n [expr $n+1]\n+\t\t\t\tset m [expr $m+1]\n \t\t\t}\n-\t\t\tset n [expr $n+1]\n+\t\t\tset i_l $next_l\n \t\t}\n-\t\tset i_l $next_l\n+\t\tset patch \"$patch$pre_context\"\n+\t\tset wholepatch \"$wholepatch@@ -$hln,$n +$hln,$m @@\\n$patch\"\n+\t\tset first_l [$ui_diff index \"$next_l + 1 lines\"]\n \t}\n-\tset patch \"$patch$pre_context\"\n-\tset patch \"@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\\n$patch\"\n \n \tif {[catch {\n \t\tset enc [get_path_encoding $current_diff_path]\n \t\tset p [eval git_write $apply_cmd]\n \t\tfconfigure $p -translation binary -encoding $enc\n \t\tputs -nonewline $p $current_diff_header\n-\t\tputs -nonewline $p $patch\n+\t\tputs -nonewline $p $wholepatch\n \t\tclose $p} err]} {\n \t\terror_popup [append $failed_msg \"\\n\\n$err\"]\n \t}\n-- \n1.6.5.rc1.49.ge970\n"},{"id":"125942","messageId":"20091026193903.GA27319@unpythonic.net","threadId":"21317","inReplyTo":"1256160023-29629-1-git-send-email-jepler@unpythonic.net","subject":"Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Jeff Epler","fromEmail":"jepler@unpythonic.net","sentAt":"2009-10-26T19:39:03Z","receivedAt":"2009-10-26T19:39:03Z","isPatch":true,"sender":{"key":"jepler@unpythonic.net","avatar":"https://avatars.githubusercontent.com/u/1517291?v=4"},"body":"I've found another problem, which I'll work on as soon as I find a\nchance.\n\nWhen staging multiple \"+\" lines preceded by a \"-\" line that must be\nturned into context, the converted \"-\" line must come after *all* the\n\"+\" lines, not just the first one.\n\nJeff\n"},{"id":"126246","messageId":"20091029073454.GA25843@m62s10.vlinux.de","threadId":"21317","inReplyTo":"1256160023-29629-1-git-send-email-jepler@unpythonic.net","subject":"Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Peter Baumann","fromEmail":"waste.manager@gmx.de","sentAt":"2009-10-29T07:34:54Z","receivedAt":"2009-10-29T07:34:54Z","isPatch":true,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"On Wed, Oct 21, 2009 at 04:20:21PM -0500, Jeff Epler wrote:\n> Compared to the first version, I fixed a bug concerning staging line(s)\n> when all following lines are deletions (a preexisting bug in git-gui).\n> This version is made based off the master branch of git-gui.git, rather\n> than the master branch of git.git.\n> \n> The first change fixes a long-standing git-gui bug in an area that the\n> new feature is rewriting anyway.  If there's interest in the new feature\n> then maybe the two should just be squashed (using the message from the\n> second).  If not, it'd be nice to see the bugfix applied anyway.\n> \n> \n> Jeff Epler (2):\n>   Fix applying a line when all following lines are deletions\n>   Make it possible to apply a range of changes at once\n> \n>  git-gui.sh   |   15 +++-\n>  lib/diff.tcl |  224 ++++++++++++++++++++++++++++++++--------------------------\n>  2 files changed, 135 insertions(+), 104 deletions(-)\n\nCc ing Shawn as the git gui maintainer, as he might have missed this series\nduring his away time.\n\nThe original series including user comments can be found at\n\n\thttp://thread.gmane.org/gmane.comp.version-control.git/130732\n\nwhereas the newest version is here:\n\n\thttp://thread.gmane.org/gmane.comp.version-control.git/130968\n\n--\nPeter\n"},{"id":"129245","messageId":"20091204220730.GB3979@book.hvoigt.net","threadId":"21317","inReplyTo":"20091029073454.GA25843@m62s10.vlinux.de","subject":"Re: Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2009-12-04T22:07:30Z","receivedAt":"2009-12-04T22:07:30Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Hi,\n\nOn Thu, Oct 29, 2009 at 08:34:54AM +0100, Peter Baumann wrote:\n> On Wed, Oct 21, 2009 at 04:20:21PM -0500, Jeff Epler wrote:\n> > \n> > Jeff Epler (2):\n> >   Fix applying a line when all following lines are deletions\n> >   Make it possible to apply a range of changes at once\n> > \n> >  git-gui.sh   |   15 +++-\n> >  lib/diff.tcl |  224 ++++++++++++++++++++++++++++++++--------------------------\n> >  2 files changed, 135 insertions(+), 104 deletions(-)\n> \n> Cc ing Shawn as the git gui maintainer, as he might have missed this series\n> during his away time.\n> \n> The original series including user comments can be found at\n> \n> \thttp://thread.gmane.org/gmane.comp.version-control.git/130732\n> \n> whereas the newest version is here:\n> \n> \thttp://thread.gmane.org/gmane.comp.version-control.git/130968\n\nPing? A short reminder for Shawn as I do not see the patches in his\ntree.\n\ncheers Heiko\n"},{"id":"129291","messageId":"20091205211946.GE5610@spearce.org","threadId":"21317","inReplyTo":"20091204220730.GB3979@book.hvoigt.net","subject":"Re: Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-12-05T21:19:46Z","receivedAt":"2009-12-05T21:19:46Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> On Thu, Oct 29, 2009 at 08:34:54AM +0100, Peter Baumann wrote:\n> > Cc ing Shawn as the git gui maintainer, as he might have missed this series\n> > during his away time.\n> \n> Ping? A short reminder for Shawn as I do not see the patches in his\n> tree.\n\nI have a stack of git-gui patches which I've just ignored in\nmy inbox.  I'll work through them this afternoon.\n\n-- \nShawn.\n"},{"id":"129292","messageId":"20091205213245.GF5610@spearce.org","threadId":"21317","inReplyTo":"1256160023-29629-2-git-send-email-jepler@unpythonic.net","subject":"Re: [RFC PATCH 1/2] Fix applying a line when all following lines are deletions","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-12-05T21:32:45Z","receivedAt":"2009-12-05T21:32:45Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff Epler <jepler@unpythonic.net> wrote:\n> If a diff looked like\n>  @@\n>   context\n>  -del1\n>  -del2\n> and you wanted to stage the deletion 'del1', the generated patch\n> wouldn't apply because it was missing the line 'del2' converted to\n> context, but this line was counted in the @@-line\n> ---\n>  lib/diff.tcl |    1 +\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n> \n> diff --git a/lib/diff.tcl b/lib/diff.tcl\n> index bd5d189..066755b 100644\n> --- a/lib/diff.tcl\n> +++ b/lib/diff.tcl\n> @@ -664,6 +664,7 @@ proc apply_line {x y} {\n>  \t\t}\n>  \t\tset i_l $next_l\n>  \t}\n> +\tset patch \"$patch$pre_context\"\n\nSigned-off-by ?\n\n-- \nShawn.\n"},{"id":"129293","messageId":"20091205213613.GG5610@spearce.org","threadId":"21317","inReplyTo":"20091026193903.GA27319@unpythonic.net","subject":"Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-12-05T21:36:13Z","receivedAt":"2009-12-05T21:36:13Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff Epler <jepler@unpythonic.net> wrote:\n> I've found another problem, which I'll work on as soon as I find a\n> chance.\n> \n> When staging multiple \"+\" lines preceded by a \"-\" line that must be\n> turned into context, the converted \"-\" line must come after *all* the\n> \"+\" lines, not just the first one.\n\nSo the reason this series got stuck was this message, this bug is\nenough to suggest we shouldn't apply it to my tree yet, so I've\nbeen waiting for an update on the topic.\n\nAlso, I need a Signed-off-by line.\n\n-- \nShawn.\n"},{"id":"129420","messageId":"20091207125435.GA43609@book.hvoigt.net","threadId":"21317","inReplyTo":"20091205213613.GG5610@spearce.org","subject":"Re: Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2009-12-07T12:54:35Z","receivedAt":"2009-12-07T12:54:35Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"On Sat, Dec 05, 2009 at 01:36:13PM -0800, Shawn O. Pearce wrote:\n> Jeff Epler <jepler@unpythonic.net> wrote:\n> > I've found another problem, which I'll work on as soon as I find a\n> > chance.\n> > \n> > When staging multiple \"+\" lines preceded by a \"-\" line that must be\n> > turned into context, the converted \"-\" line must come after *all* the\n> > \"+\" lines, not just the first one.\n> \n> So the reason this series got stuck was this message, this bug is\n> enough to suggest we shouldn't apply it to my tree yet, so I've\n> been waiting for an update on the topic.\n\nIn an attempt to help this series forward I tried to reproduce this bug\nbut were unsuccessfull. It seems that a change like this:\n\n@@ -13,7 +13,9 @@ set appvers {@@GITGUI_VERSION@@}\n set copyright [encoding convertfrom utf-8 {\n Copyright © 2006, 2007 Shawn Pearce, et. al.\n \n-This program is free software; you can redistribute it and/or modify\n+Blabla\n+blubblub\n+lalala\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\nand then trying to stage part of the '+' lines is not enough. Jeff could you\nclarify or provide an example?\n\ncheers Heiko\n"},{"id":"129458","messageId":"20091208003836.GB22330@unpythonic.net","threadId":"21317","inReplyTo":"20091207125435.GA43609@book.hvoigt.net","subject":"Re: Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Jeff Epler","fromEmail":"jepler@unpythonic.net","sentAt":"2009-12-08T00:38:36Z","receivedAt":"2009-12-08T00:38:36Z","isPatch":true,"sender":{"key":"jepler@unpythonic.net","avatar":"https://avatars.githubusercontent.com/u/1517291?v=4"},"body":"On Mon, Dec 07, 2009 at 01:54:35PM +0100, Heiko Voigt wrote:\n> Jeff could you clarify or provide an example?\n\nIf I recall correctly, the problem with the v2 patch was when the change\nwas like\n    @@ -13,8 +13,8 @@ set appvers {@@GITGUI_VERSION@@}\n     set copyright [encoding convertfrom utf-8 {\n     Copyright © 2006, 2007 Shawn Pearce, et. al.\n\n    -This program is free software; you can redistribute it and/or modify\n    -it under the terms of the GNU General Public License as published by\n    +blah blah\n    +blah blah\n     the Free Software Foundation; either version 2 of the License, or\n     (at your option) any later version.\nand the 'blah blah' lines were both staged in the same operation.\n\nWhen doing this, the staged change is actually\n    +blah blah\n     This program is free software; you can redistribute it and/or modify\n     it under the terms of the GNU General Public License as published by\n    +blah blah\n\nbut the change that should have been staged is:\n    +blah blah\n    +blah blah\n     This program is free software; you can redistribute it and/or modify\n     it under the terms of the GNU General Public License as published by\n\nSince it requires staging multiple \"+\" lines in one go, this problem\ndoesn't exist in git-gui before my changes.\n\nThe v3 patch I posted just a few minutes ago fixes this problem.\n\nJeff\n"},{"id":"129763","messageId":"20091211185706.GA52891@book.hvoigt.net","threadId":"21317","inReplyTo":"20091208003836.GB22330@unpythonic.net","subject":"Re: Re: Re: [RFC PATCH v2 0/2] git-gui: (un)stage a range of changes at once","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2009-12-11T18:57:06Z","receivedAt":"2009-12-11T18:57:06Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"On Mon, Dec 07, 2009 at 06:38:36PM -0600, Jeff Epler wrote:\n> On Mon, Dec 07, 2009 at 01:54:35PM +0100, Heiko Voigt wrote:\n> > Jeff could you clarify or provide an example?\n> \n> If I recall correctly, the problem with the v2 patch was when the change\n> was like\n>     @@ -13,8 +13,8 @@ set appvers {@@GITGUI_VERSION@@}\n>      set copyright [encoding convertfrom utf-8 {\n>      Copyright © 2006, 2007 Shawn Pearce, et. al.\n> \n>     -This program is free software; you can redistribute it and/or modify\n>     -it under the terms of the GNU General Public License as published by\n>     +blah blah\n>     +blah blah\n>      the Free Software Foundation; either version 2 of the License, or\n>      (at your option) any later version.\n> and the 'blah blah' lines were both staged in the same operation.\n\nThanks Jeff that was the missing piece. I was able to reproduce the\nbehavior and I can confirm it is gone with the new series. I was not yet\nable to read through all of the code.\n\ncheers Heiko\n"}]}