{"thread":{"id":"23677","subject":"[PATCH] diff: add configuration option for disabling diff prefixes.","startedAt":"2010-05-03T02:03:41Z","lastAt":"2010-05-05T21:14:42Z","messageCount":9,"participants":["Eli Collins","Bert Wesarg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"140806","messageId":"1272852221-14927-1-git-send-email-eli@cloudera.com","threadId":"23677","inReplyTo":null,"subject":"[PATCH] diff: add configuration option for disabling diff prefixes.","fromName":"Eli Collins","fromEmail":"eli@cloudera.com","sentAt":"2010-05-03T02:03:41Z","receivedAt":"2010-05-03T02:03:41Z","isPatch":true,"sender":{"key":"eli@cloudera.com","avatar":"https://avatars.githubusercontent.com/u/131502?v=4"},"body":"From: Eli Collins <eli@cloudera.com>\n\nWith new configuration \"diff.noprefix\", \"git diff\" does not show a source or destination prefix ala \"git diff --no-prefix\".\n\nSigned-off-by: Eli Collins <eli@cloudera.com>\n---\n Documentation/config.txt |    2 ++\n diff.c                   |    9 ++++++++-\n 2 files changed, 10 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 92f851e..e883952 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -796,6 +796,8 @@ diff.mnemonicprefix::\n \tstandard \"a/\" and \"b/\" depending on what is being compared.  When\n \tthis configuration is in effect, reverse diff output also swaps\n \tthe order of the prefixes:\n+diff.noprefix::\n+\tIf set, 'git diff' does not show any source or destination prefix.\n `git diff`;;\n \tcompares the (i)ndex and the (w)ork tree;\n `git diff HEAD`;;\ndiff --git a/diff.c b/diff.c\nindex d0ecbc3..07269c2 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -30,6 +30,7 @@ static const char *diff_word_regex_cfg;\n static const char *external_diff_cmd_cfg;\n int diff_auto_refresh_index = 1;\n static int diff_mnemonic_prefix;\n+static int diff_no_prefix;\n \n static char diff_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_RESET,\n@@ -100,6 +101,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)\n \t\tdiff_mnemonic_prefix = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"diff.noprefix\")) {\n+\t\tdiff_no_prefix = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"diff.external\"))\n \t\treturn git_config_string(&external_diff_cmd_cfg, var, value);\n \tif (!strcmp(var, \"diff.wordregex\"))\n@@ -2559,7 +2564,9 @@ void diff_setup(struct diff_options *options)\n \t\tDIFF_OPT_SET(options, COLOR_DIFF);\n \toptions->detect_rename = diff_detect_rename_default;\n \n-\tif (!diff_mnemonic_prefix) {\n+\tif (diff_no_prefix) {\n+\t\toptions->a_prefix = options->b_prefix = \"\";\n+\t} else if (!diff_mnemonic_prefix) {\n \t\toptions->a_prefix = \"a/\";\n \t\toptions->b_prefix = \"b/\";\n \t}\n-- \n1.7.1.dirty\n"},{"id":"140809","messageId":"1272868072-12120-1-git-send-email-bert.wesarg@googlemail.com","threadId":"23677","inReplyTo":"1272852221-14927-1-git-send-email-eli@cloudera.com","subject":"[PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-05-03T06:27:52Z","receivedAt":"2010-05-03T06:27:52Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Hi Eli, \n\nI like to have a path without any prefix in the diff header, too, but also like\nto see the diff mnemonic prefix (see diff.mnemonicprefix config). For some\ndiffs there is such path, which is in the extended header of the diff for\ncopies and renames. So I wrote the appended patch wich adds also an extended\nheader for non-copies and non-renames which shows the path without any prefix.\n\n\nRegards,\nBert\n\n--- 8< ---\n\nFrom: Bert Wesarg <bert.wesarg@googlemail.com>\nSubject: [PATCH] diff: add a 'path' meta header for non-renames and non-copies\n\nThis way you have always a path without any diff mnemonic prefix.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n---\n Documentation/config.txt              |    4 ++++\n Documentation/diff-generate-patch.txt |    4 ++++\n diff.c                                |   12 ++++++++++--\n 3 files changed, 18 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 92f851e..652365e 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -807,6 +807,10 @@ diff.mnemonicprefix::\n `git diff --no-index a b`;;\n \tcompares two non-git things (1) and (2).\n \n+diff.path::\n+\tAlways add a 'path <path>' extended header into the diff output,\n+\tfor non-copies and non-renames.\n+\n diff.renameLimit::\n \tThe number of files to consider when performing the copy/rename\n \tdetection; equivalent to the 'git diff' option '-l'.\ndiff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-generate-patch.txt\nindex 8f9a241..67ba78f 100644\n--- a/Documentation/diff-generate-patch.txt\n+++ b/Documentation/diff-generate-patch.txt\n@@ -30,6 +30,7 @@ the file that rename/copy produces, respectively.\n        new mode <mode>\n        deleted file mode <mode>\n        new file mode <mode>\n+       path <path>\n        copy from <path>\n        copy to <path>\n        rename from <path>\n@@ -38,6 +39,9 @@ the file that rename/copy produces, respectively.\n        dissimilarity index <number>\n        index <hash>..<hash> <mode>\n \n+    The 'path' header will only show up, if the diff.path configure option\n+    is set.\n+\n 3.  TAB, LF, double quote and backslash characters in pathnames\n     are represented as `\\t`, `\\n`, `\\\"` and `\\\\`, respectively.\n     If there is need for such substitution then the whole\ndiff --git a/diff.c b/diff.c\nindex d0ecbc3..fa33b9c 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -30,6 +30,7 @@ static const char *diff_word_regex_cfg;\n static const char *external_diff_cmd_cfg;\n int diff_auto_refresh_index = 1;\n static int diff_mnemonic_prefix;\n+static int diff_path;\n \n static char diff_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_RESET,\n@@ -104,6 +105,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)\n \t\treturn git_config_string(&external_diff_cmd_cfg, var, value);\n \tif (!strcmp(var, \"diff.wordregex\"))\n \t\treturn git_config_string(&diff_word_regex_cfg, var, value);\n+\tif (!strcmp(var, \"diff.path\")) {\n+\t\tdiff_path = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \n \treturn git_diff_basic_config(var, value, cb);\n }\n@@ -2351,8 +2356,11 @@ static void fill_metainfo(struct strbuf *msg,\n \t\t}\n \t\t/* fallthru */\n \tdefault:\n-\t\t/* nothing */\n-\t\t;\n+\t\tif (diff_path) {\n+\t\t\tstrbuf_addstr(msg, \"path \");\n+\t\t\tquote_c_style(name, msg, NULL, 0);\n+\t\t\tstrbuf_addch(msg, '\\n');\n+\t\t}\n \t}\n \tif (one && two && hashcmp(one->sha1, two->sha1)) {\n \t\tint abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n-- \ntg: (ddd02b7..) bw/always-print-a-path-meta-header (depends on: master)\n"},{"id":"140813","messageId":"7viq75tpaw.fsf@alter.siamese.dyndns.org","threadId":"23677","inReplyTo":"1272868072-12120-1-git-send-email-bert.wesarg@googlemail.com","subject":"Re: [PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-05-03T07:30:47Z","receivedAt":"2010-05-03T07:30:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sorry, but none of these configuration variables are acceptable as-is.\n\nMany scripts (the ones shipped with core-git, in contrib, or written by\nusers) depend on their invocation of \"git diff-*\" family without any funny\ncommand line arguments like --no-prefix nor --src-prefix to produce a\npatch that can be applied without giving a custom -p value to \"git apply\".\n\nLetting the user break that promise is already bad, and not giving the\nscripts any way to protect themselves from these configuration variables\nby overriding from the command line makes these doubly bad ideas.\n"},{"id":"140814","messageId":"z2m36ca99e91005030037jb880e65w73efa551a53d7be6@mail.gmail.com","threadId":"23677","inReplyTo":"7viq75tpaw.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-05-03T07:37:51Z","receivedAt":"2010-05-03T07:37:51Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Mon, May 3, 2010 at 09:30, Junio C Hamano <gitster@pobox.com> wrote:\n> Sorry, but none of these configuration variables are acceptable as-is.\n>\n> Many scripts (the ones shipped with core-git, in contrib, or written by\n> users) depend on their invocation of \"git diff-*\" family without any funny\n> command line arguments like --no-prefix nor --src-prefix to produce a\n> patch that can be applied without giving a custom -p value to \"git apply\".\n>\n> Letting the user break that promise is already bad, and not giving the\n> scripts any way to protect themselves from these configuration variables\n> by overriding from the command line makes these doubly bad ideas.\n\nAs far as I understand git_diff_ui_config() applies only for \"git\ndiff\" not for any of the plumping \"git diff-*\" tools. Also I thought\nthat these extended headers are exactly there to support arbitrary\nmeta information. Therefore I think your arguments don't hold for my\n'path' extended header, do they?\n\nThanks,\nBert\n\n>\n"},{"id":"140835","messageId":"7v1vdtt0d7.fsf@alter.siamese.dyndns.org","threadId":"23677","inReplyTo":"z2m36ca99e91005030037jb880e65w73efa551a53d7be6@mail.gmail.com","subject":"Re: [PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-05-03T16:29:24Z","receivedAt":"2010-05-03T16:29:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> As far as I understand git_diff_ui_config() applies only for \"git\n> diff\" not for any of the plumping \"git diff-*\" tools.\n\nAh, I missed that the patch was to the diff_ui parser.  Sorry for\nconfusion and thanks for straightening me up.\n"},{"id":"140860","messageId":"m2i36ca99e91005031555x4bb2df54yb47058d9f7d5342c@mail.gmail.com","threadId":"23677","inReplyTo":"7v1vdtt0d7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-05-03T22:55:46Z","receivedAt":"2010-05-03T22:55:46Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Mon, May 3, 2010 at 18:29, Junio C Hamano <gitster@pobox.com> wrote:\n> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>\n>> As far as I understand git_diff_ui_config() applies only for \"git\n>> diff\" not for any of the plumping \"git diff-*\" tools.\n>\n> Ah, I missed that the patch was to the diff_ui parser.  Sorry for\n> confusion and thanks for straightening me up.\n>\n\nSo, now that I render your arguments voidless, do you have any other\nthoughts on adding a <path> extended header for non-renames and\nnon-copies?\n\nRegards,\nBert\n"},{"id":"140870","messageId":"7v8w80sb5b.fsf@alter.siamese.dyndns.org","threadId":"23677","inReplyTo":"m2i36ca99e91005031555x4bb2df54yb47058d9f7d5342c@mail.gmail.com","subject":"Re: [PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-05-04T01:34:08Z","receivedAt":"2010-05-04T01:34:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> ... do you have any other\n> thoughts on adding a <path> extended header for non-renames and\n> non-copies?\n\nOther than \"Why do we even need it?\", no.  We actually have been careful\nwhen designing the output format to make sure that necessary information\nappears.\n\nSee also this thread:\n\n    http://thread.gmane.org/gmane.comp.version-control.git/3990/focus=4002\n\nI wasn't too opposed to having a separate \"Index: \" line (or Anton's\n\"name\") like CVS does, but the conclusion of the thread was that it is not\nnecessary.\n"},{"id":"140929","messageId":"AANLkTilsk7Hh0oN72SfOlRK92qQhjVa-rNYUtVHocEj0@mail.gmail.com","threadId":"23677","inReplyTo":"7v8w80sb5b.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-05-04T19:30:53Z","receivedAt":"2010-05-04T19:30:53Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Tue, May 4, 2010 at 03:34, Junio C Hamano <gitster@pobox.com> wrote:\n> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>\n>> ... do you have any other\n>> thoughts on adding a <path> extended header for non-renames and\n>> non-copies?\n>\n> Other than \"Why do we even need it?\", no.  We actually have been careful\n> when designing the output format to make sure that necessary information\n> appears.\n>\n> See also this thread:\n>\n>    http://thread.gmane.org/gmane.comp.version-control.git/3990/focus=4002\n>\n> I wasn't too opposed to having a separate \"Index: \" line (or Anton's\n> \"name\") like CVS does, but the conclusion of the thread was that it is not\n> necessary.\n>\n\nThanks for the pointer. The discussion revolves around technical\narguments and the conclusion that this extra information is not\nnecessary is reasonable. My intention for this information comes only\nfrom the usability and convenience side: I want a path without any\nprefix which I can select in the terminal and use this to open the\nfile. Thats why it is only an option for the UI interface.\n\nBert\n"},{"id":"141010","messageId":"w2ndfe484f01005051414p294820f8jbf974b0cde20236d@mail.gmail.com","threadId":"23677","inReplyTo":"AANLkTilsk7Hh0oN72SfOlRK92qQhjVa-rNYUtVHocEj0@mail.gmail.com","subject":"Re: [PATCH] diff: add a 'path' meta header for non-renames and non-copies","fromName":"Eli Collins","fromEmail":"eli@cloudera.com","sentAt":"2010-05-05T21:14:42Z","receivedAt":"2010-05-05T21:14:42Z","isPatch":true,"sender":{"key":"eli@cloudera.com","avatar":"https://avatars.githubusercontent.com/u/131502?v=4"},"body":"Ditto.  I frequently generate patches for other systems (primarily\nsvn) and they require diffs w/o perfixes.  Seemed like there should be\na way to enable this option in gitconfig so users don't need to type\n--no-prefix w every diff invocation or use an alias (aliasing diff to\ndiff --no-prefix in gitconfig doesn't work and wouldn't be a good idea\nanyway).\n\nThanks,\nEli\n\n\nOn Tue, May 4, 2010 at 12:30 PM, Bert Wesarg <bert.wesarg@googlemail.com> wrote:\n> On Tue, May 4, 2010 at 03:34, Junio C Hamano <gitster@pobox.com> wrote:\n>> Bert Wesarg <bert.wesarg@googlemail.com> writes:\n>>\n>>> ... do you have any other\n>>> thoughts on adding a <path> extended header for non-renames and\n>>> non-copies?\n>>\n>> Other than \"Why do we even need it?\", no.  We actually have been careful\n>> when designing the output format to make sure that necessary information\n>> appears.\n>>\n>> See also this thread:\n>>\n>>    http://thread.gmane.org/gmane.comp.version-control.git/3990/focus=4002\n>>\n>> I wasn't too opposed to having a separate \"Index: \" line (or Anton's\n>> \"name\") like CVS does, but the conclusion of the thread was that it is not\n>> necessary.\n>>\n>\n> Thanks for the pointer. The discussion revolves around technical\n> arguments and the conclusion that this extra information is not\n> necessary is reasonable. My intention for this information comes only\n> from the usability and convenience side: I want a path without any\n> prefix which I can select in the terminal and use this to open the\n> file. Thats why it is only an option for the UI interface.\n>\n> Bert\n>\n"}]}