]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rev-list: support NUL-delimited --boundary option
authorJustin Tobler <jltobler@gmail.com>
Wed, 19 Mar 2025 18:34:09 +0000 (13:34 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Mar 2025 10:40:02 +0000 (03:40 -0700)
The `--boundary` option for git-rev-list(1) prints boundary objects
found while performing the object walk in the form:

        $ git rev-list --boundary <rev>
        -<oid> LF

Add support for printing boundary objects in a NUL-delimited format when
the `-z` option is enabled.

        $ git rev-list -z --boundary <rev>
        <oid> NUL boundary=yes NUL

In this mode, instead of prefixing the boundary OID with '-', a separate
`boundary=yes` token/value pair is appended.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/rev-list-options.adoc
builtin/rev-list.c
t/t6000-rev-list-misc.sh

index aef83813b80955b08949d02a7e3bf316258fb30b..3fc9902d6b8f7af79242930ac220a7311fdec3dc 100644 (file)
@@ -371,17 +371,19 @@ ifdef::git-rev-list[]
 <OID> NUL [<token>=<value> NUL]...
 -----------------------------------------------------------------------
 +
-Additional object metadata, such as object paths, is printed using the
-`<token>=<value>` form. Token values are printed as-is without any
-encoding/truncation. An OID entry never contains a '=' character and thus
-is used to signal the start of a new object record. Examples:
+Additional object metadata, such as object paths or boundary objects, is
+printed using the `<token>=<value>` form. Token values are printed as-is
+without any encoding/truncation. An OID entry never contains a '=' character
+and thus is used to signal the start of a new object record. Examples:
 +
 -----------------------------------------------------------------------
 <OID> NUL
 <OID> NUL path=<path> NUL
+<OID> NUL boundary=yes NUL
 -----------------------------------------------------------------------
 +
-This mode is only compatible with the `--objects` output option.
+This mode is only compatible with the `--objects` and `--boundary` output
+options.
 endif::git-rev-list[]
 
 History Simplification
index 17de99d9cadf00949103b6f84d6358e2c34de1e3..bcb880f10996c6a21ab5ef00cbd18136a7945c61 100644 (file)
@@ -240,13 +240,18 @@ static void show_commit(struct commit *commit, void *data)
                fputs(info->header_prefix, stdout);
 
        if (revs->include_header) {
-               if (!revs->graph)
+               if (!revs->graph && line_term)
                        fputs(get_revision_mark(revs, commit), stdout);
                if (revs->abbrev_commit && revs->abbrev)
                        fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev),
                              stdout);
                else
                        fputs(oid_to_hex(&commit->object.oid), stdout);
+
+               if (!line_term) {
+                       if (commit->object.flags & BOUNDARY)
+                               printf("%cboundary=yes", info_term);
+               }
        }
        if (revs->print_parents) {
                struct commit_list *parents = commit->parents;
@@ -778,7 +783,7 @@ int cmd_rev_list(int argc,
                if (revs.graph || revs.verbose_header || show_disk_usage ||
                    info.show_timestamp || info.header_prefix || bisect_list ||
                    use_bitmap_index || revs.edge_hint || revs.left_right ||
-                   revs.cherry_mark || arg_missing_action || revs.boundary)
+                   revs.cherry_mark || arg_missing_action)
                        die(_("-z option used with unsupported option"));
        }
 
index 886e2fc710b66f865cb727f7e0c5f46b51043e8d..33881274a41ad2eb2adfa661cea0f8ac16909315 100755 (executable)
@@ -217,4 +217,20 @@ test_expect_success 'rev-list -z --objects' '
        test_cmp expect actual
 '
 
+test_expect_success 'rev-list -z --boundary' '
+       test_when_finished rm -rf repo &&
+
+       git init repo &&
+       test_commit -C repo 1 &&
+       test_commit -C repo 2 &&
+
+       oid1=$(git -C repo rev-parse HEAD~) &&
+       oid2=$(git -C repo rev-parse HEAD) &&
+
+       printf "%s\0%s\0boundary=yes\0" "$oid2" "$oid1" >expect &&
+       git -C repo rev-list -z --boundary HEAD~.. >actual &&
+
+       test_cmp expect actual
+'
+
 test_done