git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] rev-list: introduce NUL-delimited output mode
@ 2025-03-10 19:28 Justin Tobler
  2025-03-10 19:28 ` [PATCH 1/4] rev-list: inline `show_object_with_name()` in `show_object()` Justin Tobler
                   ` (7 more replies)
  0 siblings, 8 replies; 60+ messages in thread
From: Justin Tobler @ 2025-03-10 19:28 UTC (permalink / raw)
  To: git; +Cc: ps, christian.couder, Justin Tobler

When walking objects, git-rev-list(1) prints each object entry on a
separate line in the form:

        <oid> LF

Some options, such as `--objects`, may print additional information
about the object on the same line:

        <oid> SP [<path>] LF

In this mode, if the object path contains a newline it is truncated at
the newline.

When the `--missing={print,print-info}` option is provided, information
about any missing objects encountered during the object walk are also
printed in the form:

        ?<oid> [SP <token>=<value>]... LF

where values containing LF or SP are printed in a token specific fashion
so that the resulting encoded value does not contain either of these two
problematic bytes. For example, missing object paths are quoted in the C
style so they contain LF or SP.

To make machine parsing easier, this series introduces a NUL-delimited
output mode for git-rev-list(1) via a `-z` option following a suggestion
from Junio in a previous thread[1]. In this mode, instead of LF, each
object is delimited with two NUL bytes and any object metadata is
separated with a single NUL byte. Examples:

        <oid> NUL NUL
        <oid> [NUL <path>] NUL NUL
        ?<oid> [NUL <token>=<value>]... NUL NUL

In this mode, path and value info are printed as-is without any special
encoding or truncation.

For now this series only adds support for use with the `--objects` and
`--missing` options. Usage of `-z` with other options is rejected, so it
can potentially be added in the future.

One idea I had, but did not implement in this version, was to also use
the `<token>=<value>` format for regular non-missing object info while
in the NUL-delimited mode. I could see this being a bit more flexible
instead of relying strictly on order. Interested if anyone has thoughts
on this. :)

This series is structured as follows:

        - Patches 1 and 2 do some minor preparatory refactors.

        - Patch 3 adds the `-z` option to git-rev-list(1) to print
          objects in a NUL-delimited fashion. Printed object paths with
          the `--objects` option are also handled.

        - Patch 4 teaches the `--missing` option how to print info in a
          NUL-delimited fashion.

Thanks for taking a look,
-Justin

[1]: <xmqq5xlor0la.fsf@gitster.g>

Justin Tobler (4):
  rev-list: inline `show_object_with_name()` in `show_object()`
  rev-list: refactor early option parsing
  rev-list: support delimiting objects with NUL bytes
  rev-list: support NUL-delimited --missing option

 Documentation/rev-list-options.adoc | 26 +++++++++
 builtin/rev-list.c                  | 86 ++++++++++++++++++++++-------
 revision.c                          |  8 ---
 revision.h                          |  2 -
 t/t6000-rev-list-misc.sh            | 34 ++++++++++++
 t/t6022-rev-list-missing.sh         | 30 ++++++++++
 6 files changed, 155 insertions(+), 31 deletions(-)


base-commit: 87a0bdbf0f72b7561f3cd50636eee33dcb7dbcc3
-- 
2.49.0.rc2


