diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-01-05 09:07:17 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-01-05 09:07:17 +0300 |
commit | 319c3abadb047b37e33195f29486794501c8f83f (patch) | |
tree | d8e488dfd6f05e914c49ac59a2a692e97c03710b /builtin/cat-file.c | |
parent | 2b4f5a4e4bb102ac8d967cea653ed753b608193c (diff) | |
parent | a797c0ea042af697d82ad475b9f354c4a33a9047 (diff) |
Merge branch 'sa/cat-file-mailmap--batch-check'
'cat-file' gains mailmap support for its '--batch-check' and '-s'
options.
* sa/cat-file-mailmap--batch-check:
cat-file: add mailmap support to --batch-check option
cat-file: add mailmap support to -s option
Diffstat (limited to 'builtin/cat-file.c')
-rw-r--r-- | builtin/cat-file.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c index b3be58b1fb..cc17635e76 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -132,8 +132,21 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, case 's': oi.sizep = &size; + + if (use_mailmap) { + oi.typep = &type; + oi.contentp = (void**)&buf; + } + if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0) die("git cat-file: could not get object info"); + + if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) { + size_t s = size; + buf = replace_idents_using_mailmap(buf, &s); + size = cast_size_t_to_ulong(s); + } + printf("%"PRIuMAX"\n", (uintmax_t)size); ret = 0; goto cleanup; @@ -431,6 +444,9 @@ static void batch_object_write(const char *obj_name, if (!data->skip_object_info) { int ret; + if (use_mailmap) + data->info.typep = &data->type; + if (pack) ret = packed_object_info(the_repository, pack, offset, &data->info); @@ -444,6 +460,18 @@ static void batch_object_write(const char *obj_name, fflush(stdout); return; } + + if (use_mailmap && (data->type == OBJ_COMMIT || data->type == OBJ_TAG)) { + size_t s = data->size; + char *buf = NULL; + + buf = repo_read_object_file(the_repository, &data->oid, &data->type, + &data->size); + buf = replace_idents_using_mailmap(buf, &s); + data->size = cast_size_t_to_ulong(s); + + free(buf); + } } strbuf_reset(scratch); |