Re: [PATCH] Update documentation for stripspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Conrad Irwin <conrad.irwin@xxxxxxxxx> 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).

> Signed-off-by: Conrad Irwin <conrad.irwin@xxxxxxxxx>
> ---
>  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.

> +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".

> +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.

>  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".

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]