{"thread":{"id":"26521","subject":"[PATHC/RFC] revlist.c: introduce --cherry for unsymmetric picking","startedAt":"2011-02-16T10:59:33Z","lastAt":"2011-02-16T10:59:33Z","messageCount":1,"participants":["Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"161295","messageId":"15a90a6606cff7d823fe4afbedd580aadf7b1d1e.1297853883.git.git@drmicha.warpmail.net","threadId":"26521","inReplyTo":null,"subject":"[PATHC/RFC] revlist.c: introduce --cherry for unsymmetric picking","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-02-16T10:59:33Z","receivedAt":"2011-02-16T10:59:33Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"The existing \"--cherry-pick\" does not work with unsymmetric ranges\n(A..B) for obvious reasons.\n\nIntroduce \"--cherry\" which works more like \"git-cherry\", i.e.: Ignore\ncommits in B which are patch-equivalent to patches in A, i.e. list only\nthose which \"git cherry B A\" would list with a \"-\". This is especially\nuseful for things like\n\ngit log --cherry @{u}..\n\nwhich is a much more descriptive than\n\ngit cherry @{u}\n\nand potentially more useful than\n\ngit log --cherry-pick @{u}...\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nRFC for lack of doc and tests, and also:\n\nI first considered \"--cherry-pick A..B\" to automatically invoke this mode.\nHere are a few reasons why I didn't:\n\n- I haven't found a better way to propagate \"we have a fake symmetric\nrange\" from handle_revision_arg() to cherry_pick_list(). Flags like\nSHOWN or TMP_MARK are reset somewhere in between! A global wouldn't do a\nbetter (more fine grained) job than the rev flag.\n\n- In the case of multiple revision args, it's probably less confusing to\nhave one overall mode (think \"--cherry-pick A...B C..D\") than the added\nflexibility.\n\n- I don't like the name \"--cherry-pick\" for an option which is like \"git\ncherry\" and unlike \"git cherry-pick\".\n\n- We could still activate this mode as soon as one A..B range apears.\n\n revision.c |   17 +++++++++++++++--\n revision.h |    1 +\n 2 files changed, 16 insertions(+), 2 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 86d2470..91d27ea 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -611,6 +611,16 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)\n \t}\n \n \tfree_patch_ids(&ids);\n+\n+\tif (!revs->cherry)\n+\t\treturn;\n+\t/* Remove auxiliary commits */\n+\tfor (p = list; p; p = p->next) {\n+\t\tstruct commit *commit = p->item;\n+\n+\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n+\t\t\tcommit->object.flags |= SHOWN;\n+\t}\n }\n \n /* How many extra uninteresting commits we want to see.. */\n@@ -781,7 +791,7 @@ static int limit_list(struct rev_info *revs)\n \t\tshow(revs, newlist);\n \t\tshow_early_output = NULL;\n \t}\n-\tif (revs->cherry_pick)\n+\tif (revs->cherry || revs->cherry_pick)\n \t\tcherry_pick_list(newlist, revs);\n \n \tif (bottom) {\n@@ -1028,7 +1038,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,\n \t\t\t\tverify_non_filename(revs->prefix, arg);\n \t\t\t}\n \n-\t\t\tif (symmetric) {\n+\t\t\tif (symmetric || revs->cherry) {\n \t\t\t\texclude = get_merge_bases(a, b, 1);\n \t\t\t\tadd_pending_commit_list(revs, exclude,\n \t\t\t\t\t\t\tflags_exclude);\n@@ -1265,6 +1275,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t} else if (!strcmp(arg, \"--cherry-pick\")) {\n \t\trevs->cherry_pick = 1;\n \t\trevs->limited = 1;\n+\t} else if (!strcmp(arg, \"--cherry\")) {\n+\t\trevs->cherry = 1;\n+\t\trevs->limited = 1;\n \t} else if (!strcmp(arg, \"--objects\")) {\n \t\trevs->tag_objects = 1;\n \t\trevs->tree_objects = 1;\ndiff --git a/revision.h b/revision.h\nindex 82509dd..9a01050 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -65,6 +65,7 @@ struct rev_info {\n \t\t\tshow_decorations:1,\n \t\t\treverse:1,\n \t\t\treverse_output_stage:1,\n+\t\t\tcherry:1,\n \t\t\tcherry_pick:1,\n \t\t\tbisect:1,\n \t\t\tancestry_path:1,\n-- \n1.7.4.1.74.gf39475.dirty\n"}]}