mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
builtin/rev-parse: introduce --show-ref-format
flag
Introduce a new `--show-ref-format` to git-rev-parse(1) that causes it to print the ref format used by a repository. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
58aaf59133
commit
3c4a5318af
@ -307,6 +307,9 @@ The following options are unaffected by `--path-format`:
|
||||
input, multiple algorithms may be printed, space-separated.
|
||||
If not specified, the default is "storage".
|
||||
|
||||
--show-ref-format::
|
||||
Show the reference storage format used for the repository.
|
||||
|
||||
|
||||
Other Options
|
||||
~~~~~~~~~~~~~
|
||||
|
@ -1062,6 +1062,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||
puts(the_hash_algo->name);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--show-ref-format")) {
|
||||
puts(ref_storage_format_to_name(the_repository->ref_storage_format));
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--end-of-options")) {
|
||||
seen_end_of_options = 1;
|
||||
if (filter & (DO_FLAGS | DO_REVS))
|
||||
|
@ -208,6 +208,23 @@ test_expect_success 'rev-parse --show-object-format in repo' '
|
||||
grep "unknown mode for --show-object-format: squeamish-ossifrage" err
|
||||
'
|
||||
|
||||
test_expect_success 'rev-parse --show-ref-format' '
|
||||
test_detect_ref_format >expect &&
|
||||
git rev-parse --show-ref-format >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'rev-parse --show-ref-format with invalid storage' '
|
||||
test_when_finished "rm -rf repo" &&
|
||||
git init repo &&
|
||||
(
|
||||
cd repo &&
|
||||
git config extensions.refstorage broken &&
|
||||
test_must_fail git rev-parse --show-ref-format 2>err &&
|
||||
grep "error: invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}broken${SQ}" err
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success '--show-toplevel from subdir of working tree' '
|
||||
pwd >expect &&
|
||||
git -C sub/dir rev-parse --show-toplevel >actual &&
|
||||
|
Loading…
Reference in New Issue
Block a user