diff options
| author | brian m. carlson <sandals@crustytoothpaste.net> | 2025-10-09 21:56:23 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-09 17:46:14 -0700 |
| commit | b95c59e21e6afeddc56400e162e818a9312f04d2 (patch) | |
| tree | 040fea1673e4ad558b59c87b3a21bbecbc4dc94a /builtin/rev-parse.c | |
| parent | docs: add documentation for loose objects (diff) | |
| download | git-b95c59e21e6afeddc56400e162e818a9312f04d2.tar.gz git-b95c59e21e6afeddc56400e162e818a9312f04d2.zip | |
rev-parse: allow printing compatibility hash
Right now, we have a way to print the storage hash, the input hash, and
the output hash, but we lack a way to print the compatibility hash. Add
a new type to --show-object-format, compat, which prints this value.
If no compatibility hash exists, simply print a newline. This is
important to allow users to use multiple options at once while still
getting unambiguous output.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
| -rw-r--r-- | builtin/rev-parse.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 44ff1b8342..187b7e8be9 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -1108,11 +1108,20 @@ int cmd_rev_parse(int argc, const char *val = arg ? arg : "storage"; if (strcmp(val, "storage") && + strcmp(val, "compat") && strcmp(val, "input") && strcmp(val, "output")) die(_("unknown mode for --show-object-format: %s"), arg); - puts(the_hash_algo->name); + + if (!strcmp(val, "compat")) { + if (the_repository->compat_hash_algo) + puts(the_repository->compat_hash_algo->name); + else + putchar('\n'); + } else { + puts(the_hash_algo->name); + } continue; } if (!strcmp(arg, "--show-ref-format")) { |
