Hi Eli, I like to have a path without any prefix in the diff header, too, but also like to see the diff mnemonic prefix (see diff.mnemonicprefix config). For some diffs there is such path, which is in the extended header of the diff for copies and renames. So I wrote the appended patch wich adds also an extended header for non-copies and non-renames which shows the path without any prefix. Regards, Bert --- 8< --- From: Bert Wesarg <bert.wesarg@xxxxxxxxxxxxxx> Subject: [PATCH] diff: add a 'path' meta header for non-renames and non-copies This way you have always a path without any diff mnemonic prefix. Signed-off-by: Bert Wesarg <bert.wesarg@xxxxxxxxxxxxxx> --- Documentation/config.txt | 4 ++++ Documentation/diff-generate-patch.txt | 4 ++++ diff.c | 12 ++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 92f851e..652365e 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -807,6 +807,10 @@ diff.mnemonicprefix:: `git diff --no-index a b`;; compares two non-git things (1) and (2). +diff.path:: + Always add a 'path <path>' extended header into the diff output, + for non-copies and non-renames. + diff.renameLimit:: The number of files to consider when performing the copy/rename detection; equivalent to the 'git diff' option '-l'. diff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-generate-patch.txt index 8f9a241..67ba78f 100644 --- a/Documentation/diff-generate-patch.txt +++ b/Documentation/diff-generate-patch.txt @@ -30,6 +30,7 @@ the file that rename/copy produces, respectively. new mode <mode> deleted file mode <mode> new file mode <mode> + path <path> copy from <path> copy to <path> rename from <path> @@ -38,6 +39,9 @@ the file that rename/copy produces, respectively. dissimilarity index <number> index <hash>..<hash> <mode> + The 'path' header will only show up, if the diff.path configure option + is set. + 3. TAB, LF, double quote and backslash characters in pathnames are represented as `\t`, `\n`, `\"` and `\\`, respectively. If there is need for such substitution then the whole diff --git a/diff.c b/diff.c index d0ecbc3..fa33b9c 100644 --- a/diff.c +++ b/diff.c @@ -30,6 +30,7 @@ static const char *diff_word_regex_cfg; static const char *external_diff_cmd_cfg; int diff_auto_refresh_index = 1; static int diff_mnemonic_prefix; +static int diff_path; static char diff_colors[][COLOR_MAXLEN] = { GIT_COLOR_RESET, @@ -104,6 +105,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb) return git_config_string(&external_diff_cmd_cfg, var, value); if (!strcmp(var, "diff.wordregex")) return git_config_string(&diff_word_regex_cfg, var, value); + if (!strcmp(var, "diff.path")) { + diff_path = git_config_bool(var, value); + return 0; + } return git_diff_basic_config(var, value, cb); } @@ -2351,8 +2356,11 @@ static void fill_metainfo(struct strbuf *msg, } /* fallthru */ default: - /* nothing */ - ; + if (diff_path) { + strbuf_addstr(msg, "path "); + quote_c_style(name, msg, NULL, 0); + strbuf_addch(msg, '\n'); + } } if (one && two && hashcmp(one->sha1, two->sha1)) { int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV; -- tg: (ddd02b7..) bw/always-print-a-path-meta-header (depends on: master) -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html