From c3c62482bcfc51667335e6c46cdc2eee110ac027 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 22 May 2006 09:17:49 +1000 Subject: [PATCH] Fix off-by-one-error when extracting a merge file. If a merge ended at EOF, --extract wouldn't interpret it properly. --- extract.c | 8 ++++---- p | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extract.c b/extract.c index 0959b44..755a725 100644 --- a/extract.c +++ b/extract.c @@ -207,7 +207,7 @@ int split_merge(struct stream f, struct stream *f1, struct stream *f2, struct st lineno++; switch(state) { case 0: - if (len>8 && + if (len>=8 && strncmp(cp, "<<<<<<<", 7)==0 && (cp[7] == ' ' || cp[7] == '\n') ) { @@ -222,7 +222,7 @@ int split_merge(struct stream f, struct stream *f1, struct stream *f2, struct st } break; case 1: - if (len>8 && + if (len>=8 && strncmp(cp, "|||||||", 7)==0 && (cp[7] == ' ' || cp[7] == '\n') ) { @@ -232,7 +232,7 @@ int split_merge(struct stream f, struct stream *f1, struct stream *f2, struct st copyline(&r1, &cp, end); break; case 2: - if (len>8 && + if (len>=8 && strncmp(cp, "=======", 7)==0 && (cp[7] == ' ' || cp[7] == '\n') ) { @@ -242,7 +242,7 @@ int split_merge(struct stream f, struct stream *f1, struct stream *f2, struct st copyline(&r2, &cp, end); break; case 3: - if (len>8 && + if (len>=8 && strncmp(cp, ">>>>>>>", 7)==0 && (cp[7] == ' ' || cp[7] == '\n') ) { diff --git a/p b/p index 2500b66..48ee550 100755 --- a/p +++ b/p @@ -170,7 +170,7 @@ commit_one() { rm -f "$1~current~" mv "$1" "$1~current~" - cp "$1~current~" $1 + cp -p "$1~current~" $1 chmod u+w $1 }