From: Jonathan Nieder <jrnieder@gmail.com>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: git@vger.kernel.org
Subject: Re: [WIP PATCH] revision-walk: --parent option to find children of a parent
Date: Thu, 30 Sep 2010 09:32:34 -0500 [thread overview]
Message-ID: <20100930143234.GH4850@burratino> (raw)
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"
?
> --- 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.
next prev parent reply other threads:[~2010-09-30 14:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-30 10:30 [WIP PATCH] revision-walk: --parent option to find children of a parent Michael J Gruber
2010-09-30 14:32 ` Jonathan Nieder [this message]
2010-09-30 15:12 ` Michael J Gruber
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=20100930143234.GH4850@burratino \
--to=jrnieder@gmail.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
/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).