Git fork

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 <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Justin Tobler and committed by
Junio C Hamano
1c3c1ab3 c3d59c2e

+30 -7
+7 -5
Documentation/rev-list-options.adoc
··· 371 371 <OID> NUL [<token>=<value> NUL]... 372 372 ----------------------------------------------------------------------- 373 373 + 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: 378 378 + 379 379 ----------------------------------------------------------------------- 380 380 <OID> NUL 381 381 <OID> NUL path=<path> NUL 382 + <OID> NUL boundary=yes NUL 382 383 ----------------------------------------------------------------------- 383 384 + 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. 385 387 endif::git-rev-list[] 386 388 387 389 History Simplification
+7 -2
builtin/rev-list.c
··· 240 240 fputs(info->header_prefix, stdout); 241 241 242 242 if (revs->include_header) { 243 - if (!revs->graph) 243 + if (!revs->graph && line_term) 244 244 fputs(get_revision_mark(revs, commit), stdout); 245 245 if (revs->abbrev_commit && revs->abbrev) 246 246 fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev), 247 247 stdout); 248 248 else 249 249 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 + } 250 255 } 251 256 if (revs->print_parents) { 252 257 struct commit_list *parents = commit->parents; ··· 778 783 if (revs.graph || revs.verbose_header || show_disk_usage || 779 784 info.show_timestamp || info.header_prefix || bisect_list || 780 785 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) 782 787 die(_("-z option used with unsupported option")); 783 788 } 784 789
+16
t/t6000-rev-list-misc.sh
··· 217 217 test_cmp expect actual 218 218 ' 219 219 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 + 220 236 test_done