Re: [WIP PATCH] revision-walk: --parent option to find children of a parent

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

 



Hi,

Michael J Gruber wrote:

> Introduce a new --parent=<commit> option for the revision walker which
> limits the commits to those which have <commit> as one of their parents.

So this lists the direct children for a given commit.  Could you
mention a use case?  Why would one want to use this instead of

 the_commit=$(git rev-parse --verify <commit>) &&
 git rev-list --parents ... ^<commit> |
 grep -F " $the_commit"

?
 
> --- a/revision.c
> +++ b/revision.c
> @@ -1149,6 +1149,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
>  {
>  	const char *arg = argv[0];
>  	const char *optarg;
> +	unsigned char sha1[20];

Could this be given narrower scope?

> @@ -1989,6 +1999,14 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi
>  		return commit_ignore;
>  	if (revs->merges_only && !(commit->parents && commit->parents->next))
>  		return commit_ignore;
> +	if (revs->parent_list) {
> +		struct commit_list *a, *b;
> +		for (b = revs->parent_list; b; b = b->next)
> +			for (a = commit->parents; a; a = a->next)
> +				if (!hashcmp(b->item->object.sha1, a->item->object.sha1))
> +					return commit_show;
> +		return commit_ignore;
> +	}

The implementation looks good.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]