diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-12-28 14:28:50 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-30 13:05:29 -0800 |
commit | 245b948815048821e73edc1a2b4224eaa94a8fc0 (patch) | |
tree | 6ca7e45929c7a826cb52d574936108cc806f2311 /t | |
parent | object-name.c: don't have GET_OID_ONLY_TO_DIE imply *_QUIETLY (diff) | |
download | tgif-245b948815048821e73edc1a2b4224eaa94a8fc0.tar.xz |
cat-file: use GET_OID_ONLY_TO_DIE in --(textconv|filters)
Change the cat_one_file() logic that calls get_oid_with_context()
under --textconv and --filters to use the GET_OID_ONLY_TO_DIE flag,
thus improving the error messaging emitted when e.g. <path> is missing
but <rev> is not.
To service the "cat-file" use-case we need to introduce a new
"GET_OID_REQUIRE_PATH" flag, otherwise it would exit early as soon as
a valid "HEAD" was resolved, but in the "cat-file" case being changed
we always need a valid revision and path.
This arguably makes the "<bad rev>:<bad path>" and "<bad
rev>:<good (in HEAD) path>" use cases worse, as we won't quote the
<path> component at the user anymore, but let's just use the existing
logic "git log" et al use for now. We can improve the messaging for
those cases as a follow-up for all callers.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t8007-cat-file-textconv.sh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/t/t8007-cat-file-textconv.sh b/t/t8007-cat-file-textconv.sh index 71ea2ac987..b067983ba1 100755 --- a/t/t8007-cat-file-textconv.sh +++ b/t/t8007-cat-file-textconv.sh @@ -29,7 +29,7 @@ test_expect_success 'usage: <bad rev>' ' test_expect_success 'usage: <bad rev>:<bad path>' ' cat >expect <<-\EOF && - fatal: Not a valid object name HEAD2:two.bin + fatal: invalid object name '\''HEAD2'\''. EOF test_must_fail git cat-file --textconv HEAD2:two.bin 2>actual && test_cmp expect actual @@ -37,7 +37,7 @@ test_expect_success 'usage: <bad rev>:<bad path>' ' test_expect_success 'usage: <rev>:<bad path>' ' cat >expect <<-\EOF && - fatal: Not a valid object name HEAD:two.bin + fatal: path '\''two.bin'\'' does not exist in '\''HEAD'\'' EOF test_must_fail git cat-file --textconv HEAD:two.bin 2>actual && test_cmp expect actual @@ -46,7 +46,7 @@ test_expect_success 'usage: <rev>:<bad path>' ' test_expect_success 'usage: <rev> with no <path>' ' cat >expect <<-\EOF && - fatal: git cat-file --textconv HEAD: <object> must be <sha1:path> + fatal: <object>:<path> required, only <object> '\''HEAD'\'' given EOF test_must_fail git cat-file --textconv HEAD 2>actual && test_cmp expect actual @@ -55,7 +55,7 @@ test_expect_success 'usage: <rev> with no <path>' ' test_expect_success 'usage: <bad rev>:<good (in HEAD) path>' ' cat >expect <<-\EOF && - fatal: Not a valid object name HEAD2:one.bin + fatal: invalid object name '\''HEAD2'\''. EOF test_must_fail git cat-file --textconv HEAD2:one.bin 2>actual && test_cmp expect actual |