74 lines
2.2 KiB
Diff
74 lines
2.2 KiB
Diff
From: Andreas Gruenbacher <agruen@suse.de>
|
|
Subject: diff3-style merges: include filenames
|
|
|
|
Include the filenames from the patch header in the diff3-style format.
|
|
Use the name of the output file as the third filename.
|
|
|
|
<<<<<<< old-filename
|
|
old lines from patch
|
|
||||||| new-filename
|
|
new lines from patch
|
|
=======
|
|
merge result
|
|
>>>>>>> output-filename
|
|
|
|
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
|
|
|
|
---
|
|
patch.c | 21 ++++++++++++++++++---
|
|
1 file changed, 18 insertions(+), 3 deletions(-)
|
|
|
|
Index: b/patch.c
|
|
===================================================================
|
|
--- a/patch.c
|
|
+++ b/patch.c
|
|
@@ -1353,6 +1353,7 @@ static bool merge_hunk (struct outstate
|
|
register LINENUM merge, merge_end;
|
|
register FILE *fp = outstate->ofp;
|
|
bool succeeded = true;
|
|
+ const char *name;
|
|
|
|
while (pch_char(new) == '=' || pch_char(new) == '\n' /* ??? */)
|
|
new++;
|
|
@@ -1410,7 +1411,11 @@ static bool merge_hunk (struct outstate
|
|
}
|
|
|
|
/* "From" lines in the patch */
|
|
- fprintf(fp, outstate->after_newline + "\n<<<<<<<\n");
|
|
+ name = pch_name(OLD);
|
|
+ if (!name)
|
|
+ name = "";
|
|
+ fprintf(fp, outstate->after_newline + "\n<<<<<<<%*s\n",
|
|
+ strlen(name) ? strlen(name) + 1 : 0, name);
|
|
if (ferror (fp))
|
|
write_fatal ();
|
|
outstate->after_newline = true;
|
|
@@ -1421,7 +1426,11 @@ static bool merge_hunk (struct outstate
|
|
|
|
if (fuzz) {
|
|
/* "To" lines in the patch */
|
|
- fprintf(fp, outstate->after_newline + "\n|||||||\n");
|
|
+ name = pch_name(NEW);
|
|
+ if (!name)
|
|
+ name = "";
|
|
+ fprintf(fp, outstate->after_newline + "\n|||||||%*s\n",
|
|
+ strlen(name) ? strlen(name) + 1 : 0, name);
|
|
if (ferror (fp))
|
|
write_fatal ();
|
|
outstate->after_newline = true;
|
|
@@ -1442,7 +1451,13 @@ static bool merge_hunk (struct outstate
|
|
copy_till(outstate, merge_end);
|
|
}
|
|
|
|
- fprintf(fp, outstate->after_newline + "\n>>>>>>>\n");
|
|
+ /* If the merge result and the new file are the same, label the merge
|
|
+ result with the new file's name. */
|
|
+ name = fuzz ? NULL : pch_name(NEW);
|
|
+ if (!name)
|
|
+ name = "";
|
|
+ fprintf(fp, outstate->after_newline + "\n>>>>>>>%*s\n",
|
|
+ strlen(name) ? strlen(name) + 1 : 0, name);
|
|
if (ferror (fp))
|
|
write_fatal ();
|
|
outstate->after_newline = true;
|