This also adds "rename from <oldpath>" and "copy from <oldpath>"
extended headers when renames or copies are involved.

Signed-off-by: Elijah Newren <new...@gmail.com>
---
 Documentation/diff-generate-patch.txt |  7 +++----
 combine-diff.c                        | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Documentation/diff-generate-patch.txt 
b/Documentation/diff-generate-patch.txt
index f10ca410ad..f0c2a17aef 100644
--- a/Documentation/diff-generate-patch.txt
+++ b/Documentation/diff-generate-patch.txt
@@ -128,12 +128,11 @@ or like this (when `--cc` option is used):
        mode <mode>,<mode>..<mode>
        new file mode <mode>
        deleted file mode <mode>,<mode>
+       copy from <path>
+       rename from <path>
 +
 The `mode <mode>,<mode>..<mode>` line appears only if at least one of
-the <mode> is different from the rest. Extended headers with
-information about detected contents movement (renames and
-copying detection) are designed to work with diff of two
-<tree-ish> and are not used by combined diff format.
+the <mode> is different from the rest.
 
 3.   It is followed by two-line from-file/to-file header
 
diff --git a/combine-diff.c b/combine-diff.c
index 54cb892ae5..04a139ea03 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -981,6 +981,21 @@ static void show_combined_header(struct combine_diff_path 
*elem,
                printf("%s\n", c_reset);
        }
 
+       for (i = 0; i < num_parent; i++) {
+               switch (elem->parent[i].status) {
+               case DIFF_STATUS_COPIED:
+                       dump_quoted_path("copy from ", "",
+                                        elem->parent[i].path.buf,
+                                        line_prefix, c_meta, c_reset);
+                       break;
+               case DIFF_STATUS_RENAMED:
+                       dump_quoted_path("rename from ", "",
+                                        elem->parent[i].path.buf,
+                                        line_prefix, c_meta, c_reset);
+                       break;
+               }
+       }
+
        if (!show_file_header)
                return;
 
-- 
2.20.1.311.gb8408a6075

Reply via email to