{"thread":{"id":"4794","subject":"[PATCH] Teach --text option to diff","startedAt":"2006-07-07T10:33:57Z","lastAt":"2006-07-07T13:57:09Z","messageCount":6,"participants":["Stephan Feder","Junio C Hamano","sf"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"23351","messageId":"11522684373987-git-send-email-sf@b-i-t.de","threadId":"4794","inReplyTo":null,"subject":"[PATCH] Teach --text option to diff","fromName":"Stephan Feder","fromEmail":"sf@b-i-t.de","sentAt":"2006-07-07T10:33:57Z","receivedAt":"2006-07-07T10:33:57Z","isPatch":true,"sender":{"key":"sf@b-i-t.de","avatar":null},"body":"Add new item text to struct diff_options.\nIf set then do not try to detect binary files.\n\nSigned-off-by: Stephan Feder <sf@b-i-t.de>\n---\n\nI have to send patches of binary data to a customer but the builtin diff\nwas no help in this case.\n\nNotes:\n\n1. The shorthand -a for --text is not implemented. Is there a conflicting\nshorthand?\n\n2. For diffstat --text is ignored. It seems pointless because binary\npatch data is not for human consumption anyway.\n\n3. No documentation yet. If the patch is accepted I will add a short\ndescription. To Documentation/diff-options.txt?\n\nRegards\n    Stephan\n\n\n diff.c |    5 ++++-\n diff.h |    1 +\n 2 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex f0450a8..1f0219d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -723,7 +723,7 @@ static void builtin_diff(const char *nam\n \tif (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)\n \t\tdie(\"unable to read files to diff\");\n \n-\tif (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2)) {\n+\tif (!o->text && (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2))) {\n \t\t/* Quite common confusing case */\n \t\tif (mf1.size == mf2.size &&\n \t\t    !memcmp(mf1.ptr, mf2.ptr, mf1.size))\n@@ -1561,6 +1561,9 @@ int diff_opt_parse(struct diff_options *\n \t\toptions->output_format |= DIFF_FORMAT_PATCH;\n \t\toptions->full_index = options->binary = 1;\n \t}\n+\telse if (!strcmp(arg, \"--text\")) {\n+\t\toptions->text = 1;\n+\t}\n \telse if (!strcmp(arg, \"--name-only\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME;\n \telse if (!strcmp(arg, \"--name-status\"))\ndiff --git a/diff.h b/diff.h\nindex d557394..f80f646 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -42,6 +42,7 @@ struct diff_options {\n \tunsigned recursive:1,\n \t\t tree_in_recursive:1,\n \t\t binary:1,\n+\t\t text:1,\n \t\t full_index:1,\n \t\t silent_on_remove:1,\n \t\t find_copies_harder:1,\n-- \n1.4.1.gbc483\n"},{"id":"23355","messageId":"7v64i91xow.fsf@assigned-by-dhcp.cox.net","threadId":"4794","inReplyTo":"11522684373987-git-send-email-sf@b-i-t.de","subject":"Re: [PATCH] Teach --text option to diff","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-07T11:06:23Z","receivedAt":"2006-07-07T11:06:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephan Feder <sf@b-i-t.de> writes:\n\n> I have to send patches of binary data to a customer but the builtin diff\n> was no help in this case.\n\nGiven the previous patch, and also your point #2 below, I would\nhave expected you to introduce an option to force files to be\ntreated as binary even when they are otherwise misidentified as\ntext, but this patch is going the other way.\n\nInteresting.\n\n> 1. The shorthand -a for --text is not implemented. Is there a conflicting\n> shorthand?\n\nI do not think of one offhand, but it's the responsibility for\nthe party to propose such an enhancement to do the study ;-)\n\n> 2. For diffstat --text is ignored. It seems pointless because binary\n> patch data is not for human consumption anyway.\n\n> 3. No documentation yet. If the patch is accepted I will add a short\n> description. To Documentation/diff-options.txt?\n\nMost likely that would be the place.\n"},{"id":"23363","messageId":"44AE4B35.6060607@b-i-t.de","threadId":"4794","inReplyTo":"7v64i91xow.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Teach --text option to diff","fromName":"sf","fromEmail":"sf@b-i-t.de","sentAt":"2006-07-07T11:53:25Z","receivedAt":"2006-07-07T11:53:25Z","isPatch":true,"sender":{"key":"sf@b-i-t.de","avatar":null},"body":"Junio C Hamano wrote:\n> Stephan Feder <sf@b-i-t.de> writes:\n> \n>> I have to send patches of binary data to a customer but the builtin diff\n>> was no help in this case.\n> \n> Given the previous patch, and also your point #2 below, I would\n> have expected you to introduce an option to force files to be\n> treated as binary even when they are otherwise misidentified as\n> text, but this patch is going the other way.\n> \n> Interesting.\n\nNot really. I was surprised that the GNU diff option --text is\nunsupported in the builtin diff.\n\n> \n>> 1. The shorthand -a for --text is not implemented. Is there a conflicting\n>> shorthand?\n> \n> I do not think of one offhand, but it's the responsibility for\n> the party to propose such an enhancement to do the study ;-)\n\nOf course. I did not find any conflict but as the builtin diff and its\noptions are used by quite a lot of git commands I wanted to make sure.\n\nIf no objections arise I am going to add the shorthand.\n\n>> 2. For diffstat --text is ignored. It seems pointless because binary\n>> patch data is not for human consumption anyway.\n> \n>> 3. No documentation yet. If the patch is accepted I will add a short\n>> description. To Documentation/diff-options.txt?\n> \n> Most likely that would be the place.\n\nGood.\n"},{"id":"23369","messageId":"11522806291956-git-send-email-sf@b-i-t.de","threadId":"4794","inReplyTo":"44AE4B35.6060607@b-i-t.de","subject":"[PATCH 1/3] Teach diff -a as shorthand for --text","fromName":"Stephan Feder","fromEmail":"sf@b-i-t.de","sentAt":"2006-07-07T13:57:07Z","receivedAt":"2006-07-07T13:57:07Z","isPatch":true,"sender":{"key":"sf@b-i-t.de","avatar":null},"body":"Signed-off-by: Stephan Feder <sf@b-i-t.de>\n---\n diff.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 1f0219d..b423491 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1561,7 +1561,7 @@ int diff_opt_parse(struct diff_options *\n \t\toptions->output_format |= DIFF_FORMAT_PATCH;\n \t\toptions->full_index = options->binary = 1;\n \t}\n-\telse if (!strcmp(arg, \"--text\")) {\n+\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\")) {\n \t\toptions->text = 1;\n \t}\n \telse if (!strcmp(arg, \"--name-only\"))\n-- \n1.4.1.gbc483\n"},{"id":"23371","messageId":"11522806292871-git-send-email-sf@b-i-t.de","threadId":"4794","inReplyTo":"44AE4B35.6060607@b-i-t.de","subject":"[PATCH 2/3] Add -a and --text to common diff options help","fromName":"Stephan Feder","fromEmail":"sf@b-i-t.de","sentAt":"2006-07-07T13:57:08Z","receivedAt":"2006-07-07T13:57:08Z","isPatch":true,"sender":{"key":"sf@b-i-t.de","avatar":null},"body":"Signed-off-by: Stephan Feder <sf@b-i-t.de>\n---\n diff.h |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/diff.h b/diff.h\nindex f80f646..8ab0448 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -162,7 +162,8 @@ #define COMMON_DIFF_OPTIONS_HELP \\\n \"  -O<file>      reorder diffs according to the <file>.\\n\" \\\n \"  -S<string>    find filepair whose only one side contains the string.\\n\" \\\n \"  --pickaxe-all\\n\" \\\n-\"                show all files diff when -S is used and hit is found.\\n\"\n+\"                show all files diff when -S is used and hit is found.\\n\" \\\n+\"  -a  --text    treat all files as text.\\n\"\n \n extern int diff_queue_is_empty(void);\n extern void diff_flush(struct diff_options*);\n-- \n1.4.1.gbc483\n"},{"id":"23370","messageId":"11522806292890-git-send-email-sf@b-i-t.de","threadId":"4794","inReplyTo":"44AE4B35.6060607@b-i-t.de","subject":"[PATCH 3/3] diff-options: Explain --text and -a","fromName":"Stephan Feder","fromEmail":"sf@b-i-t.de","sentAt":"2006-07-07T13:57:09Z","receivedAt":"2006-07-07T13:57:09Z","isPatch":true,"sender":{"key":"sf@b-i-t.de","avatar":null},"body":"Signed-off-by: Stephan Feder <sf@b-i-t.de>\n---\n Documentation/diff-options.txt |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex f523ec2..1a93629 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -94,5 +94,11 @@\n \tSwap two inputs; that is, show differences from index or\n \ton-disk file to tree contents.\n \n+--text::\n+\tTreat all files as text.\n+\n+-a::\n+\tShorthand for \"--text\".\n+\n For more detailed explanation on these common options, see also\n link:diffcore.html[diffcore documentation].\n-- \n1.4.1.gbc483\n"}]}