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
Junio C Hamano <gitster@pobox.com>
Date
Mar 27, 2023, 16:07 UTC
Message-ID
<xmqqzg7ych5i.fsf@gitster.g>
In-Reply-To
<AS1PR02MB818545E563E40C5E31A02D1E948B9@AS1PR02MB8185.eurprd02.prod.outlook.com>
"Baumann, Moritz" <moritz.baumann@sap.com> writes:
Show 5 quoted lines
> The option would be called something like "--include-all-object-names" and
> belong to the category of options that only make sense in combination with
> "--objects". That name (hopefully) already explains the intended behavior:
>
>  * commits are not duplicated
Didn't the sentence above just say "all object names"?  Why not commits?
>  * as before, only changed blobs / subtrees are shown, however:

We are not showing "changed" things at all. If you want that, you'd need "git rev-list | git diff-tree --stdin" instead.

The difference matters if you are aiming for automation (i.e. not casual browsing). If you had a blob A, changed it in a commit to B, and then put the original one A back in another commit, you should see (in reverse history traversal) A and then B and then A again if we were showing "changed" things. But rev-list is not about showing changes. We show A in the latest commit, B in the previous commit, and that is the end. Original needs not to be shown, because rev-list is enumerating the objects in the history and it knows that it showed A already.

If you did not have a blob C, and added two instances of the same blob C to different paths, you should see C twice if we were showing "changed" things. But rev-list is not about showing changes. We show C once for a path, and it is not shown again for the other path. The other one needs not to be shown, because rev-list is enumerating the objects in the history and it knows that it showed C already.

>  * blobs / subtrees are duplicated in the output if they were previously shown
>    with a different name

I suspect that adding "if they were ... with a DIFFERENT name" would probably make it prohibitively more expensive. The traversal done by rev-list is fundamentally driven by "have we shown this object (1-bit)?" to avoid duplicated work, and not "at which path did this object appear (unbounded amount of information)?".

As I told you in the message you are responding to, I think I am OK with the idea of showing a bit more from "rev-list --objects", but such an enhancement may need to be designed a bit better, I am afraid.

I suspect that "rev-list | diff-tree --stdin" without "--objects" added to the upstream "rev-list" might be closer to what you are looking for in this case, but I dunno.

Thanks.
Previous: Baumann, MoritzNext: Jeff King
Message 4 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.