From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Taylor Blau" <me@ttaylorr.com>,
"Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
"Jonathan Tan" <jonathantanmy@google.com>,
"Kousik Sanagavarapu" <five231003@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 3/3] tag: don't emit potentially incorrect "object is a X, not a Y"
Date: Fri, 30 Dec 2022 02:52:16 +0100 [thread overview]
Message-ID: <patch-v2-3.3-2493988c41c-20221230T011725Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-0.3-00000000000-20221230T011725Z-avarab@gmail.com>
As noted in the preceding commit we weren't handling cases where we
see a reference to a bad "type" in a "tag", but then end up not fully
parsing the object.
In those cases let's only claim that we have a bad tag pointer, but
emit "is a %s, not a %s".
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/t6102-rev-list-unexpected-objects.sh | 4 ++--
tag.c | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/t/t6102-rev-list-unexpected-objects.sh b/t/t6102-rev-list-unexpected-objects.sh
index 590e2523d0c..98e36e73698 100755
--- a/t/t6102-rev-list-unexpected-objects.sh
+++ b/t/t6102-rev-list-unexpected-objects.sh
@@ -231,7 +231,7 @@ test_expect_success !SANITIZE_LEAK 'traverse unexpected non-tag tag (tree seen t
'
-test_expect_failure !SANITIZE_LEAK 'traverse unexpected objects with for-each-ref' '
+test_expect_success !SANITIZE_LEAK 'traverse unexpected objects with for-each-ref' '
cat >expect <<-EOF &&
error: bad tag pointer to $tree in $tag_tag_tree
fatal: parse_object_buffer failed on $tag_tag_tree for refs/tags/tag_tag_tree
@@ -251,7 +251,7 @@ test_expect_success 'setup: unexpected objects with fsck' '
while read oid type
do
- test_expect_failure "fsck knows unexpected object $oid is $type" '
+ test_expect_success "fsck knows unexpected object $oid is $type" '
git cat-file -t $oid >expect &&
echo $type >actual &&
test_cmp expect actual
diff --git a/tag.c b/tag.c
index 19453c2edbf..ad92cf89209 100644
--- a/tag.c
+++ b/tag.c
@@ -193,8 +193,9 @@ int parse_tag_buffer(struct repository *r, struct tag *item, const void *data, u
}
if (!item->tagged || strcmp(type_name(item->tagged->type), type)) {
- error(_("object %s is a %s, not a %s"), oid_to_hex(&oid),
- type_name(item->tagged->type), type);
+ if (item->tagged && item->tagged->parsed)
+ error(_("object %s is a %s, not a %s"), oid_to_hex(&oid),
+ type_name(item->tagged->type), type);
return error("bad tag pointer to %s in %s",
oid_to_hex(&oid),
oid_to_hex(&item->object.oid));
--
2.39.0.1153.g589e4efe9dc
next prev parent reply other threads:[~2022-12-30 1:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 16:39 [RFC][PATCH] object.c: use has_object() instead of repo_has_object_file() Kousik Sanagavarapu
2022-11-16 18:20 ` Jeff King
2022-11-16 21:14 ` Jonathan Tan
2022-11-17 22:37 ` [PATCH 0/2] fixing parse_object() check for type mismatch Jeff King
2022-11-17 22:37 ` [PATCH 1/2] parse_object(): drop extra "has" check before checking object type Jeff King
2022-11-17 22:41 ` [PATCH 2/2] parse_object(): check on-disk type of suspected blob Jeff King
2022-11-18 0:36 ` Ævar Arnfjörð Bjarmason
2022-11-21 19:21 ` Jeff King
2022-11-18 11:46 ` [PATCH 0/4] tag: don't misreport type of tagged objects in errors Ævar Arnfjörð Bjarmason
2022-11-18 11:46 ` [PATCH 1/4] object-file.c: free the "t.tag" in check_tag() Ævar Arnfjörð Bjarmason
2022-11-18 11:46 ` [PATCH 2/4] object tests: add test for unexpected objects in tags Ævar Arnfjörð Bjarmason
2022-11-18 11:46 ` [PATCH 3/4] tag: don't misreport type of tagged objects in errors Ævar Arnfjörð Bjarmason
2022-11-18 11:46 ` [PATCH 4/4] tag: don't emit potentially incorrect "object is a X, not a Y" Ævar Arnfjörð Bjarmason
2022-12-30 1:52 ` [PATCH v2 0/3] tag: don't misreport type of tagged objects in errors Ævar Arnfjörð Bjarmason
2022-12-30 1:52 ` [PATCH v2 1/3] object tests: add test for unexpected objects in tags Ævar Arnfjörð Bjarmason
2022-12-30 4:25 ` Junio C Hamano
2022-12-30 1:52 ` [PATCH v2 2/3] tag: don't misreport type of tagged objects in errors Ævar Arnfjörð Bjarmason
2022-12-30 6:07 ` Junio C Hamano
2022-12-30 1:52 ` Ævar Arnfjörð Bjarmason [this message]
2022-11-18 19:05 ` [PATCH 0/2] fixing parse_object() check for type mismatch Taylor Blau
2022-11-21 19:26 ` Jeff King
2022-11-22 0:05 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=patch-v2-3.3-2493988c41c-20221230T011725Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=five231003@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).