Re: [PATCH] Warn when calling deref_tag() on broken tags
- From
Petr Baudis <pasky@suse.cz>
- Date
- Nov 2, 2005, 23:42 UTC
- Message-ID
- <20051102234232.GG1431@pasky.or.cz>
- In-Reply-To
- <7vhdauocv6.fsf@assigned-by-dhcp.cox.net>
Dear diary, on Thu, Nov 03, 2005 at 12:21:01AM CET, I got a letter where Junio C Hamano <junkio@cox.net> told me that...
Show 9 quoted lines
> Petr Baudis <pasky@suse.cz> writes: > > > Good idea. Not that I would be excited by the awing elegancy of the > > patch... > > It turns out to be not so good idea. Some places call deref_tag > just to see if we can unwrap it but not having the referenced > object but having the tag object does not necessarily mean a > corrupt repository.
Aha, that didn't occur to me initially. Yes, what you did is fine by me (not that I would be overly proficient in this part of code).
Show 21 quoted lines
> diff --git a/tag.c b/tag.c
> index b1ab75f..e574c4b 100644
> --- a/tag.c
> +++ b/tag.c
> @@ -3,10 +3,15 @@
>
> const char *tag_type = "tag";
>
> -struct object *deref_tag(struct object *o)
> +struct object *deref_tag(struct object *o, const char *warn, int warnlen)
> {
> while (o && o->type == tag_type)
> o = parse_object(((struct tag *)o)->tagged->sha1);
> + if (!o && warn) {
> + if (!warnlen)
> + warnlen = strlen(warn);
> + error("missing object referenced by '%.*s'", warnlen, warn);
> + }
> return o;
> }
> It should still be a warning, not an error, though. I'd also mention the "tag" keyword in the message.
-- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ VI has two modes: the one in which it beeps and the one in which it doesn't.