From: Jeff King <peff@peff.net>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 1/2] pack-refs: write peeled entry for non-tags
Date: Sun, 17 Mar 2013 02:02:28 -0400 [thread overview]
Message-ID: <20130317060228.GD16070@sigill.intra.peff.net> (raw)
In-Reply-To: <514478C0.6060008@alum.mit.edu>
On Sat, Mar 16, 2013 at 02:50:56PM +0100, Michael Haggerty wrote:
> > @@ -39,14 +40,13 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
> > return 0;
> >
> > fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
> > - if (is_tag_ref) {
> > - struct object *o = parse_object(sha1);
> > - if (o->type == OBJ_TAG) {
> > - o = deref_tag(o, path, 0);
> > - if (o)
> > - fprintf(cb->refs_file, "^%s\n",
> > - sha1_to_hex(o->sha1));
> > - }
> > +
> > + o = parse_object(sha1);
> > + if (o->type == OBJ_TAG) {
>
> You suggested that I add a test (o != NULL) at the equivalent place in
> my code (which was derived from this code). Granted, my code was
> explicitly intending to pass invalid SHA1 values to parse_object(). But
> wouldn't it be a good defensive step to add the same check here?
Hmm, yeah. That is not new code, but rather just reindented from above
("diff -w" makes it much more obvious what is going on).
It is probably worth dying rather than segfaulting, though it should be
a separate patch (and I do not think it is sane to do anything except
die here). I almost wonder if parse_object should die by default on
bogus or missing objects, and the few callers who really want to handle
the error can call parse_object_gently. I do not relish analyzing each
caller, though. It would be simpler to add parse_object_or_die.
> > +# This matches show-ref's output
> > +print_ref() {
> > + echo "`git rev-parse "$1"` $1"
> > +}
> > +
>
> CodingGuidelines prefers $() over ``.
Old habits die hard. :)
I'll re-roll with your suggestions in a moment.
-Peff
next prev parent reply other threads:[~2013-03-17 6:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-16 9:00 [PATCH 0/2] peel-ref optimization fixes Jeff King
2013-03-16 9:01 ` [PATCH 1/2] pack-refs: write peeled entry for non-tags Jeff King
2013-03-16 13:50 ` Michael Haggerty
2013-03-17 6:02 ` Jeff King [this message]
2013-03-16 9:01 ` [PATCH 2/2] pack-refs: add fully-peeled trait Jeff King
2013-03-16 14:06 ` Michael Haggerty
2013-03-17 6:04 ` Jeff King
2013-03-17 5:50 ` Junio C Hamano
2013-03-17 5:55 ` Jeff King
2013-03-17 8:21 ` [PATCH v2 0/4] peel-ref optimization fixes Jeff King
2013-03-17 8:22 ` [PATCH v2 1/4] avoid segfaults on parse_object failure Jeff King
2013-03-17 8:23 ` [PATCH v2 2/4] use parse_object_or_die instead of die("bad object") Jeff King
2013-03-17 8:23 ` [PATCH v2 3/4] pack-refs: write peeled entry for non-tags Jeff King
2013-03-17 8:28 ` [PATCH v2 4/4] pack-refs: add fully-peeled trait Jeff King
2013-03-17 20:01 ` Junio C Hamano
2013-03-18 11:37 ` [PATCH v3 " Jeff King
2013-03-18 16:26 ` Junio C Hamano
2013-03-18 3:12 ` [PATCH v2 " Michael Haggerty
2013-03-18 15:12 ` Junio C Hamano
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=20130317060228.GD16070@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
/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).