Skip to content

Commit 1c3c1ab

Browse files
jltoblergitster
authored andcommitted
rev-list: support NUL-delimited --boundary option
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3d59c2 commit 1c3c1ab

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

Documentation/rev-list-options.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,19 @@ ifdef::git-rev-list[]
371371
<OID> NUL [<token>=<value> NUL]...
372372
-----------------------------------------------------------------------
373373
+
374-
Additional object metadata, such as object paths, is printed using the
375-
`<token>=<value>` form. Token values are printed as-is without any
376-
encoding/truncation. An OID entry never contains a '=' character and thus
377-
is used to signal the start of a new object record. Examples:
374+
Additional object metadata, such as object paths or boundary objects, is
375+
printed using the `<token>=<value>` form. Token values are printed as-is
376+
without any encoding/truncation. An OID entry never contains a '=' character
377+
and thus is used to signal the start of a new object record. Examples:
378378
+
379379
-----------------------------------------------------------------------
380380
<OID> NUL
381381
<OID> NUL path=<path> NUL
382+
<OID> NUL boundary=yes NUL
382383
-----------------------------------------------------------------------
383384
+
384-
This mode is only compatible with the `--objects` output option.
385+
This mode is only compatible with the `--objects` and `--boundary` output
386+
options.
385387
endif::git-rev-list[]
386388

387389
History Simplification

builtin/rev-list.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,18 @@ static void show_commit(struct commit *commit, void *data)
240240
fputs(info->header_prefix, stdout);
241241

242242
if (revs->include_header) {
243-
if (!revs->graph)
243+
if (!revs->graph && line_term)
244244
fputs(get_revision_mark(revs, commit), stdout);
245245
if (revs->abbrev_commit && revs->abbrev)
246246
fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev),
247247
stdout);
248248
else
249249
fputs(oid_to_hex(&commit->object.oid), stdout);
250+
251+
if (!line_term) {
252+
if (commit->object.flags & BOUNDARY)
253+
printf("%cboundary=yes", info_term);
254+
}
250255
}
251256
if (revs->print_parents) {
252257
struct commit_list *parents = commit->parents;
@@ -778,7 +783,7 @@ int cmd_rev_list(int argc,
778783
if (revs.graph || revs.verbose_header || show_disk_usage ||
779784
info.show_timestamp || info.header_prefix || bisect_list ||
780785
use_bitmap_index || revs.edge_hint || revs.left_right ||
781-
revs.cherry_mark || arg_missing_action || revs.boundary)
786+
revs.cherry_mark || arg_missing_action)
782787
die(_("-z option used with unsupported option"));
783788
}
784789

t/t6000-rev-list-misc.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,20 @@ test_expect_success 'rev-list -z --objects' '
217217
test_cmp expect actual
218218
'
219219

220+
test_expect_success 'rev-list -z --boundary' '
221+
test_when_finished rm -rf repo &&
222+
223+
git init repo &&
224+
test_commit -C repo 1 &&
225+
test_commit -C repo 2 &&
226+
227+
oid1=$(git -C repo rev-parse HEAD~) &&
228+
oid2=$(git -C repo rev-parse HEAD) &&
229+
230+
printf "%s\0%s\0boundary=yes\0" "$oid2" "$oid1" >expect &&
231+
git -C repo rev-list -z --boundary HEAD~.. >actual &&
232+
233+
test_cmp expect actual
234+
'
235+
220236
test_done

0 commit comments

Comments
 (0)