mbox series

[v3,0/4] rev-list: print additional missing object information

Message ID 20250201201658.11562-1-jltobler@gmail.com (mailing list archive)
Headers show
Series rev-list: print additional missing object information | expand

Message

Justin Tobler Feb. 1, 2025, 8:16 p.m. UTC
Greetings,

It is possible to configure git-rev-list(1) to print the OID of missing
objects by setting the `--missing=print` option. While it is useful
knowing about these objects, it would be nice to have even more context
about the objects that are missing. Luckily, from an object containing
the missing object, it is possible to infer additional information the
missing object. For example, if the tree containing a missing blob still
exists, the tree entry for the missing object should contain path and
type information.

This series aims to provide git-rev-list(1) with a new `print-info`
missing action for the `--missing` option that, when set, behaves like
the existing `print` action but also prints other potentially
interesting information about the missing object.

Missing object info is printed in the form `?<oid> [<token>=<value>]...`
where multiple `<token>=<value>` pairs may be specified each separated
from each other with a SP. Values that contain SP or LF characters are
expected to be encoded in a manner such that these problematic bytes are
handled. For missing object path information this is handled by quoting
the path in the C style if it contains SP or special characters.

One concern I currently have with this quoting approach is that it is a
bit more challenging to machine parse compared to something like using a
null byte to delimit between missing info. One option is, in a followup
series, introduce a git-for-each-ref(1) style format syntax. Maybe
something like: `--missing=print-info:%(path)%00%(type)`. I'm curious if
anyone may have thoughts around this. My goal is to ensure that there is
an easy to use machine parsable interface to get this information. I
could see something like `?<oid> path="foo \"bar" type=blob`, being a
bit complex.

The series is set up as follows:

- Pathes 1 and 2 provide the `quote_c_style` and `quote_path` functions
  with a way print consistent output regardless of how core.quotePath is
  set.

- Patch 3 introduces the `print-info` missing action and supports
  printing missing object path information.

- Patch 4 extends the `print-info` missing action to also print object
  type information about the missing object.

Changes in V3:

- This missing info is provided once again through an explicit
  `--missing=print-info` action instead of combining the
  `--missing=print` and `--missing-info` flag. This was done to make the
  interface a bit straightforward to use and not introduce a flag and is
  dependent on another.

- Added flag to `quote_path()` to disable core.quotePath from impacting
  quoted output and use it when print missing object path info.

- Update documentation to not use the term "attribute" which could be
  confused with gitattributes.

Due to all rearranging/changes in this version, I opted not to include a
range-diff.

Thanks,
-Justin

Justin Tobler (4):
  quote: add c quote flag to ignore core.quotePath
  quote: add quote_path() flag to ignore config
  rev-list: add print-info action to print missing object path
  rev-list: extend print-info to print missing object type

 Documentation/rev-list-options.txt |  19 +++++
 builtin/rev-list.c                 | 107 ++++++++++++++++++++++++-----
 quote.c                            |  27 +++++---
 quote.h                            |   6 +-
 t/t6022-rev-list-missing.sh        |  53 ++++++++++++++
 5 files changed, 184 insertions(+), 28 deletions(-)


base-commit: b74ff38af58464688b211140b90ec90598d340c6

Comments

Christian Couder Feb. 3, 2025, 10:45 a.m. UTC | #1
On Sat, Feb 1, 2025 at 9:20 PM Justin Tobler <jltobler@gmail.com> wrote:
>
> Greetings,
>
> It is possible to configure git-rev-list(1) to print the OID of missing
> objects by setting the `--missing=print` option. While it is useful
> knowing about these objects, it would be nice to have even more context
> about the objects that are missing. Luckily, from an object containing
> the missing object, it is possible to infer additional information the
> missing object. For example, if the tree containing a missing blob still
> exists, the tree entry for the missing object should contain path and
> type information.
>
> This series aims to provide git-rev-list(1) with a new `print-info`
> missing action for the `--missing` option that, when set, behaves like
> the existing `print` action but also prints other potentially
> interesting information about the missing object.

I took a look and commented a bit on patches 1/4 and 2/4. Not sure my
comments are worth a reroll on their own. The other patches look good
to me.

Anyway I think you might want to address Phillip Wood's concerns too:

https://lore.kernel.org/git/76390e3b-e749-4d28-98a5-05db7c5fbcd3@gmail.com/

Thanks.
Justin Tobler Feb. 4, 2025, 10:51 p.m. UTC | #2
On 25/02/03 11:45AM, Christian Couder wrote:
> On Sat, Feb 1, 2025 at 9:20 PM Justin Tobler <jltobler@gmail.com> wrote:
> >
> > Greetings,
> >
> > It is possible to configure git-rev-list(1) to print the OID of missing
> > objects by setting the `--missing=print` option. While it is useful
> > knowing about these objects, it would be nice to have even more context
> > about the objects that are missing. Luckily, from an object containing
> > the missing object, it is possible to infer additional information the
> > missing object. For example, if the tree containing a missing blob still
> > exists, the tree entry for the missing object should contain path and
> > type information.
> >
> > This series aims to provide git-rev-list(1) with a new `print-info`
> > missing action for the `--missing` option that, when set, behaves like
> > the existing `print` action but also prints other potentially
> > interesting information about the missing object.
> 
> I took a look and commented a bit on patches 1/4 and 2/4. Not sure my
> comments are worth a reroll on their own. The other patches look good
> to me.
> 
> Anyway I think you might want to address Phillip Wood's concerns too:
> 
> https://lore.kernel.org/git/76390e3b-e749-4d28-98a5-05db7c5fbcd3@gmail.com/
> 
> Thanks.

Thanks Christian for the review!

-Justin