git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Junio C Hamano
Message 9 of 9 in “Fix segfaults caused by invalid tags”
  1. Fix segfaults caused by invalid tagsPetr Baudis, Nov 2, 2005
  2. Johannes SchindelinNov 2, 2005
  3. Junio C HamanoNov 2, 2005
  4. Warn when calling deref_tag() on broken tagsPetr Baudis, Nov 2, 2005
  5. Johannes SchindelinNov 2, 2005
  6. Petr BaudisNov 2, 2005
  7. Junio C HamanoNov 2, 2005
  8. Junio C HamanoNov 2, 2005
  9. Petr BaudisNov 2, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.