{"thread":{"id":"6506","subject":"[PATCH] diff --check: use colour","startedAt":"2007-01-24T14:05:48Z","lastAt":"2007-02-18T16:27:24Z","messageCount":26,"participants":["Johannes Schindelin","Junio C Hamano","Bill Lear","Jeff King","Andreas Ericsson","Andy Parkins","J. Bruce Fields","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"32521","messageId":"Pine.LNX.4.63.0701241505260.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6506","inReplyTo":null,"subject":"[PATCH] diff --check: use colour","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-24T14:05:48Z","receivedAt":"2007-01-24T14:05:48Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nReuse the colour handling of the regular diff.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tIs it possible that diff_get_color() _never_ returns NULL?\n\tThen diff.c can be further cleaned up...\n\n diff.c |   58 ++++++++++++++++++++++++++++++++++++++++------------------\n 1 files changed, 40 insertions(+), 18 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex f11a633..1b31c4f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -405,22 +405,16 @@ static void emit_line(const char *set, const char *reset, const char *line, int\n \tputs(reset);\n }\n \n-static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)\n+static void emit_line_with_ws(int nparents,\n+\t\tconst char *set, const char *reset, const char *ws,\n+\t\tconst char *line, int len)\n {\n-\tint col0 = ecbdata->nparents;\n+\tint col0 = nparents;\n \tint last_tab_in_indent = -1;\n \tint last_space_in_indent = -1;\n \tint i;\n \tint tail = len;\n \tint need_highlight_leading_space = 0;\n-\tconst char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);\n-\tconst char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);\n-\n-\tif (!*ws) {\n-\t\temit_line(set, reset, line, len);\n-\t\treturn;\n-\t}\n-\n \t/* The line is a newly added line.  Does it have funny leading\n \t * whitespaces?  In indent, SP should never precede a TAB.\n \t */\n@@ -475,6 +469,18 @@ static void emit_add_line(const char *reset, struct emit_callback *ecbdata, cons\n \t\temit_line(set, reset, line + i, len - i);\n }\n \n+static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)\n+{\n+\tconst char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);\n+\tconst char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);\n+\n+\tif (!*ws)\n+\t\temit_line(set, reset, line, len);\n+\telse\n+\t\temit_line_with_ws(ecbdata->nparents, set, reset, reset,\n+\t\t\t\tline, len);\n+}\n+\n static void fn_out_consume(void *priv, char *line, unsigned long len)\n {\n \tint i;\n@@ -864,30 +870,45 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)\n struct checkdiff_t {\n \tstruct xdiff_emit_state xm;\n \tconst char *filename;\n-\tint lineno;\n+\tint lineno, color_diff;\n };\n \n static void checkdiff_consume(void *priv, char *line, unsigned long len)\n {\n \tstruct checkdiff_t *data = priv;\n+\tconst char *ws = diff_get_color(data->color_diff, DIFF_WHITESPACE);\n+\tconst char *reset = diff_get_color(data->color_diff, DIFF_RESET);\n+\tconst char *set = diff_get_color(data->color_diff, DIFF_FILE_NEW);\n \n \tif (line[0] == '+') {\n-\t\tint i, spaces = 0;\n+\t\tint i, spaces = 0, space_before_tab = 0, white_space_at_end = 0;\n+\t\tconst char *message = NULL;\n \n \t\t/* check space before tab */\n \t\tfor (i = 1; i < len && (line[i] == ' ' || line[i] == '\\t'); i++)\n \t\t\tif (line[i] == ' ')\n \t\t\t\tspaces++;\n \t\tif (line[i - 1] == '\\t' && spaces)\n-\t\t\tprintf(\"%s:%d: space before tab:%.*s\\n\",\n-\t\t\t\tdata->filename, data->lineno, (int)len, line);\n+\t\t\tspace_before_tab = 1;\n \n \t\t/* check white space at line end */\n \t\tif (line[len - 1] == '\\n')\n \t\t\tlen--;\n \t\tif (isspace(line[len - 1]))\n-\t\t\tprintf(\"%s:%d: white space at end: %.*s\\n\",\n-\t\t\t\tdata->filename, data->lineno, (int)len, line);\n+\t\t\twhite_space_at_end = 1;\n+\n+\t\tif (space_before_tab || white_space_at_end) {\n+\t\t\tprintf(\"%s:%d: %s\", data->filename, data->lineno, ws);\n+\t\t\tif (space_before_tab) {\n+\t\t\t\tprintf(\"space before tab\");\n+\t\t\t\tif (white_space_at_end)\n+\t\t\t\t\tputchar(',');\n+\t\t\t}\n+\t\t\tif (white_space_at_end)\n+\t\t\t\tprintf(\"white space at end\");\n+\t\t\tprintf(\":%s \", reset);\n+\t\t\temit_line_with_ws(2, set, reset, ws, line, len);\n+\t\t}\n \n \t\tdata->lineno++;\n \t} else if (line[0] == ' ')\n@@ -1145,7 +1166,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,\n \n static void builtin_checkdiff(const char *name_a, const char *name_b,\n \t\t\t     struct diff_filespec *one,\n-\t\t\t     struct diff_filespec *two)\n+\t\t\t     struct diff_filespec *two, struct diff_options *o)\n {\n \tmmfile_t mf1, mf2;\n \tstruct checkdiff_t data;\n@@ -1157,6 +1178,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdata.xm.consume = checkdiff_consume;\n \tdata.filename = name_b ? name_b : name_a;\n \tdata.lineno = 0;\n+\tdata.color_diff = o->color_diff;\n \n \tif (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)\n \t\tdie(\"unable to read files to diff\");\n@@ -1766,7 +1788,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)\n \tdiff_fill_sha1_info(p->one);\n \tdiff_fill_sha1_info(p->two);\n \n-\tbuiltin_checkdiff(name, other, p->one, p->two);\n+\tbuiltin_checkdiff(name, other, p->one, p->two, o);\n }\n \n void diff_setup(struct diff_options *options)\n-- \n1.5.0.rc2.g8b13f-dirty\n"},{"id":"32571","messageId":"7vr6tkdnee.fsf@assigned-by-dhcp.cox.net","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0701241505260.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] diff --check: use colour","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-24T23:18:33Z","receivedAt":"2007-01-24T23:18:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Reuse the colour handling of the regular diff.\n\nJohannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Reuse the colour handling of the regular diff.\n>\n> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> ---\n>\n> \tIs it possible that diff_get_color() _never_ returns NULL?\n> \tThen diff.c can be further cleaned up...\n\nDoes anybody actually use \"diff --check\"?  We could lose more\ncode by removing the option altogether ;-)\n\nSeriously, this option needs to be documented.  Volunteers?\n"},{"id":"32596","messageId":"Pine.LNX.4.63.0701251015390.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6506","inReplyTo":"7vr6tkdnee.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] diff --check: use colour","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-25T09:16:15Z","receivedAt":"2007-01-25T09:16:15Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 24 Jan 2007, Junio C Hamano wrote:\n\n> Does anybody actually use \"diff --check\"?\n\nYes, I do.\n\nCiao,\nDscho\n"},{"id":"32650","messageId":"7vk5za925w.fsf@assigned-by-dhcp.cox.net","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0701251015390.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] diff --check: use colour","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-25T22:23:07Z","receivedAt":"2007-01-25T22:23:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Wed, 24 Jan 2007, Junio C Hamano wrote:\n>\n>> Does anybody actually use \"diff --check\"?\n>\n> Yes, I do.\n\nThen\n\n\tSeriously, this option needs to be documented.  Volunteers?\n"},{"id":"32653","messageId":"17849.13327.527531.262943@lisa.zopyra.com","threadId":"6506","inReplyTo":"7vk5za925w.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] diff --check: use colour","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-01-25T22:49:51Z","receivedAt":"2007-01-25T22:49:51Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Thursday, January 25, 2007 at 14:23:07 (-0800) Junio C Hamano writes:\n>...\n>Then\n>\n>\tSeriously, this option needs to be documented.  Volunteers?\n\nIf you think someone new to git could do this, I would be happy to\nmake this my first contribution to the git community.\n\nTell me where to look for the thing to modify, how to modify it, and\nhow to tell you about what I did (etc.), and I'll give it a go.\n\n\nBill\n"},{"id":"32661","messageId":"Pine.LNX.4.63.0701260034320.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6506","inReplyTo":"17849.13327.527531.262943@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-25T23:41:42Z","receivedAt":"2007-01-25T23:41:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 25 Jan 2007, Bill Lear wrote:\n\n> On Thursday, January 25, 2007 at 14:23:07 (-0800) Junio C Hamano writes:\n> >...\n> >Then\n> >\n> >\tSeriously, this option needs to be documented.  Volunteers?\n> \n> If you think someone new to git could do this, I would be happy to make \n> this my first contribution to the git community.\n> \n> Tell me where to look for the thing to modify, how to modify it, and how \n> to tell you about what I did (etc.), and I'll give it a go.\n\nThe --check option is handled in diff.c (you can find out by e.g. \"git \ngrep -e --check -- \\*\"). Thus, it should be documented in \nDocumentation/diff-options.txt.\n\nThe easiest way to find out what it does is to execute:\n\n\tgit log -S--check diff.c\n\nThis will lead you to v1.4.0-rc1~110.\n\nThe file format for Documentation/*.txt is easily imitated by looking at \nthe context, and maybe eventually \"make doc\" (you'll need asciidoc for \nthat).\n\nOnce you made that change, just commit and make a patch with \"git \nformat-patch HEAD^\". Submit. Be famous.\n\nThank you,\nDscho\n"},{"id":"32666","messageId":"17849.17947.645022.282882@lisa.zopyra.com","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0701260034320.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] diff --check: use colour","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-01-26T00:06:51Z","receivedAt":"2007-01-26T00:06:51Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Friday, January 26, 2007 at 00:41:42 (+0100) Johannes Schindelin writes:\n>...\n>The easiest way to find out what it does is to execute:\n>\n>\tgit log -S--check diff.c\n\nHmm, using 1.5.0-rc2, I created a test repo, and did this:\n\necho foo > foo\ngit add foo\ngit commit -a -m foo\necho bar > foo\ngit commit -a -m bar\ngit log -S--check foo\n\nand nothing happened.\n\nI did\n\ngit log -S --check foo\n\nand the thing went off into outer space.  Now at over 2 1/2 minutes of\nCPU time on my 2 Ghz Opteron box...\n\nIs it really '-S--check'?\n\n\nBill\n"},{"id":"32669","messageId":"7vejpi63py.fsf@assigned-by-dhcp.cox.net","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0701241505260.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] diff --check: use colour","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-26T00:17:45Z","receivedAt":"2007-01-26T00:17:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> \tIs it possible that diff_get_color() _never_ returns NULL?\n\nI think so, although it may often return a pointer that points\nat NUL (e.g under --no-color option).\n"},{"id":"32676","messageId":"20070126043120.GA6111@coredump.intra.peff.net","threadId":"6506","inReplyTo":"17849.17947.645022.282882@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-01-26T04:31:20Z","receivedAt":"2007-01-26T04:31:20Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jan 25, 2007 at 06:06:51PM -0600, Bill Lear wrote:\n\n> >The easiest way to find out what it does is to execute:\n> >\tgit log -S--check diff.c\n> \n> Hmm, using 1.5.0-rc2, I created a test repo, and did this:\n\nI think you misunderstood Johannes. The -S option is used to find\nrevisions that include the given string in their changes. So he was\nsuggesting running that command in the _git_ repository, to show you the\ncommit that introduced the --check option (from which you would get some\nmaterial for writing the docs...)\n\n> echo foo > foo\n> git add foo\n> git commit -a -m foo\n> echo bar > foo\n> git commit -a -m bar\n> git log -S--check foo\n> \n> and nothing happened.\n\nRight. You never put the word --check into your repository content. :)\n\n> git log -S --check foo\n> \n> and the thing went off into outer space.  Now at over 2 1/2 minutes of\n> CPU time on my 2 Ghz Opteron box...\n\nThis appears to be a bug. I will look into it.\n\n-Peff\n"},{"id":"32720","messageId":"45B9E1A2.40505@op5.se","threadId":"6506","inReplyTo":"17849.17947.645022.282882@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-01-26T11:10:26Z","receivedAt":"2007-01-26T11:10:26Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Bill Lear wrote:\n> On Friday, January 26, 2007 at 00:41:42 (+0100) Johannes Schindelin writes:\n>> ...\n>> The easiest way to find out what it does is to execute:\n>>\n>> \tgit log -S--check diff.c\n> \n> Hmm, using 1.5.0-rc2, I created a test repo, and did this:\n> \n> echo foo > foo\n> git add foo\n> git commit -a -m foo\n> echo bar > foo\n> git commit -a -m bar\n> git log -S--check foo\n> \n> and nothing happened.\n> \n> I did\n> \n> git log -S --check foo\n> \n> and the thing went off into outer space.  Now at over 2 1/2 minutes of\n> CPU time on my 2 Ghz Opteron box...\n> \n> Is it really '-S--check'?\n> \n\nYes. '-S--check' will start a pickaxe search for the string '--check' in\nthe repository, covering all the history and the likes. It can take quite\na long time (even if used properly ;-)), but it's certainly better than having\nto look manually.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"32730","messageId":"200701261205.28504.andyparkins@gmail.com","threadId":"6506","inReplyTo":"17849.17947.645022.282882@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-01-26T12:05:27Z","receivedAt":"2007-01-26T12:05:27Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Friday 2007 January 26 00:06, Bill Lear wrote:\n\n> git log -S --check foo\n>\n> and the thing went off into outer space.  Now at over 2 1/2 minutes of\n> CPU time on my 2 Ghz Opteron box...\n\nI would guess it's because you've used \"-S<space>--check\"; the --check will be \nignored as git-log doesn't use it, but the -S is saying \"search for the empty \nstring\" in all log messages - that's probably a long list, and so takes a \nwhile to compile.\n\n> Is it really '-S--check'?\n\nYep - it's \"-S<string to search for>\", so you'd be searching for the \nstring \"--check\" in that example.\n\n\nAndy\n\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"},{"id":"32736","messageId":"17850.1928.124641.990272@lisa.zopyra.com","threadId":"6506","inReplyTo":"200701261205.28504.andyparkins@gmail.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-01-26T13:52:08Z","receivedAt":"2007-01-26T13:52:08Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Friday, January 26, 2007 at 12:05:27 (+0000) Andy Parkins writes:\n>On Friday 2007 January 26 00:06, Bill Lear wrote:\n>\n>> git log -S --check foo\n>>\n>> and the thing went off into outer space.  Now at over 2 1/2 minutes of\n>> CPU time on my 2 Ghz Opteron box...\n>\n>I would guess it's because you've used \"-S<space>--check\"; the --check will be \n>ignored as git-log doesn't use it, but the -S is saying \"search for the empty \n>string\" in all log messages - that's probably a long list, and so takes a \n>while to compile.\n\nWell, remember this was a test repo, one file, one commit, with the word\n\"foo\" in the file.  Even if searching for a space, it should not take\nthat long.  I think it's an infinite loop somewhere.\n\n\nBill\n"},{"id":"32746","messageId":"17850.8953.478146.754550@lisa.zopyra.com","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0701260034320.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] diff --check: use colour","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-01-26T15:49:13Z","receivedAt":"2007-01-26T15:49:13Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Friday, January 26, 2007 at 00:41:42 (+0100) Johannes Schindelin writes:\n>...\n>The file format for Documentation/*.txt is easily imitated by looking at \n>the context, and maybe eventually \"make doc\" (you'll need asciidoc for \n>that).\n>\n>Once you made that change, just commit and make a patch with \"git \n>format-patch HEAD^\". Submit. Be famous.\n\nOk, I've read through the code and, have experimented with 'diff --check'\nfairly extensively, now understand it, have documented what I understand,\nand am now building the doc to ensure it is properly formatted.\n\nI presume that I send the patch text to the list with the subject line\nthat starts with [PATCH], some sensible topic (e.g., \"document --check\noption to diff\"), and then a short body of explanation and then,\nfollowing my signature, the patch itself.\n\nAssuming that is correct, I should have a patch out before the end of\nthe day.\n\n\nBill\n"},{"id":"32748","messageId":"20070126160040.GA7730@fieldses.org","threadId":"6506","inReplyTo":"17850.8953.478146.754550@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-01-26T16:00:40Z","receivedAt":"2007-01-26T16:00:40Z","isPatch":true,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Fri, Jan 26, 2007 at 09:49:13AM -0600, Bill Lear wrote:\n> Ok, I've read through the code and, have experimented with 'diff --check'\n> fairly extensively, now understand it, have documented what I understand,\n> and am now building the doc to ensure it is properly formatted.\n> \n> I presume that I send the patch text to the list with the subject line\n> that starts with [PATCH], some sensible topic (e.g., \"document --check\n> option to diff\"), and then a short body of explanation and then,\n> following my signature, the patch itself.\n\nSee also Documentation/SubmittingPatches in the git tree.\n\n--b.\n"},{"id":"32750","messageId":"17850.10014.251824.979660@lisa.zopyra.com","threadId":"6506","inReplyTo":"17850.8953.478146.754550@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-01-26T16:06:54Z","receivedAt":"2007-01-26T16:06:54Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Friday, January 26, 2007 at 09:49:13 (-0600) Bill Lear writes:\n>...\n>Assuming that is correct, I should have a patch out before the end of\n>the day.\n\nI did this:\n\ngit format-patch -s HEAD^\n\nit produced this file:\n\n0001-Document-check-option-to-git-diff.patch\n\nwhich looks to be formatted as a mail message:\n\n>From 2a81f1e97564b89ab622cf32b68e7cebf605eafe Mon Sep 17 00:00:00 2001\n>From: Bill Lear <rael@zopyra.com>\n>Date: Fri, 26 Jan 2007 09:58:07 -0600\n>Subject: [PATCH] Document --check option to git-diff.\n>\n>\n>Signed-off-by: Bill Lear <rael@zopyra.com>\n>---\n> Documentation/diff-options.txt |    5 +++++\n> Documentation/git-diff.txt     |    6 ++++++\n> 2 files changed, 11 insertions(+), 0 deletions(-)\n>...\n\n\nDo I optionally edit this file, putting my comments before the\n\"Signed-off-by\" line, and then just send this off to the list with my\nmail command, i.e.:\n\n% mail git@vger.kernel.org < 0001-Document-check-option-to-git-diff.patch\n\n?\n\n\nBill\n"},{"id":"32751","messageId":"17850.10060.840121.23662@lisa.zopyra.com","threadId":"6506","inReplyTo":"20070126160040.GA7730@fieldses.org","subject":"Re: [PATCH] diff --check: use colour","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-01-26T16:07:40Z","receivedAt":"2007-01-26T16:07:40Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Friday, January 26, 2007 at 11:00:40 (-0500) J. Bruce Fields writes:\n>...\n>See also Documentation/SubmittingPatches in the git tree.\n\nSorry, missed that before my previous post went out...\n\n\nBill\n"},{"id":"32752","messageId":"200701261637.01199.andyparkins@gmail.com","threadId":"6506","inReplyTo":"17850.8953.478146.754550@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-01-26T16:37:00Z","receivedAt":"2007-01-26T16:37:00Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Friday 2007 January 26 15:49, Bill Lear wrote:\n\n> I presume that I send the patch text to the list with the subject line\n> that starts with [PATCH], some sensible topic (e.g., \"document --check\n> option to diff\"), and then a short body of explanation and then,\n> following my signature, the patch itself.\n\ngit-format-patch will make you an email of the correct form.  Personally I do \nthis (this is the IMAP server version, but it's similar for mbox)\n\n * make myself a branch from current master\n * write patch/patches, test (yeah, right ;-))\n * git-format-patch --stdout HEAD^ to check it looks good\n * git-format-patch --stdout HEAD^ | git-imap-send \n * Go to Drafts mailbox, open it up, add any additional comments for the\n   mailing list only underneath the \"---\" and before the diffstat.  Make sure\n   you turn word wrap off as soon as you open the mail.  Word wrapping will\n   ruin the patch.\n * Send.\n * Wait for huge feeling of disappointment because your patch is junk and\n   gets savaged by the git-gurus (maybe this step is just for me though).\n\nTo make this all easy and automatic I also have the following in \nmy .git/config:\n\n[format]\n        headers = \"To: git@vger.kernel.org\\n\"\n\nAnd the following in my ~/.gitconfig:\n\n[imap]\n    Folder = \"INBOX.Drafts\"\n    Tunnel = \"ssh -q mailhost /usr/bin/imapd ./IMAPmd 2> /dev/null\"\n\nAnd the following in my .git/hooks/commit-msg (make sure you set it \nexecutable) to automatically add the \"Signed-Off-By\" line to your commits:\n\nSOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\\(.*>\\).*$/Signed-off-by: \\1/p')\ngrep -qs \"^$SOB\" \"$1\" || echo \"$SOB\" >> \"$1\"\n\nI've also enabled the .git/hooks/pre-commit hook (chmod a+x) to make git check \nmy patches before they get committed.\n\ngit-format-patch makes git mailing list friendly patches that match the \nguidelines given in Documentation/SubmittingPatches\n\nHope that helps.\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"},{"id":"32756","messageId":"20070126171929.GA23324@coredump.intra.peff.net","threadId":"6506","inReplyTo":"17850.10014.251824.979660@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-01-26T17:19:30Z","receivedAt":"2007-01-26T17:19:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jan 26, 2007 at 10:06:54AM -0600, Bill Lear wrote:\n\n> git format-patch -s HEAD^\n> [...]\n> which looks to be formatted as a mail message:\n\nRight.\n\nThe format is:\n  - subject line is the first line of your commit message\n  - subsequent body lines are the rest of your commit message, until you\n    hit the ---\n  - below that is the patch; everything in the patch section that is not\n    an actual diff hunk is free-form (e.g., the diffstat).\n\n> Do I optionally edit this file, putting my comments before the\n> \"Signed-off-by\" line, and then just send this off to the list with my\n> mail command, i.e.:\n\nComments before the signed-off-by line will be part of the commit\nmessage; so if you have comments to put there, you probably would have\nmade them when your were committing. If you have comments to send with\nthe email (\"cover letter\"), place them after the --- but before the\ndiffstat.\n\n> % mail git@vger.kernel.org < 0001-Document-check-option-to-git-diff.patch\n> \n> ?\n\nI'm not an expert on 'mail' but I'm not sure if it handles headers\ncorrectly (i.e., it expects body text, _not_ the full rfc822 message).\nYou can use git-send-email, but I find its interface a little clunky.\nYou can use git-imap-send to place the message in an IMAP mailbox, which\nyou can then presumably grab as a 'draft' using your regular mail\nclient. Or you can use a mail client which understands mbox (most unix\nones do), open the file as an mbox, and then resume it as a draft.\n\nOr finally, you can simply edit in the headers you want, remove the\ninitial 'From ' line, and pipe it to sendmail. :)\n\nWhat's easiest for you depends on what your mail setup is like (I use\nmutt to open the mbox, then \"resend\" it with editing).\n\n-Peff\n"},{"id":"32757","messageId":"epddi9$f2r$1@sea.gmane.org","threadId":"6506","inReplyTo":"17850.10014.251824.979660@lisa.zopyra.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-01-26T17:26:39Z","receivedAt":"2007-01-26T17:26:39Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"[Cc: git@vger.kernel.org]\n\nBill Lear wrote:\n\n> On Friday, January 26, 2007 at 09:49:13 (-0600) Bill Lear writes:\n>>...\n>>Assuming that is correct, I should have a patch out before the end of\n>>the day.\n> \n> I did this:\n> \n> git format-patch -s HEAD^\n> \n> it produced this file:\n> \n> 0001-Document-check-option-to-git-diff.patch\n> \n> which looks to be formatted as a mail message:\n> \n>>From 2a81f1e97564b89ab622cf32b68e7cebf605eafe Mon Sep 17 00:00:00 2001\n>>From: Bill Lear <rael@zopyra.com>\n>>Date: Fri, 26 Jan 2007 09:58:07 -0600\n>>Subject: [PATCH] Document --check option to git-diff.\n>>\n>>\n>>Signed-off-by: Bill Lear <rael@zopyra.com>\n>>---\n>> Documentation/diff-options.txt |    5 +++++\n>> Documentation/git-diff.txt     |    6 ++++++\n>> 2 files changed, 11 insertions(+), 0 deletions(-)\n>>...\n> \n> \n> Do I optionally edit this file, putting my comments before the\n> \"Signed-off-by\" line, and then just send this off to the list with my\n> mail command, i.e.:\n\nBefore \"Signed-off-by\" line you put commit message. Any coments\nwhich are not meant to be in commit message (like for example reply\nto some email) are to be put after \"---\" line, but before diffstat.\n\nRead Documentation/SubmittingPatches\n\n> % mail git@vger.kernel.org < 0001-Document-check-option-to-git-diff.patch\n\nThis should work.\n\n% git send-email --to git@vger.kernel.org 0001-Document-check-option-to-git-diff.patch\n\nshould also work.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"32758","messageId":"epdedp$s0o$1@sea.gmane.org","threadId":"6506","inReplyTo":"200701261637.01199.andyparkins@gmail.com","subject":"Re: [PATCH] diff --check: use colour","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-01-26T17:41:19Z","receivedAt":"2007-01-26T17:41:19Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Andy Parkins wrote:\n\n> On Friday 2007 January 26 15:49, Bill Lear wrote:\n> \n>> I presume that I send the patch text to the list with the subject line\n>> that starts with [PATCH], some sensible topic (e.g., \"document --check\n>> option to diff\"), and then a short body of explanation and then,\n>> following my signature, the patch itself.\n> \n> git-format-patch will make you an email of the correct form.  Personally I do \n> this (this is the IMAP server version, but it's similar for mbox)\n\nYou can use git-send-email to send emails via SMTP. I have configured\nsendmail to send emails via gmail\n\n-dnl define(`SMART_HOST',`smtp.your.provider')\n+define(`SMART_HOST',`[smtp.gmail.com]')\n \n>  * make myself a branch from current master\n>  * write patch/patches, test (yeah, right ;-))\n\nThe same for me (with the exception that I branch from origin).\nIf writing patches takes longer time, and upstream has\nadvanced in meantime, I also rebase before sending patches.\n\n   * rebase branch using \"git rebase master <branch>\"\n\n>  * git-format-patch --stdout HEAD^ to check it looks good\n>  * git-format-patch --stdout HEAD^ | git-imap-send \n>  * Go to Drafts mailbox, open it up, add any additional comments for the\n>    mailing list only underneath the \"---\" and before the diffstat.  Make sure\n>    you turn word wrap off as soon as you open the mail.  Word wrapping will\n>    ruin the patch.\n\nFor me it is \"git format-patch HEAD^..\" if it is one patch (one commit)\nonly, \"git format-patch -o mdir.<n> origin..\" if this is series of patches.\nThen edit the patches (the 0001-*.txt file), adding any additional\ncomments for the mailing list only underneath the \"---\" and before\nthe diffstat.\n\n>  * Send.\n\nUse \"git send-email <patch>\" or \"git send-email mdir.<n>\" to send patches.\n\n>  * Wait for huge feeling of disappointment because your patch is junk and\n>    gets savaged by the git-gurus (maybe this step is just for me though).\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"32764","messageId":"Pine.LNX.4.63.0701262214420.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6506","inReplyTo":"7vejpi63py.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] diff --check: use colour","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-01-26T21:15:20Z","receivedAt":"2007-01-26T21:15:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 25 Jan 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > \tIs it possible that diff_get_color() _never_ returns NULL?\n> \n> I think so, although it may often return a pointer that points\n> at NUL (e.g under --no-color option).\n\nAh! I misread that particular part of the code. It says \"if (!*ws)\", not \n-- as I read it -- \"if (!ws)\".\n\nCiao,\nDscho\n"},{"id":"34917","messageId":"7vfy94qplg.fsf@assigned-by-dhcp.cox.net","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0701262214420.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] diff --check: use colour","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-18T00:25:15Z","receivedAt":"2007-02-18T00:25:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I wonder what happened to this patch...\n"},{"id":"34921","messageId":"Pine.LNX.4.63.0702180146260.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6506","inReplyTo":"7vfy94qplg.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] diff --check: use colour","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-18T00:47:40Z","receivedAt":"2007-02-18T00:47:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 17 Feb 2007, Junio C Hamano wrote:\n\n> I wonder what happened to this patch...\n\nI think it is still the same. At least I did not use another patch in my \nprivate tree, and it works fine.\n\nI _thought_ I could clean it up a little more, but then realized a thinko \non my part: I misread a NUL for a NULL.\n\nShould I resend?\n\nCiao,\nDscho\n"},{"id":"34924","messageId":"7vodnsp950.fsf@assigned-by-dhcp.cox.net","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0702180146260.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] diff --check: use colour","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-18T01:06:03Z","receivedAt":"2007-02-18T01:06:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> I _thought_ I could clean it up a little more, but then realized a thinko \n> on my part: I misread a NUL for a NULL.\n>\n> Should I resend?\n\nNo need.  I think you have unused variable 'message' but I'll\nmanage.\n"},{"id":"34926","messageId":"Pine.LNX.4.63.0702180215250.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6506","inReplyTo":"7vodnsp950.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] diff --check: use colour","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-18T01:15:55Z","receivedAt":"2007-02-18T01:15:55Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 17 Feb 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > I _thought_ I could clean it up a little more, but then realized a thinko \n> > on my part: I misread a NUL for a NULL.\n> >\n> > Should I resend?\n> \n> No need.  I think you have unused variable 'message' but I'll\n> manage.\n\nAh yes. And I'm sure you'll manage. ;-)\n\nCiao,\nDscho\n"},{"id":"34957","messageId":"Pine.LNX.4.63.0702181725400.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6506","inReplyTo":"Pine.LNX.4.63.0702180215250.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"[PATCH for \"master\"] diff --check: use colour","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-18T16:27:24Z","receivedAt":"2007-02-18T16:27:24Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nReuse the colour handling of the regular diff.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tThis time I tried to make sure that the patch applies cleanly\n\tto \"master\", that there are no compiler warnings, and that no\n\tbehaviour (apart from --check) is changed.\n\n diff.c |   57 +++++++++++++++++++++++++++++++++++++++------------------\n 1 files changed, 39 insertions(+), 18 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 701880a..ce25f4b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -405,22 +405,16 @@ static void emit_line(const char *set, const char *reset, const char *line, int\n \tputs(reset);\n }\n \n-static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)\n+static void emit_line_with_ws(int nparents,\n+\t\tconst char *set, const char *reset, const char *ws,\n+\t\tconst char *line, int len)\n {\n-\tint col0 = ecbdata->nparents;\n+\tint col0 = nparents;\n \tint last_tab_in_indent = -1;\n \tint last_space_in_indent = -1;\n \tint i;\n \tint tail = len;\n \tint need_highlight_leading_space = 0;\n-\tconst char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);\n-\tconst char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);\n-\n-\tif (!*ws) {\n-\t\temit_line(set, reset, line, len);\n-\t\treturn;\n-\t}\n-\n \t/* The line is a newly added line.  Does it have funny leading\n \t * whitespaces?  In indent, SP should never precede a TAB.\n \t */\n@@ -475,6 +469,18 @@ static void emit_add_line(const char *reset, struct emit_callback *ecbdata, cons\n \t\temit_line(set, reset, line + i, len - i);\n }\n \n+static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)\n+{\n+\tconst char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);\n+\tconst char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);\n+\n+\tif (!*ws)\n+\t\temit_line(set, reset, line, len);\n+\telse\n+\t\temit_line_with_ws(ecbdata->nparents, set, reset, ws,\n+\t\t\t\tline, len);\n+}\n+\n static void fn_out_consume(void *priv, char *line, unsigned long len)\n {\n \tint i;\n@@ -884,30 +890,44 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)\n struct checkdiff_t {\n \tstruct xdiff_emit_state xm;\n \tconst char *filename;\n-\tint lineno;\n+\tint lineno, color_diff;\n };\n \n static void checkdiff_consume(void *priv, char *line, unsigned long len)\n {\n \tstruct checkdiff_t *data = priv;\n+\tconst char *ws = diff_get_color(data->color_diff, DIFF_WHITESPACE);\n+\tconst char *reset = diff_get_color(data->color_diff, DIFF_RESET);\n+\tconst char *set = diff_get_color(data->color_diff, DIFF_FILE_NEW);\n \n \tif (line[0] == '+') {\n-\t\tint i, spaces = 0;\n+\t\tint i, spaces = 0, space_before_tab = 0, white_space_at_end = 0;\n \n \t\t/* check space before tab */\n \t\tfor (i = 1; i < len && (line[i] == ' ' || line[i] == '\\t'); i++)\n \t\t\tif (line[i] == ' ')\n \t\t\t\tspaces++;\n \t\tif (line[i - 1] == '\\t' && spaces)\n-\t\t\tprintf(\"%s:%d: space before tab:%.*s\\n\",\n-\t\t\t\tdata->filename, data->lineno, (int)len, line);\n+\t\t\tspace_before_tab = 1;\n \n \t\t/* check white space at line end */\n \t\tif (line[len - 1] == '\\n')\n \t\t\tlen--;\n \t\tif (isspace(line[len - 1]))\n-\t\t\tprintf(\"%s:%d: white space at end: %.*s\\n\",\n-\t\t\t\tdata->filename, data->lineno, (int)len, line);\n+\t\t\twhite_space_at_end = 1;\n+\n+\t\tif (space_before_tab || white_space_at_end) {\n+\t\t\tprintf(\"%s:%d: %s\", data->filename, data->lineno, ws);\n+\t\t\tif (space_before_tab) {\n+\t\t\t\tprintf(\"space before tab\");\n+\t\t\t\tif (white_space_at_end)\n+\t\t\t\t\tputchar(',');\n+\t\t\t}\n+\t\t\tif (white_space_at_end)\n+\t\t\t\tprintf(\"white space at end\");\n+\t\t\tprintf(\":%s \", reset);\n+\t\t\temit_line_with_ws(1, set, reset, ws, line, len);\n+\t\t}\n \n \t\tdata->lineno++;\n \t} else if (line[0] == ' ')\n@@ -1165,7 +1185,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,\n \n static void builtin_checkdiff(const char *name_a, const char *name_b,\n \t\t\t     struct diff_filespec *one,\n-\t\t\t     struct diff_filespec *two)\n+\t\t\t     struct diff_filespec *two, struct diff_options *o)\n {\n \tmmfile_t mf1, mf2;\n \tstruct checkdiff_t data;\n@@ -1177,6 +1197,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdata.xm.consume = checkdiff_consume;\n \tdata.filename = name_b ? name_b : name_a;\n \tdata.lineno = 0;\n+\tdata.color_diff = o->color_diff;\n \n \tif (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)\n \t\tdie(\"unable to read files to diff\");\n@@ -1787,7 +1808,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)\n \tdiff_fill_sha1_info(p->one);\n \tdiff_fill_sha1_info(p->two);\n \n-\tbuiltin_checkdiff(name, other, p->one, p->two);\n+\tbuiltin_checkdiff(name, other, p->one, p->two, o);\n }\n \n void diff_setup(struct diff_options *options)\n-- \n1.5.0.52.gf6b7-dirty\n"}]}