Skip to content

Commit

Permalink
Fix off-by-one-error when extracting a merge file.
Browse files Browse the repository at this point in the history
If a merge ended at EOF, --extract wouldn't interpret it properly.
  • Loading branch information
neilbrown committed May 21, 2006
1 parent 991a0ca commit c3c6248
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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')
) {
Expand All @@ -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')
) {
Expand All @@ -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')
) {
Expand All @@ -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')
) {
Expand Down
2 changes: 1 addition & 1 deletion p
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit c3c6248

Please sign in to comment.