git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@suse.cz>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Warn when calling deref_tag() on broken tags
Date: Thu, 3 Nov 2005 00:42:32 +0100	[thread overview]
Message-ID: <20051102234232.GG1431@pasky.or.cz> (raw)
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...
> 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).

> 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.

      reply	other threads:[~2005-11-02 23:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-02 20:07 [PATCH] Fix segfaults caused by invalid tags Petr Baudis
2005-11-02 20:16 ` Johannes Schindelin
2005-11-02 20:28   ` Junio C Hamano
2005-11-02 20:41   ` [PATCH] Warn when calling deref_tag() on broken tags Petr Baudis
2005-11-02 20:47     ` Johannes Schindelin
2005-11-02 20:50       ` Petr Baudis
2005-11-02 21:18     ` Junio C Hamano
2005-11-02 23:21     ` Junio C Hamano
2005-11-02 23:42       ` Petr Baudis [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051102234232.GG1431@pasky.or.cz \
    --to=pasky@suse.cz \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.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.
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 NNTP newsgroup(s).