@@ -378,7 +378,15 @@ containing newline characters:
<OID> [NUL <object-name>] NUL NUL
-----------------------------------------------------------------------
+
-This option is only compatible with `--objects`.
+When the `--missing` option is provided, missing objects are printed in the
+following form where value is printed as-is without any token specific
+encoding:
++
+-----------------------------------------------------------------------
+?<OID> [NUL <token>=<value>]... NUL NUL
+-----------------------------------------------------------------------
++
+This option is only compatible with `--objects` and `--missing`.
endif::git-rev-list[]
History Simplification
@@ -145,25 +145,38 @@ static void print_missing_object(struct missing_objects_map_entry *entry,
int print_missing_info)
{
struct strbuf sb = STRBUF_INIT;
+ char info_sep = ' ';
+
+ if (nul_delim)
+ info_sep = '\0';
+
+ printf("?%s", oid_to_hex(&entry->entry.oid));
if (!print_missing_info) {
- printf("?%s\n", oid_to_hex(&entry->entry.oid));
+ print_object_term(nul_delim);
return;
}
if (entry->path && *entry->path) {
struct strbuf path = STRBUF_INIT;
- strbuf_addstr(&sb, " path=");
- quote_path(entry->path, NULL, &path, QUOTE_PATH_QUOTE_SP);
- strbuf_addbuf(&sb, &path);
+ strbuf_addf(&sb, "%cpath=", info_sep);
+
+ if (nul_delim) {
+ strbuf_addstr(&sb, entry->path);
+ } else {
+ quote_path(entry->path, NULL, &path, QUOTE_PATH_QUOTE_SP);
+ strbuf_addbuf(&sb, &path);
+ }
strbuf_release(&path);
}
if (entry->type)
- strbuf_addf(&sb, " type=%s", type_name(entry->type));
+ strbuf_addf(&sb, "%ctype=%s", info_sep, type_name(entry->type));
+
+ fwrite(sb.buf, sizeof(char), sb.len, stdout);
+ print_object_term(nul_delim);
- printf("?%s%s\n", oid_to_hex(&entry->entry.oid), sb.buf);
strbuf_release(&sb);
}
@@ -782,7 +795,7 @@ int cmd_rev_list(int argc,
if (nul_delim) {
if (revs.graph || revs.verbose_header || show_disk_usage ||
info.show_timestamp || info.header_prefix || bisect_list ||
- use_bitmap_index || revs.edge_hint || arg_missing_action)
+ use_bitmap_index || revs.edge_hint)
die(_("-z option used with unsupported option"));
}
@@ -198,4 +198,34 @@ do
'
done
+test_expect_success "-z nul-delimited --missing" '
+ test_when_finished rm -rf repo &&
+
+ git init repo &&
+ (
+ cd repo &&
+ git commit --allow-empty -m first &&
+
+ path="foo bar" &&
+ echo foobar >"$path" &&
+ git add -A &&
+ git commit -m second &&
+
+ oid=$(git rev-parse "HEAD:$path") &&
+ type="$(git cat-file -t $oid)" &&
+
+ obj_path=".git/objects/$(test_oid_to_path $oid)" &&
+
+ git rev-list -z --objects --no-object-names \
+ HEAD ^"$oid" >expect &&
+ printf "?%s\0path=%s\0type=%s\0\0" "$oid" "$path" "$type" >>expect &&
+
+ mv "$obj_path" "$obj_path.hidden" &&
+ git rev-list -z --objects --no-object-names \
+ --missing=print-info HEAD >actual &&
+
+ test_cmp expect actual
+ )
+'
+
test_done
The `--missing={print,print-info}` option for git-rev-list(1) prints missing objects found while performing the revision walk. Add support for printing missing objects in a NUL-delimited format when the `-z` option is enabled. $ git rev-list -z --missing=print-info <rev> <oid> NUL NUL ?<oid> [NUL <token>=<value>]... NUL NUL In this mode, values containing special characters or spaces are printed as-is without being escaped or quoted. Signed-off-by: Justin Tobler <jltobler@gmail.com> --- Documentation/rev-list-options.adoc | 10 +++++++++- builtin/rev-list.c | 27 +++++++++++++++++++------- t/t6022-rev-list-missing.sh | 30 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 8 deletions(-)