git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCHv2 1/9] revlist.c: introduce --left/right-only for unsymmetric picking
Date: Mon,  7 Mar 2011 13:31:35 +0100	[thread overview]
Message-ID: <60adf7d73e44126289a98dada60f9c335ffc84b0.1299499429.git.git@drmicha.warpmail.net> (raw)
In-Reply-To: <cover.1299499429.git.git@drmicha.warpmail.net>

The existing "--cherry-pick" does not work with unsymmetric ranges
(A..B) for obvious reasons.

Introduce "--left-only" and "--right-only" which limit the output to
commits on the respective sides of a symmetric range (i.e. only "<"
resp. ">" commits as per "--left-right").

This is especially useful for things like

    git log --cherry-pick --right-only @{u}...

which is much more flexible (and descriptive) than

    git cherry @{u} | sed -ne 's/^+ //p'

and potentially more useful than

    git log --cherry-pick @{u}...

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 revision.c |   24 ++++++++++++++++++++++++
 revision.h |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/revision.c b/revision.c
index 7b9eaef..0681c7c 100644
--- a/revision.c
+++ b/revision.c
@@ -733,6 +733,23 @@ static struct commit_list *collect_bottom_commits(struct commit_list *list)
 	return bottom;
 }
 
+/* Assumes either left_only or right_only is set */
+static void limit_left_right(struct commit_list *list, struct rev_info *revs)
+{
+	struct commit_list *p;
+
+	for (p = list; p; p = p->next) {
+		struct commit *commit = p->item;
+
+		if (revs->right_only) {
+			if (commit->object.flags & SYMMETRIC_LEFT)
+				commit->object.flags |= SHOWN;
+		} else	/* revs->left_only is set */
+			if (!(commit->object.flags & SYMMETRIC_LEFT))
+				commit->object.flags |= SHOWN;
+	}
+}
+
 static int limit_list(struct rev_info *revs)
 {
 	int slop = SLOP;
@@ -788,6 +805,9 @@ static int limit_list(struct rev_info *revs)
 	if (revs->cherry_pick)
 		cherry_pick_list(newlist, revs);
 
+	if (revs->left_only || revs->right_only)
+		limit_left_right(newlist, revs);
+
 	if (bottom) {
 		limit_to_ancestry(bottom, newlist);
 		free_commit_list(bottom);
@@ -1263,6 +1283,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 		revs->boundary = 1;
 	} else if (!strcmp(arg, "--left-right")) {
 		revs->left_right = 1;
+	} else if (!strcmp(arg, "--left-only")) {
+		revs->left_only = 1;
+	} else if (!strcmp(arg, "--right-only")) {
+		revs->right_only = 1;
 	} else if (!strcmp(arg, "--count")) {
 		revs->count = 1;
 	} else if (!strcmp(arg, "--cherry-pick")) {
diff --git a/revision.h b/revision.h
index 05659c6..d2ffde1 100644
--- a/revision.h
+++ b/revision.h
@@ -59,6 +59,8 @@ struct rev_info {
 			boundary:2,
 			count:1,
 			left_right:1,
+			left_only:1,
+			right_only:1,
 			rewrite_parents:1,
 			print_parents:1,
 			show_source:1,
-- 
1.7.4.1.299.g567d7.dirty

  reply	other threads:[~2011-03-07 12:35 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-07 12:31 [PATCHv2 0/9] --left/right-only and --cherry-mark Michael J Gruber
2011-03-07 12:31 ` Michael J Gruber [this message]
2011-03-07 12:31 ` [PATCHv2 2/9] t6007: Make sure we test --cherry-pick Michael J Gruber
2011-03-07 12:31 ` [PATCHv2 3/9] rev-list: documentation and test for --left/right-only Michael J Gruber
2011-03-07 12:31 ` [PATCHv2 4/9] rev-list: --left/right-only are mutually exclusive Michael J Gruber
2011-03-07 12:31 ` [PATCHv2 5/9] rev-list/log: factor out revision mark generation Michael J Gruber
2011-03-07 12:31 ` [PATCHv2 6/9] revision.c: introduce --cherry-mark Michael J Gruber
2011-03-09 21:29   ` Junio C Hamano
2011-03-10  8:23     ` [PATCHv2+ " Michael J Gruber
2011-03-07 12:31 ` [PATCHv2 7/9] rev-list: documentation and test for --cherry-mark Michael J Gruber
2011-03-07 12:31 ` [PATCHv2 8/9] log --cherry: a synonym Michael J Gruber
2011-03-07 12:31 ` [PATCHv2 9/9] t6007: test rev-list --cherry Michael J Gruber
2011-03-09 21:49 ` [PATCHv2 0/9] --left/right-only and --cherry-mark Junio C Hamano
2011-03-10  8:08   ` Michael J Gruber
2011-03-10  9:56     ` Junio C Hamano
2011-03-10 10:48       ` Michael J Gruber
2011-03-10 14:44         ` [PATCHv3 00/10] " Michael J Gruber
2011-03-10 14:44           ` [PATCHv3 01/10] revlist.c: introduce --left/right-only for unsymmetric picking Michael J Gruber
2011-03-10 14:44           ` [PATCHv3 02/10] t6007: Make sure we test --cherry-pick Michael J Gruber
2011-03-10 14:44           ` [PATCHv3 03/10] rev-list: documentation and test for --left/right-only Michael J Gruber
2011-03-10 14:44           ` [PATCHv3 04/10] rev-list: --left/right-only are mutually exclusive Michael J Gruber
2011-03-10 14:44           ` [PATCHv3 05/10] rev-list/log: factor out revision mark generation Michael J Gruber
2011-03-10 14:44           ` [PATCHv3 06/10] revision.c: introduce --cherry-mark Michael J Gruber
2011-03-10 14:45           ` [PATCHv3 07/10] rev-list: documentation and test for --cherry-mark Michael J Gruber
2011-03-10 14:45           ` [PATCHv3 08/10] log --cherry: a synonym Michael J Gruber
2011-03-10 14:45           ` [PATCHv3 09/10] t6007: test rev-list --cherry Michael J Gruber
2011-03-10 14:45           ` [PATCHv3 10/10] git-log: put space after commit mark Michael J Gruber
2011-03-10 18:22         ` [PATCHv2 0/9] --left/right-only and --cherry-mark Junio C Hamano
2011-03-11  7:52           ` Michael J Gruber
2011-03-11  8:02             ` Junio C Hamano

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=60adf7d73e44126289a98dada60f9c335ffc84b0.1299499429.git.git@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).