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

Re: [PATCH v5] rev-list: teach --no-object-names to enable piping

From
Jeff King <peff@peff.net>
Date
Jun 19, 2019, 21:38 UTC
Message-ID
<20190619213804.GD6571@sigill.intra.peff.net>
In-Reply-To
<20190619205656.117272-1-emilyshaffer@google.com>
On Wed, Jun 19, 2019 at 01:56:56PM -0700, Emily Shaffer wrote:
Show 5 quoted lines
> Allow easier parsing by cat-file by giving rev-list an option to print
> only the OID of a non-commit object without any additional information.
> This is a short-term shim; later on, rev-list should be taught how to
> print the types of objects it finds in a format similar to cat-file's.
> [...]

I missed some of the intermediate rounds, but fortunately Junio already said everything I was going to. :) This version looks good to me, though with one minor nit:

Show 12 quoted lines
> diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
> index 88609ff435..9392760b25 100644
> --- a/Documentation/git-rev-list.txt
> +++ b/Documentation/git-rev-list.txt
> @@ -48,6 +48,7 @@ SYNOPSIS
>  	     [ --date=<format>]
>  	     [ [ --objects | --objects-edge | --objects-edge-aggressive ]
>  	       [ --unpacked ]
> +	       [ --object-names | --no-object-names ]
>  	       [ --filter=<filter-spec> [ --filter-print-omitted ] ] ]
>  	     [ --missing=<missing-action> ]
>  	     [ --pretty | --header ]

Here you put --object-names along with the --objects. Which kind of makes sense, but everything else in that block is about choosing _which_ commits to show. In the short help, you put it near --pretty:

Show 8 quoted lines
> @@ -49,6 +49,7 @@ static const char rev_list_usage[] =
>  "    --objects | --objects-edge\n"
>  "    --unpacked\n"
>  "    --header | --pretty\n"
> +"    --[no-]object-names\n"
>  "    --abbrev=<n> | --no-abbrev\n"
>  "    --abbrev-commit\n"
>  "    --left-right\n"

which I think makes more sense. I think maybe you were trying to imply that "--object-names" is not useful unless you're also using "--objects". Which is true, but I'm not sure it's obvious from that mass of brackets (and I think is sufficiently covered in the actual option descriptions you give later).

Show 6 quoted lines
> +test_expect_success '--no-object-names and --object-names are last-one-wins' '
> +	git rev-list --objects --no-object-names --object-names --all >output &&
> +	grep wanted_file output &&
> +	git rev-list --objects --object-names --no-object-names --all >output &&
> +	! grep wanted_file output
> +'

We don't generally test this behavior for each option, since it would lead to a ton of uninteresting tests (and parse-options generally just handles it). But after our discussion about --no-abbrev, I can see how you might be more interested in the topic. :) So I'm OK with it either way.

-Peff
Previous: Emily Shaffer
Message 22 of 22 in “revision: remove stray whitespace when name empty”
  1. revision: remove stray whitespace when name emptyEmily Shaffer, Jun 7, 2019
  2. Eric SunshineJun 8, 2019
  3. Emily ShafferJun 12, 2019
  4. Jeff KingJun 9, 2019
  5. Junio C HamanoJun 10, 2019
  6. Emily ShafferJun 12, 2019
  7. Jeff KingJun 13, 2019
  8. rev-list: teach --oid-only to enable pipingEmily Shaffer, Jun 13, 2019
  9. Jeff KingJun 14, 2019
  10. Junio C HamanoJun 14, 2019
  11. Emily ShafferJun 14, 2019
  12. Emily ShafferJun 14, 2019
  13. Jeff KingJun 19, 2019
  14. rev-list: teach --no-object-names to enable pipingEmily Shaffer, Jun 14, 2019
  15. Junio C HamanoJun 17, 2019
  16. Emily ShafferJun 18, 2019
  17. rev-list: teach --no-object-names to enable pipingEmily Shaffer, Jun 18, 2019
  18. Junio C HamanoJun 19, 2019
  19. Emily ShafferJun 19, 2019
  20. Jeff KingJun 19, 2019
  21. rev-list: teach --no-object-names to enable pipingEmily Shaffer, Jun 19, 2019
  22. Jeff KingJun 19, 2019

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.