git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 30, 2010, 14:32 UTC
Message-ID
<20100930143234.GH4850@burratino>
In-Reply-To
<99aa4cd5a60b2b2d3eae962acb8a49c2a62a8f77.1285842569.git.git@drmicha.warpmail.net>
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"
?
 
Show 7 quoted lines
> --- 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?
Show 12 quoted lines
> @@ -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.
Previous: Michael J GruberNext: Michael J Gruber
Message 2 of 3 in “revision-walk: --parent option to find children of a parent”
  1. revision-walk: --parent option to find children of a parentMichael J Gruber, Sep 30, 2010
  2. Jonathan NiederSep 30, 2010
  3. Michael J GruberSep 30, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.