From 59c8afdf475d2b072fb63383df9f62afd2b3b1ee Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Mon, 21 Feb 2011 17:09:12 +0100 Subject: rev-list: documentation and test for --left/right-only Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- Documentation/rev-list-options.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Documentation/rev-list-options.txt') diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 44a2ef1de1..cebba62239 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -319,6 +319,19 @@ from the other branch (for example, "3rd on b" may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output. +--left-only:: +--right-only:: + + List only commits on the respective side of a symmetric range, + i.e. only those which would be marked `<` resp. `>` by + `--left-right`. ++ +For example, `--cherry-pick --right-only A...B` omits those +commits from `B` which are in `A` or are patch-equivalent to a commit in +`A`. In other words, this lists the `{plus}` commits from `git cherry A B`. +More precisely, `--cherry-pick --right-only --no-merges` gives the exact +list. + -g:: --walk-reflogs:: -- cgit v1.2.3 From cb56e3093a1b25e105df44640e2224c8f6e6b893 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Mon, 7 Mar 2011 13:31:41 +0100 Subject: rev-list: documentation and test for --cherry-mark Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 1 + Documentation/rev-list-options.txt | 5 +++++ t/t6007-rev-list-cherry-pick-file.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) (limited to 'Documentation/rev-list-options.txt') diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 5f47a13d3c..8a891ca68d 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -33,6 +33,7 @@ SYNOPSIS [ \--left-right ] [ \--left-only ] [ \--right-only ] + [ \--cherry-mark ] [ \--cherry-pick ] [ \--encoding[=] ] [ \--(author|committer|grep)= ] diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index cebba62239..4755b83d2d 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -305,6 +305,11 @@ ifdef::git-rev-list[] to /dev/null as the output does not have to be formatted. endif::git-rev-list[] +--cherry-mark:: + + Like `--cherry-pick` (see below) but mark equivalent commits + with `=` rather than omitting them, and inequivalent ones with `+`. + --cherry-pick:: Omit any commit that introduces the same change as diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index cd089a913b..37bd25eaaa 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -99,6 +99,34 @@ test_expect_success '--cherry-pick bar does not come up empty (II)' ' test_cmp actual.named expect ' +cat >expect < actual && + git name-rev --stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp actual.named expect +' + +cat >expect <tags/E +=tags/C +EOF + +test_expect_success '--cherry-mark --left-right' ' + git rev-list --cherry-mark --left-right F...E -- bar > actual && + git name-rev --stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp actual.named expect +' + cat >expect < Date: Mon, 7 Mar 2011 13:31:42 +0100 Subject: log --cherry: a synonym At the porcelain level, because by definition there are many more contributors than integrators, it makes sense to give a handy short-hand for --right-only used with --cherry-mark and --no-merges. Make it so. In other words, this provides "git cherry with rev-list interface". Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- Documentation/rev-list-options.txt | 8 ++++++++ revision.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'Documentation/rev-list-options.txt') diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 4755b83d2d..95d209c11d 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -337,6 +337,14 @@ commits from `B` which are in `A` or are patch-equivalent to a commit in More precisely, `--cherry-pick --right-only --no-merges` gives the exact list. +--cherry:: + + A synonym for `--right-only --cherry-mark --no-merges`; useful to + limit the output to the commits on our side and mark those that + have been applied to the other side of a forked history with + `git log --cherry upstream...mybranch`, similar to + `git cherry upstream mybranch`. + -g:: --walk-reflogs:: diff --git a/revision.c b/revision.c index 36022a6f6b..51372f650a 100644 --- a/revision.c +++ b/revision.c @@ -1289,12 +1289,20 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->left_right = 1; } else if (!strcmp(arg, "--left-only")) { if (revs->right_only) - die("--left-only is incompatible with --right-only"); + die("--left-only is incompatible with --right-only" + " or --cherry"); revs->left_only = 1; } else if (!strcmp(arg, "--right-only")) { if (revs->left_only) die("--right-only is incompatible with --left-only"); revs->right_only = 1; + } else if (!strcmp(arg, "--cherry")) { + if (revs->left_only) + die("--cherry is incompatible with --left-only"); + revs->cherry_mark = 1; + revs->right_only = 1; + revs->no_merges = 1; + revs->limited = 1; } else if (!strcmp(arg, "--count")) { revs->count = 1; } else if (!strcmp(arg, "--cherry-mark")) { -- cgit v1.2.3