summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Johannes Sixt <johannes.sixt@telecom.at>2008-07-15 23:11:00 +0200
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2008-07-26 16:43:08 -0700
commitfa6b5b3944b74f2ad2430f3dfec517f8f70a6663 (patch)
tree0312dc18b9c15e9e3d00cd9f27d306d0ad822c26
parentgit-gui: Correct 'Visualize Branches' on Mac OS X to start gitk (diff)
downloadtgif-fa6b5b3944b74f2ad2430f3dfec517f8f70a6663.tar.xz
git-gui: Fix "Stage/Unstage Line" with one line of context.
To "Stage/Unstage Line" we construct a patch that contains exactly one change (either addition or removal); the hunk header was forged by counting the old side and adjusting the count by +/-1 for the new side. But when we counted the context we never counted the changed line itself. If the hunk had only one removal line and one line of context, like this: @@ -1,3 +1,2 @@ context 1 -removal context 2 We had constructed this patch: @@ -1,2 +1,1 @@ context 1 -removal context 2 which does not apply because git apply deduces that it must apply at the end of the file. ("context 2" is considered garbage and ignored.) The fix is that removal lines must be counted towards the context of the old side. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--lib/diff.tcl3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/diff.tcl b/lib/diff.tcl
index 96ba94906c..ee7f391e2f 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -423,6 +423,9 @@ proc apply_line {x y} {
# the line to stage/unstage
set ln [$ui_diff get $i_l $next_l]
set patch "$patch$ln"
+ if {$c1 eq {-}} {
+ set n [expr $n+1]
+ }
} elseif {$c1 ne {-} && $c1 ne {+}} {
# context line
set ln [$ui_diff get $i_l $next_l]