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

Re: [PATCH] Update documentation for stripspace

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 12, 2011, 06:41 UTC
Message-ID
<7vy5ui5h0k.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1323655158-5075-1-git-send-email-conrad.irwin@gmail.com>
Conrad Irwin <conrad.irwin@gmail.com> writes:
> Tell the user what this command is intended for, and expand the
> description of what it does.
Thanks.
> Stop referring to the input as <stream>, as this command reads the
> entire input into memory before processing it.

Which can change to stream, but calling it as input would not invalidate the new wording, so "input" is fine. From the caller's point of view, the current implementation (or streaming implementation) can read from an unseekable input stream (i.e. pipe), so the original wording is equally valid, by the way.

So in that sense, it does not make any difference either way to me (it is not even worth rerolling this patch to only remove this part of the change).

Show 30 quoted lines
> Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
> ---
>  Documentation/git-stripspace.txt |   26 ++++++++++++++++++++------
>  builtin/stripspace.c             |    2 +-
>  2 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/git-stripspace.txt b/Documentation/git-stripspace.txt
> index b78f031..6667d25 100644
> --- a/Documentation/git-stripspace.txt
> +++ b/Documentation/git-stripspace.txt
> @@ -3,26 +3,40 @@ git-stripspace(1)
>  
>  NAME
>  ----
> -git-stripspace - Filter out empty lines
> +git-stripspace - Remove unnecessary whitespace
>  
>  
>  SYNOPSIS
>  --------
>  [verse]
> -'git stripspace' [-s | --strip-comments] < <stream>
> +'git stripspace' [-s | --strip-comments] < input
>  
>  DESCRIPTION
>  -----------
> -Remove multiple empty lines, and empty lines at beginning and end.
> +
> +Normalizes input in the manner used by 'git' for user-provided metadata such
> +as commit messages, notes, tags and branch descriptions.

The original says "remove" and new one says "normalize*s*". I think we tend to say things in imperative mood (i.e. without the trailing "s").

I do not think 'user-provided metadata' is a good wording. This is just a simple text clean-up filter and you can use it to clean your text files that you mean to store in the repository as well.

Show 6 quoted lines
> +When run with no arguments this:
> +
> +- removes trailing whitespace from all lines
> +- collapses multiple consecutive empty lines into one empty line
> +- removes blank lines from the beginning and end of the input
> +- ensures the last line ends with exactly one '\n'.

Thanks for a nicely written bulleted list. It clarifies what the command does quite a bit.

The last one is a bit funny, though.

By definition, you cannot end the last line with more than one '\n' (upon seeing the second '\n', you would realize immediately that the line you saw was _not_ the last line). I think you meant the file does not end with an incomplete line, i.e. "ensures the output does not end with an incomplete line by adding '\n' at the end if needed".

Show 6 quoted lines
> +In the case where the input consists entirely of whitespace characters, no
> +output will be produced.
> +
> +*NOTE*: This is intended for cleaning metadata, prefer the `--whitespace=fix`
> +mode of linkgit:git-apply[1] for correcting whitespace of patches or files in
> +the repository.

I can tell that these three lines were the _primary_ thing you wanted to add with this patch, having never seen anybody got confused between the whitespace breakage fix and text cleaning, I wonder if this is adding clarity or giving users an impression that git can do too many things than they can wrap their mind around and forcing them to wonder if they have to learn everything git can do for them.

Show 6 quoted lines
>  OPTIONS
>  -------
>  -s::
>  --strip-comments::
> -	In addition to empty lines, also strip lines starting with '#'.
> +	Also remove all lines starting with '#'.

With the resulting text (with the rules clarified with your above 4-bullet points) of this manual page, can a user tell what the command does to this input (I added line numbers, vertical bars and dollar signs to show where the beginning and the end of lines are):

    1 | $
    2 |a b c$
    3 |$
    4 |# comment line$
    5 |$
    6 |d e f$
    
The original text at least allows the user to guess correctly, as it hints
that a comment line is treated pretty much like an empty line, and the
"consecutive empty lines are squashed into one" in your bulleted list
would mean that ll 3-5 will become a single blank line.

The new text however gives a wrong hint by saying "Also"; it can be read as if all the rules in the bullted list are applied first to leave blank lines at 3 and 5 and then comment line is removed from the result, which would leave two blank lines in the result.

If I were touching this description, I probably would say something like "Treat lines starting with a '#' as if they are empty lines".

Previous: Conrad IrwinNext: Conrad Irwin
Message 2 of 6 in “Update documentation for stripspace”
  1. Update documentation for stripspaceConrad Irwin, Dec 12, 2011
  2. Junio C HamanoDec 12, 2011
  3. Update documentation for stripspaceConrad Irwin, Dec 12, 2011
  4. Junio C HamanoDec 12, 2011
  5. Update documentation for stripspaceConrad Irwin, Dec 12, 2011
  6. Frans KlaverDec 13, 2011

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.