{"thread":{"id":"6549","subject":"[PATCH] Document check option to git diff.","startedAt":"2007-01-26T17:42:52Z","lastAt":"2007-01-27T03:05:39Z","messageCount":4,"participants":["rael@zopyra.com","Junio C Hamano","Bill Lear"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"32759","messageId":"1169833372823-git-send-email-rael@zopyra.com","threadId":"6549","inReplyTo":null,"subject":"[PATCH] Document check option to git diff.","fromName":"","fromEmail":"rael@zopyra.com","sentAt":"2007-01-26T17:42:52Z","receivedAt":"2007-01-26T17:42:52Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"From: Bill Lear <rael@zopyra.com>\n\n\nSigned-off-by: Bill Lear <rael@zopyra.com>\n---\n Documentation/SubmittingPatches |    3 ++-\n Documentation/diff-options.txt  |    5 +++++\n Documentation/git-diff.txt      |    6 ++++++\n 3 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 41b76d8..ce85d06 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -23,7 +23,8 @@ probably need to split up your commit to finer grained pieces.\n \n Oh, another thing.  I am picky about whitespaces.  Make sure your\n changes do not trigger errors with the sample pre-commit hook shipped\n-in templates/hooks--pre-commit.\n+in templates/hooks--pre-commit.  To help ensure this does not happen,\n+run git diff --check on your changes before you commit.\n \n \n (2) Generate your patch using git tools out of your commits.\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex da1cc60..501e0df 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -58,6 +58,11 @@\n \tTurn off rename detection, even when the configuration\n \tfile gives the default to do so.\n \n+--check::\n+\tCheck whether differences form a valid patch.  Warns if\n+\tdifferences include a space before a tab or a space at the end\n+\tof a line.\n+\n --full-index::\n \tInstead of the first handful characters, show full\n \tobject name of pre- and post-image blob on the \"index\"\ndiff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt\nindex 6a098df..5054fb7 100644\n--- a/Documentation/git-diff.txt\n+++ b/Documentation/git-diff.txt\n@@ -70,6 +70,7 @@ Various ways to check your working tree::\n $ git diff            <1>\n $ git diff --cached   <2>\n $ git diff HEAD       <3>\n+$ git diff --check    <4>\n ------------\n +\n <1> changes in the working tree not yet staged for the next commit.\n@@ -77,6 +78,11 @@ $ git diff HEAD       <3>\n would be committing if you run \"git commit\" without \"-a\" option.\n <3> changes in the working tree since your last commit; what you\n would be committing if you run \"git commit -a\"\n+<4> display whether what you are about to commit is a valid patch,\n+including whether you have spaces at the end of lines, or spaces\n+before tabs.  Violations are displayed in this form:\n+\n+<file name>:<line number>:<violation>:<offending line>\n \n Comparing with arbitrary commits::\n +\n-- \n1.5.0-rc2.GIT-dirty\n"},{"id":"32783","messageId":"7vodoltkqt.fsf@assigned-by-dhcp.cox.net","threadId":"6549","inReplyTo":"1169833372823-git-send-email-rael@zopyra.com","subject":"Re: [PATCH] Document check option to git diff.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-26T23:46:02Z","receivedAt":"2007-01-26T23:46:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"rael@zopyra.com writes:\n\n> From: Bill Lear <rael@zopyra.com>\n>\n> Signed-off-by: Bill Lear <rael@zopyra.com>\n> ---\n>  Documentation/SubmittingPatches |    3 ++-\n>  Documentation/diff-options.txt  |    5 +++++\n>  Documentation/git-diff.txt      |    6 ++++++\n>  3 files changed, 13 insertions(+), 1 deletions(-)\n\nThanks.  It's nice to see somebody new getting more and more\ncomfortable with git.\n\n> diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\n> index da1cc60..501e0df 100644\n> --- a/Documentation/diff-options.txt\n> +++ b/Documentation/diff-options.txt\n> @@ -58,6 +58,11 @@\n>  \tTurn off rename detection, even when the configuration\n>  \tfile gives the default to do so.\n>  \n> +--check::\n> +\tCheck whether differences form a valid patch.  Warns if\n> +\tdifferences include a space before a tab or a space at the end\n> +\tof a line.\n> +\n\nIt is supposed to be only about new lines; correcting an\nexisting line that had trailing whitespaces should not trigger\nthe check.  \"SP before a TAB\" check is supposed to apply only in\nthe indent part (if the code does not work that way, you have\nspotted bugs).\n\nAlso I fear that 'valid' is a bit too strong a word here.  A\npatch that introduces new lines that have trailing whitespaces\nis still a valid patch in the sense that 'patch' and 'git apply'\nwould accept it as input.  How about rewording it like this?\n\n\tLook for and warn about changes that introduce trailing\n        whitespaces at the end of the line or an indent that\n        uses a whitespace before a tab.\n\n> diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt\n> index 6a098df..5054fb7 100644\n> --- a/Documentation/git-diff.txt\n> +++ b/Documentation/git-diff.txt\n> @@ -70,6 +70,7 @@ Various ways to check your working tree::\n>  $ git diff            <1>\n>  $ git diff --cached   <2>\n>  $ git diff HEAD       <3>\n> +$ git diff --check    <4>\n>  ------------\n>  +\n>  <1> changes in the working tree not yet staged for the next commit.\n> @@ -77,6 +78,11 @@ $ git diff HEAD       <3>\n>  would be committing if you run \"git commit\" without \"-a\" option.\n>  <3> changes in the working tree since your last commit; what you\n>  would be committing if you run \"git commit -a\"\n> +<4> display whether what you are about to commit is a valid patch,\n> +including whether you have spaces at the end of lines, or spaces\n> +before tabs.  Violations are displayed in this form:\n> +\n> +<file name>:<line number>:<violation>:<offending line>\n>  \n>  Comparing with arbitrary commits::\n>  +\n\n        ... what you are about to commit introduces funny whitespaces,\n        such as traling whitespaces at the end of the line or an indent\n        that uses a whitespace before a tab.  Violations are...\n"},{"id":"32794","messageId":"17850.45971.918929.314082@lisa.zopyra.com","threadId":"6549","inReplyTo":"7vodoltkqt.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Document check option to git diff.","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2007-01-27T02:06:11Z","receivedAt":"2007-01-27T02:06:11Z","isPatch":true,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Friday, January 26, 2007 at 15:46:02 (-0800) Junio C Hamano writes:\n>...\n>Thanks.  It's nice to see somebody new getting more and more\n>comfortable with git.\n\nI, and my colleagues, are grateful for all the work put into it.\n\n>Also I fear that 'valid' is a bit too strong a word here.  ...\n>                     ....  How about rewording it like this?\n>\n>\tLook for and warn about changes that introduce trailing\n>        whitespaces at the end of the line or an indent that\n>        uses a whitespace before a tab.\n\nI was indeed too strong in wording it as \"valid\": yet another example\nof haste-induced waste.\n\nI believe that an accurate and concise statement would be:\n\n    Warn if changes introduce trailing whitespace\n    or an indent that uses a space before a tab.\n\nI think it should be explicitly limited to \"space\" and not\n\"whitespace\" before the tab, as \"whitespace\" really includes tab.\n\nDo I really need to say \"trailing whitespace at the end of the line\"?\nThat seems overly verbose: trailing whitespace is, I think, understood\nto trail at the end of the line.\n\nI'll re-do the patch when I hear back, probably tomorrow.\n\nAlso: I suppose I am wondering about the motivation for this switch.\nIt seems to reflect the aesthetics of the git project.  Whitespace at\nthe end of a line is meaningless and wasteful, so I understand and\nsympathize with the judgment that this is undesirable.  Spaces\npreceding tabs are somewhat murkier: two tabs, a space, and text pass\nthe check, but a tab, space, tab and text do not.  Why is this bad?\n\nI'm sure there is a better way to categorize these violations other\nthan \"funny\".  Should we not say \"wasteful and inelegant, and\ntherefore anathema to any decent, self-respecting person\"?\n\n\nBill\n"},{"id":"32795","messageId":"7vps91p3ss.fsf@assigned-by-dhcp.cox.net","threadId":"6549","inReplyTo":"17850.45971.918929.314082@lisa.zopyra.com","subject":"Re: [PATCH] Document check option to git diff.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-27T03:05:39Z","receivedAt":"2007-01-27T03:05:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bill Lear <rael@zopyra.com> writes:\n\n> I believe that an accurate and concise statement would be:\n>\n>     Warn if changes introduce trailing whitespace\n>     or an indent that uses a space before a tab.\n>\n> I think it should be explicitly limited to \"space\" and not\n> \"whitespace\" before the tab, as \"whitespace\" really includes tab.\n>\n> Do I really need to say \"trailing whitespace at the end of the line\"?\n> That seems overly verbose: trailing whitespace is, I think, understood\n> to trail at the end of the line.\n\nAll true.  Thanks for rewording.\n\n> Also: I suppose I am wondering about the motivation for this switch.\n> It seems to reflect the aesthetics of the git project.  Whitespace at\n> the end of a line is meaningless and wasteful, so I understand and\n> sympathize with the judgment that this is undesirable.  Spaces\n> preceding tabs are somewhat murkier: two tabs, a space, and text pass\n> the check, but a tab, space, tab and text do not.  Why is this bad?\n\nThe trailing space removal comes from the kernel project\naesthetics:\n\n\thttp://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt\n\tlinux-2.6/Documentation/CodingStyle (end of Chapter 1)\n\n\"TAB SP TAB blah\" visually is the same as \"TAB TAB blah\".  It is\nbad for the same reason as \"fofofofo SP TAB EOL\" (which is\nvisually the same as \"fofofofo EOL\") is bad.  This is not from\nthe kernel project, so if the above reasoning is flawed, it is\nmy fault.  I once considered saying 8 spaces are bad and should\nbe replaced with a tab, but I refrained from going that far ;-).\n\n> I'm sure there is a better way to categorize these violations other\n> than \"funny\".  Should we not say \"wasteful and inelegant, and\n> therefore anathema to any decent, self-respecting person\"?\n\n\"Wasteful\" is probably better than \"funny\"; I do not think of a\ngood wording.\n\nSometimes we do want to keep the trailing whitespaces (the patch\nthat came over e-mail to produce commit c7c24889, for example),\nso getting warnings from \"git-diff --check\" (or its counterpart,\n\"git-apply --whitespace=warn\") is not a crime.  But most of the\ntime, they only waste space and bandwidth and many people who\nare conscious about hygiene of their sources seem to avoid them\nlike the plague.\n"}]}