Re: [PATCH v6 4/5] builtin/stash: provide a way to export stashes to a ref

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2025-05-22 at 20:51:20, Junio C Hamano wrote:
> "brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes:
> 
> > +static int check_stash_topology(struct repository *r, struct commit *stash)
> > +{
> > +	struct commit *p1, *p2, *p3 = NULL;
> > +
> > +	/* stash must have two or three parents */
> > +	if (!stash->parents || !stash->parents->next ||
> > +			(stash->parents->next->next && stash->parents->next->next->next))
> > +		return -1;
> > +	p1 = stash->parents->item;
> > +	p2 = stash->parents->next->item;
> > +	if (stash->parents->next->next)
> > +		p3 = stash->parents->next->next->item;
> > +	if (repo_parse_commit(r, p1) || repo_parse_commit(r, p2) ||
> > +			(p3 && repo_parse_commit(r, p3)))
> > +		return -1;
> > +	/* p2 must have a single parent, p3 must have no parents */
> > +	if (!p2->parents || p2->parents->next || (p3 && p3->parents))
> > +		return -1;
> > +	if (repo_parse_commit(r, p2->parents->item))
> > +		return -1;
> > +	/* p2^1 must equal p1 */
> > +	if (!oideq(&p1->object.oid, &p2->parents->item->object.oid))
> > +		return -1;
> > +
> > +	return 0;
> > +}
> 
> This is much more elaborate than the existing "does this commit look
> like a stash entry" test done elsewhere, isn't it?  Very nicely done.

This is Phillip Wood's code, but yes, it is very nice.  I looked at the
patch he provided and it seemed very sensible, so I adopted it.

> Hmph.  As we work with the commit objects in the above part already,
> would it still make sense to use an oid array?  That would force us
> to look up the same set of commits using the object names again in
> the later loop.  I would have thought we might use commit_list or
> something to accumulate commits, and then consume in the loop below.

I can do that in v7.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux