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

Re: [PATCH] rev-list: print missing object type with --missing=print-type

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 8, 2025, 15:17 UTC
Message-ID
<xmqqjzb5pc6t.fsf@gitster.g>
In-Reply-To
<20250108034012.211043-1-jltobler@gmail.com>
Justin Tobler <jltobler@gmail.com> writes:
Show 8 quoted lines
> Handling of missing objects encounted by git-rev-list(1) can be
> configured with the `--missing=<action>` option and specifying the
> desired action. Of the available missing actions, none provide a way to
> print additional information about the missing object such as its type.
>
> Add a new missing action called `print-type`. Similar to `print`, this
> action prints a list of missing objects but also includes the object
> type if available in the form: `?<oid> [type]`.

This part needs to explain where the type information comes from and what its significance is (see below for more details).

Show 11 quoted lines
> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
> index 459e5a02f5..277a0b645e 100644
> --- a/Documentation/rev-list-options.txt
> +++ b/Documentation/rev-list-options.txt
> @@ -1024,6 +1024,9 @@ Unexpected missing objects will raise an error.
>  The form '--missing=print' is like 'allow-any', but will also print a
>  list of the missing objects.  Object IDs are prefixed with a ``?'' character.
>  +
> +The form '--missing=print-type' is like 'print', but will also print the
> +missing object type information if available in the form `?<oid> [type]`.
> ++

The users need to be told what this "type" information really means, as its meaning is quite different from what "git cat-file -t <oid>" would give them. We do not have the object, so we are not learning its type from the object itself. How much trust should the users put in this information, for example?

That comes back to the "where does it come from" that the future readers of "git log" and reviewers need to be told by the proposed log message. Knowing the internals, I know you'd be getting it from the "containing" objects, e.g., an object name that was found on the "parent" object header field of another commit, which is _expected_ to be a commit, or an object name that was found in a tree entry whose mode bits were 100644, which is _expected_ to be a blob, etc.

There are other places that you _could_ glean information about (possibly missing) objects. An object that is found during "rev-list --objects" traversal (which is the topic of this patch after all) but turned out to be missing may not just have an expected type (because it was found in a tree object that we successfully read) but also the full path to the object in the top-level tree, for example.

In modern Git, there are even more places that you may be able to use, like commit-graph that not just hints the object itself is a commit, but what its parents are and when the commit was created.

Note that I am not suggesting to implement more code to learn "type" information from more places than the current patch is doing. At least not in this iteration of the patch. What I am getting at is that it would help us to avoid unnecessarily limiting ourselves by stressing on "type" too much if we at least imagine what the possible sources of these extra pieces of information are and what they could provide.

As I suspect that we would want to leave the door open for us to extend this later, I would perhaps suggest an output format format like:

    ?<object name> [<token>=<value>]...

where <token> tells what kind of extra information it is. I expect that the initial implementation only knows about "type" as the <token>. For future extensibility, we only need to say that under the syntax:

 (1) How multiple attributes are shown?
 (2) How would a <value> with SP or LF in it is represented?

My suggestion is to have multiple <token>=<value> on the same line, with a SP in between, and problematic bytes in <value> are quoted, using cquote(). i.e. a <token>=<value> whose <value> part does not begin with a double-quote ends at the first SP after it, otherwise <value> is taken as a C-quoted string inside a pair of double-quote.

If you are adventurous, I would not mind seeing "path" implemented as another token, since that would be fairly easily obtainable, but it does not have to be in the initial attempt.

Thanks.
Previous: Justin ToblerNext: Justin Tobler
Message 4 of 37 in “rev-list: print missing object type with --missing=print-type”
  1. rev-list: print missing object type with --missing=print-typeJustin Tobler, Jan 8, 2025
  2. Christian CouderJan 8, 2025
  3. Justin ToblerJan 8, 2025
  4. Junio C HamanoJan 8, 2025
  5. Justin ToblerJan 8, 2025
  6. Junio C HamanoJan 8, 2025
  7. Justin ToblerJan 8, 2025
  8. 0/2 rev-list: print additional missing object informationJustin Tobler, Jan 10, 2025
  9. 0/4 rev-list: print additional missing object informationJustin Tobler, Feb 1, 2025
  10. 1/4 quote: add c quote flag to ignore core.quotePathJustin Tobler, Feb 1, 2025
  11. Christian CouderFeb 3, 2025
  12. Junio C HamanoFeb 3, 2025
  13. Junio C HamanoFeb 3, 2025
  14. Junio C HamanoFeb 4, 2025
  15. Justin ToblerFeb 4, 2025
  16. 2/4 quote: add quote_path() flag to ignore configJustin Tobler, Feb 1, 2025
  17. Phillip WoodFeb 2, 2025
  18. Justin ToblerFeb 4, 2025
  19. Phillip WoodFeb 11, 2025
  20. Christian CouderFeb 3, 2025
  21. Junio C HamanoFeb 3, 2025
  22. 3/4 rev-list: add print-info action to print missing object pathJustin Tobler, Feb 1, 2025
  23. 4/4 rev-list: extend print-info to print missing object typeJustin Tobler, Feb 1, 2025
  24. Christian CouderFeb 3, 2025
  25. Justin ToblerFeb 4, 2025
  26. 0/2 rev-list: print additional missing object informationJustin Tobler, Feb 5, 2025
  27. 1/2 rev-list: add print-info action to print missing object pathJustin Tobler, Feb 5, 2025
  28. 2/2 rev-list: extend print-info to print missing object typeJustin Tobler, Feb 5, 2025
  29. Christian CouderFeb 5, 2025
  30. Justin ToblerFeb 5, 2025
  31. Junio C HamanoFeb 5, 2025
  32. Justin ToblerFeb 5, 2025
  33. Junio C HamanoFeb 5, 2025
  34. 1/2 rev-list: add --missing-info to print missing object pathJustin Tobler, Jan 10, 2025
  35. Christian CouderJan 10, 2025
  36. Junio C HamanoJan 10, 2025
  37. 2/2 rev-list: extend --missing-info to print missing object typeJustin Tobler, Jan 10, 2025

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.