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

Re: [PATCH] rev-list-options: clarify the usage of -n/--max-number

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 27, 2016, 16:51 UTC
Message-ID
<xmqq1t05qoad.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<010201576bfb6c7d-0b68228f-9503-4dd1-9721-713477fa2596-000000@eu-west-1.amazonses.com>
Pranit Bauva <pranit.bauva@gmail.com> writes:
> -n=<number>, -<number>, --max-number=<number> shows the last n commits
> specified in <number> irrespective of whether --reverse is used or not.
> With --reverse, it just shows the last n commits in reverse order.

I think it is easier to understand if you updated the description of "--reverse", rather than "-<n>". "rev-list -n $N" that stops after showing $N commits is something everybody understands. What often dissapoints some users is that "--reverse" kicks in _after_ what commits are to be shown are decided.

Show 13 quoted lines
>  Documentation/rev-list-options.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
> index 7e462d3..6b7c2e5 100644
> --- a/Documentation/rev-list-options.txt
> +++ b/Documentation/rev-list-options.txt
> @@ -18,7 +18,7 @@ ordering and formatting options, such as `--reverse`.
>  -<number>::
>  -n <number>::
>  --max-count=<number>::
> -	Limit the number of commits to output.
> +	Limit to last n number of commits to output specified in <number>.

These essentially say the same thing. The original does not mention where and how <number> is used, but "Limit the number of commits" as a description for "-<number>" would be understood by anybody halfway intelligent that the given number is used as that limit, so I do not think an updated description is making it easier to understand.

There is a paragraph of interest in an earlier part of "Commit Limiting" section (which is the section "-n" appears in, among other options):

    Note that these are applied before commit
    ordering and formatting options, such as `--reverse`.

So the documentation already makes an attempt to avoid confusion Ruediger saw, i.e. "rev-list traverses, limits the output to N, and then shows these N commits in reverse" is what it expects readers to understand, and that it also expects it would lead naturally to "these N commits are still from the newest part of the history, hence 'rev-list --reverse -n N' is not how you grab the earliest N".

But apparently the attempt by the current documentation is not enough. Let's see how it describes the '--reverse' option:

    Commit Ordering
    ~~~~~~~~~~~~~~~
    By default, the commits are shown in reverse chronological order.
    ...
    --reverse::
            Output the commits in reverse order.
            Cannot be combined with `--walk-reflogs`.

Perhaps "Output the commits chosen to be shown (see Commit Limiting section above) in reverse order." would make it clearer?

Previous: Pranit BauvaNext: Pranit Bauva
Message 3 of 9 in “question about git rev-list --max-count=n”
  1. Ruediger MeierSep 27, 2016
  2. rev-list-options: clarify the usage of -n/--max-numberPranit Bauva, Sep 27, 2016
  3. Junio C HamanoSep 27, 2016
  4. Pranit BauvaSep 27, 2016
  5. rev-list-options: clarify the usage of --reversePranit Bauva, Sep 27, 2016
  6. Philip OakleySep 27, 2016
  7. Junio C HamanoSep 27, 2016
  8. Philip OakleySep 27, 2016
  9. Pranit BauvaSep 28, 2016

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.