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
This commit is contained in:
Junio C Hamano
2023-01-05 15:07:17 +09:00
3 changed files with 132 additions and 14 deletions

View File

@ -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);