diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-06-17 10:44:39 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-06-17 10:44:39 -0700 |
| commit | 4fd5b1ddc75c941e5f3ecc5586cc2c88c96847a7 (patch) | |
| tree | deced631dba59358a589360411ff592da7d46a04 /builtin | |
| parent | Merge branch 'ag/send-email-docs' (diff) | |
| parent | cat-file.c: add batch handling for submodules (diff) | |
| download | git-4fd5b1ddc75c941e5f3ecc5586cc2c88c96847a7.tar.gz git-4fd5b1ddc75c941e5f3ecc5586cc2c88c96847a7.zip | |
Merge branch 'vd/cat-file-objectmode-update'
"git cat-file --batch" learns to understand %(objectmode) atom to
allow the caller to tell missing objects (due to repository
corruption) and submodules (whose commit objects are OK to be
missing) apart.
* vd/cat-file-objectmode-update:
cat-file.c: add batch handling for submodules
cat-file: add %(objectmode) atom
t1006: update 'run_tests' to test generic object specifiers
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/cat-file.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 67a5ff2b9e..4b23fcecbd 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -275,6 +275,7 @@ struct expand_data { struct object_id oid; enum object_type type; unsigned long size; + unsigned short mode; off_t disk_size; const char *rest; struct object_id delta_base_oid; @@ -306,6 +307,7 @@ struct expand_data { */ unsigned skip_object_info : 1; }; +#define EXPAND_DATA_INIT { .mode = S_IFINVALID } static int is_atom(const char *atom, const char *s, int slen) { @@ -345,6 +347,9 @@ static int expand_atom(struct strbuf *sb, const char *atom, int len, else strbuf_addstr(sb, oid_to_hex(&data->delta_base_oid)); + } else if (is_atom("objectmode", atom, len)) { + if (!data->mark_query && !(S_IFINVALID == data->mode)) + strbuf_addf(sb, "%06o", data->mode); } else return 0; return 1; @@ -491,7 +496,10 @@ static void batch_object_write(const char *obj_name, &data->oid, &data->info, OBJECT_INFO_LOOKUP_REPLACE); if (ret < 0) { - report_object_status(opt, obj_name, &data->oid, "missing"); + if (data->mode == S_IFGITLINK) + report_object_status(opt, oid_to_hex(&data->oid), &data->oid, "submodule"); + else + report_object_status(opt, obj_name, &data->oid, "missing"); return; } @@ -613,6 +621,7 @@ static void batch_one_object(const char *obj_name, goto out; } + data->mode = ctx.mode; batch_object_write(obj_name, scratch, opt, data, NULL, 0); out: @@ -866,7 +875,7 @@ static int batch_objects(struct batch_options *opt) { struct strbuf input = STRBUF_INIT; struct strbuf output = STRBUF_INIT; - struct expand_data data; + struct expand_data data = EXPAND_DATA_INIT; int save_warning; int retval = 0; @@ -875,7 +884,6 @@ static int batch_objects(struct batch_options *opt) * object_info to be handed to oid_object_info_extended for each * object. */ - memset(&data, 0, sizeof(data)); data.mark_query = 1; expand_format(&output, opt->format ? opt->format : DEFAULT_FORMAT, |
