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

RE: Feature Request: Option to make "git rev-list --objects" output duplicate objects

From
Baumann, Moritz <moritz.baumann@sap.com>
Date
Mar 28, 2023, 08:08 UTC
Message-ID
<AS1PR02MB8185DF947EBC583318481E1994889@AS1PR02MB8185.eurprd02.prod.outlook.com>
In-Reply-To
<20230324192848.GC536967@coredump.intra.peff.net>
> Another problem you might not have run into yet: the names given by
> rev-list are not quoted in any way, and will just omit newlines. So if
> your hook is trying to avoid malicious garbage like "foo\nbar", it won't
> work.
Thanks for that warning. I was not aware that rev-list didn't quote file names.
> Those names are really just intended as hints for pack-objects. I
> suspect the documentation could be more clear about these limitations.

That would indeed be great and would have likely prevented the obvious misconceptions on my side.

> I'm not sure what you mean by "one by one", since that is inherently
> what rev-list is doing under the hood. If you mean "running a separate
> process for each commit", then yes, that will be slow.
Yes, that's what I meant to say.
Show 6 quoted lines
> But if you want
> to know all of the names touched in a set of commits, I have used
> something like this before:
>
>   git rev-list $new --not --all |
>   git diff-tree --stdin --format= -r -c --name-only

Thanks, that looks promising and solves at least one of my use cases. The only minor problem is that there seems to be no way to pipe the diff-tree output to cat-file without massaging it with awk first.

I have three uses cases in my pre-receive hooks:
1. Filters solely based on the file name
   ? your suggestions works perfectly here
2. Filters based only on file contents
   ? git rev-list --objects + git cat-file provide everything I need
3. One filter based on file size and name (forbid large files, with exceptions)
   ? I'm guessing "git rev-list | git diff-tree --stdin | awk |
     git cat-file --batch-check" is the best solution to extract the necessary
     information from git in this case?
-- Moritz
Previous: Jeff KingNext: Jeff King
Message 6 of 9 in “Feature Request: Option to make "git rev-list --objects" output duplicate objects”
  1. Baumann, MoritzMar 24, 2023
  2. Junio C HamanoMar 24, 2023
  3. Baumann, MoritzMar 27, 2023
  4. Junio C HamanoMar 27, 2023
  5. Jeff KingMar 24, 2023
  6. Baumann, MoritzMar 28, 2023
  7. docs: document caveats of rev-list's object-name outputJeff King, Mar 28, 2023
  8. Baumann, MoritzMar 30, 2023
  9. Jeff KingMar 28, 2023

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.