^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2025-03-19 18:37 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 19:28 [PATCH 0/4] rev-list: introduce NUL-delimited output mode Justin Tobler
2025-03-10 19:28 ` [PATCH 1/4] rev-list: inline `show_object_with_name()` in `show_object()` Justin Tobler
2025-03-10 20:51   ` Junio C Hamano
2025-03-10 19:28 ` [PATCH 2/4] rev-list: refactor early option parsing Justin Tobler
2025-03-10 20:54   ` Junio C Hamano
2025-03-12 21:39     ` Justin Tobler
2025-03-10 19:28 ` [PATCH 3/4] rev-list: support delimiting objects with NUL bytes Justin Tobler
2025-03-10 20:59   ` Junio C Hamano
2025-03-12 21:39     ` Justin Tobler
2025-03-12  7:50   ` Patrick Steinhardt
2025-03-12 21:41     ` Justin Tobler
2025-03-10 19:28 ` [PATCH 4/4] rev-list: support NUL-delimited --missing option Justin Tobler
2025-03-10 20:37 ` [PATCH 0/4] rev-list: introduce NUL-delimited output mode Junio C Hamano
2025-03-10 21:08   ` Junio C Hamano
2025-03-11 23:24     ` Justin Tobler
2025-03-11 23:19   ` Justin Tobler
2025-03-11 23:44     ` Junio C Hamano
2025-03-12  7:37       ` Patrick Steinhardt
2025-03-12 21:45         ` Justin Tobler
2025-03-10 22:38 ` D. Ben Knoble
2025-03-11 22:59   ` Justin Tobler
2025-03-11 23:57 ` Jeff King
2025-03-12  7:42   ` Patrick Steinhardt
2025-03-12 15:56     ` Junio C Hamano
2025-03-13  7:46       ` Patrick Steinhardt
2025-03-12 22:09   ` Justin Tobler
2025-03-13  5:33     ` Jeff King
2025-03-13 16:41       ` Justin Tobler
2025-03-14  2:49         ` Jeff King
2025-03-14 17:02           ` Junio C Hamano
2025-03-14 18:59             ` Jeff King
2025-03-14 19:53               ` Justin Tobler
2025-03-14 21:16                 ` Junio C Hamano
2025-03-19 15:58                   ` Justin Tobler
2025-03-13  0:17 ` [PATCH v2 0/6] " Justin Tobler
2025-03-13  0:17   ` [PATCH v2 1/6] rev-list: inline `show_object_with_name()` in `show_object()` Justin Tobler
2025-03-13  0:17   ` [PATCH v2 2/6] rev-list: refactor early option parsing Justin Tobler
2025-03-13  0:17   ` [PATCH v2 3/6] revision: support NUL-delimited --stdin mode Justin Tobler
2025-03-13  0:17   ` [PATCH v2 4/6] rev-list: support delimiting objects with NUL bytes Justin Tobler
2025-03-13 12:55     ` Patrick Steinhardt
2025-03-13 14:44       ` Justin Tobler
2025-03-13  0:17   ` [PATCH v2 5/6] rev-list: support NUL-delimited --boundary option Justin Tobler
2025-03-13  0:17   ` [PATCH v2 6/6] rev-list: support NUL-delimited --missing option Justin Tobler
2025-03-13 12:55     ` Patrick Steinhardt
2025-03-13 14:51       ` Justin Tobler
2025-03-13 23:57   ` [PATCH v3 0/6] rev-list: introduce NUL-delimited output mode Justin Tobler
2025-03-13 23:57     ` [PATCH v3 1/6] rev-list: inline `show_object_with_name()` in `show_object()` Justin Tobler
2025-03-13 23:57     ` [PATCH v3 2/6] rev-list: refactor early option parsing Justin Tobler
2025-03-13 23:57     ` [PATCH v3 3/6] revision: support NUL-delimited --stdin mode Justin Tobler
2025-03-13 23:57     ` [PATCH v3 4/6] rev-list: support delimiting objects with NUL bytes Justin Tobler
2025-03-19 12:35       ` Christian Couder
2025-03-19 16:02         ` Justin Tobler
2025-03-13 23:57     ` [PATCH v3 5/6] rev-list: support NUL-delimited --boundary option Justin Tobler
2025-03-13 23:57     ` [PATCH v3 6/6] rev-list: support NUL-delimited --missing option Justin Tobler
2025-03-19 18:34     ` [PATCH v4 0/5] rev-list: introduce NUL-delimited output mode Justin Tobler
2025-03-19 18:34       ` [PATCH v4 1/5] rev-list: inline `show_object_with_name()` in `show_object()` Justin Tobler
2025-03-19 18:34       ` [PATCH v4 2/5] rev-list: refactor early option parsing Justin Tobler
2025-03-19 18:34       ` [PATCH v4 3/5] rev-list: support delimiting objects with NUL bytes Justin Tobler
2025-03-19 18:34       ` [PATCH v4 4/5] rev-list: support NUL-delimited --boundary option Justin Tobler
2025-03-19 18:34       ` [PATCH v4 5/5] rev-list: support NUL-delimited --missing option Justin Tobler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).