summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-07-22 21:48:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-07-22 22:38:22 (GMT)
commitb810cbbde9232cbe9a3841edccc5b606bbd3a82e (patch)
treec79f6c67be6dad7a57996008ec94c668e0f68a54 /combine-diff.c
parent55d5d5bab7c3f9ab6310b9cf436a7935d7d32165 (diff)
downloadgit-b810cbbde9232cbe9a3841edccc5b606bbd3a82e.zip
git-b810cbbde9232cbe9a3841edccc5b606bbd3a82e.tar.gz
git-b810cbbde9232cbe9a3841edccc5b606bbd3a82e.tar.bz2
diff --cc: a lost line at the beginning of the file is shown incorrectly
When combine-diff inspected the diff from one parent to the merge result, it misinterpreted a header in the form @@ -l,k +0,0 @@. This hunk header means that K lines were removed from the beginning of the file, so the lost lines must be queued to the sline that represents the first line of the merge result, but we incremented our pointer incorrectly and ended up queuing it to the second line, which in turn made the lossage appear _after_ the first line. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/combine-diff.c b/combine-diff.c
index b82f46c..1a6f9d1 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -164,20 +164,22 @@ static void consume_line(void *state_, char *line, unsigned long len)
&state->nb, &state->nn))
return;
state->lno = state->nb;
- if (!state->nb)
- /* @@ -1,2 +0,0 @@ to remove the
- * first two lines...
- */
- state->nb = 1;
- if (state->nn == 0)
+ if (state->nn == 0) {
/* @@ -X,Y +N,0 @@ removed Y lines
* that would have come *after* line N
* in the result. Our lost buckets hang
* to the line after the removed lines,
+ *
+ * Note that this is correct even when N == 0,
+ * in which case the hunk removes the first
+ * line in the file.
*/
state->lost_bucket = &state->sline[state->nb];
- else
+ if (!state->nb)
+ state->nb = 1;
+ } else {
state->lost_bucket = &state->sline[state->nb-1];
+ }
if (!state->sline[state->nb-1].p_lno)
state->sline[state->nb-1].p_lno =
xcalloc(state->num_parent,