Re: [PATCH 2/2] pack-refs: add fully-peeled trait
From: Jeff King <hidden>
Date: 2016-06-15 22:56:25
On Sat, Mar 16, 2013 at 03:06:22PM +0100, Michael Haggerty wrote:
quoted
refname = parse_ref_line(refline, sha1); if (refname) { - last = create_ref_entry(refname, sha1, flag, 1); + /* + * Older git did not write peel lines for anything + * outside of refs/tags/; if the fully-peeled trait + * is not set, we are dealing with such an older + * git and cannot assume an omitted peel value + * means the ref is not a tag object. + */ + int this_flag = flag; + if (!fully_peeled && prefixcmp(refname, "refs/tags/")) + this_flag &= ~REF_KNOWS_PEELED; + + last = create_ref_entry(refname, sha1, this_flag, 1); add_ref(dir, last); continue; }I have to admit that I am partial to my variant of this code [1] because the logic makes it clearer when the affirmative decision can be made to set the REF_KNOWS_PEELED flag. But this version also looks correct to me and equivalent (aside from the idea that a few lines later if a peeled value is found then the REF_KNOWS_PEELED bit could also be set).
Yeah, I think they are equivalent, but I agree yours is a little more readable. I'll switch it in my re-roll, and I will go ahead and set the REF_KNOWS_PEELED bit when we see a peel line. That code should not be triggered in general, but it is the sane thing for the reader to do, so it makes the code more obvious and readable. -Peff