git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Document check option to git diff.

From
Junio C Hamano <junkio@cox.net>
Date
Jan 26, 2007, 23:46 UTC
Message-ID
<7vodoltkqt.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1169833372823-git-send-email-rael@zopyra.com>
rael@zopyra.com writes:
Show 8 quoted lines
> From: Bill Lear <rael@zopyra.com>
>
> Signed-off-by: Bill Lear <rael@zopyra.com>
> ---
>  Documentation/SubmittingPatches |    3 ++-
>  Documentation/diff-options.txt  |    5 +++++
>  Documentation/git-diff.txt      |    6 ++++++
>  3 files changed, 13 insertions(+), 1 deletions(-)

Thanks. It's nice to see somebody new getting more and more comfortable with git.

Show 13 quoted lines
> diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
> index da1cc60..501e0df 100644
> --- a/Documentation/diff-options.txt
> +++ b/Documentation/diff-options.txt
> @@ -58,6 +58,11 @@
>  	Turn off rename detection, even when the configuration
>  	file gives the default to do so.
>  
> +--check::
> +	Check whether differences form a valid patch.  Warns if
> +	differences include a space before a tab or a space at the end
> +	of a line.
> +

It is supposed to be only about new lines; correcting an existing line that had trailing whitespaces should not trigger the check. "SP before a TAB" check is supposed to apply only in the indent part (if the code does not work that way, you have spotted bugs).

Also I fear that 'valid' is a bit too strong a word here. A patch that introduces new lines that have trailing whitespaces is still a valid patch in the sense that 'patch' and 'git apply' would accept it as input. How about rewording it like this?

	Look for and warn about changes that introduce trailing
        whitespaces at the end of the line or an indent that
        uses a whitespace before a tab.
Show 24 quoted lines
> diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
> index 6a098df..5054fb7 100644
> --- a/Documentation/git-diff.txt
> +++ b/Documentation/git-diff.txt
> @@ -70,6 +70,7 @@ Various ways to check your working tree::
>  $ git diff            <1>
>  $ git diff --cached   <2>
>  $ git diff HEAD       <3>
> +$ git diff --check    <4>
>  ------------
>  +
>  <1> changes in the working tree not yet staged for the next commit.
> @@ -77,6 +78,11 @@ $ git diff HEAD       <3>
>  would be committing if you run "git commit" without "-a" option.
>  <3> changes in the working tree since your last commit; what you
>  would be committing if you run "git commit -a"
> +<4> display whether what you are about to commit is a valid patch,
> +including whether you have spaces at the end of lines, or spaces
> +before tabs.  Violations are displayed in this form:
> +
> +<file name>:<line number>:<violation>:<offending line>
>  
>  Comparing with arbitrary commits::
>  +
        ... what you are about to commit introduces funny whitespaces,
        such as traling whitespaces at the end of the line or an indent
        that uses a whitespace before a tab.  Violations are...
Previous: rael@zopyra.comNext: Bill Lear
Message 2 of 4 in “Document check option to git diff.”
  1. Document check option to git diff.rael@zopyra.com, Jan 26, 2007
  2. Junio C HamanoJan 26, 2007
  3. Bill LearJan 27, 2007
  4. Junio C HamanoJan 27, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.