summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7838d3f)
raw | patch | inline | side by side (parent: 7838d3f)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Tue, 15 Jul 2008 21:11:00 +0000 (23:11 +0200) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Sat, 26 Jul 2008 23:43:08 +0000 (16:43 -0700) |
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>
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>
lib/diff.tcl | patch | blob | history |
diff --git a/lib/diff.tcl b/lib/diff.tcl
index 96ba94906cf8037b58c2ba135654da840f9fff9a..ee7f391e2f24c418c14cacc63768da7b258e3754 100644 (file)
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
# 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]