{"thread":{"id":"16912","subject":"[PATCH] git-cherry: make <upstream> parameter optional","startedAt":"2008-12-29T17:45:20Z","lastAt":"2009-01-01T21:56:29Z","messageCount":7,"participants":["Markus Heidelberg","Johannes Schindelin","demerphq","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"98905","messageId":"200812291845.20500.markus.heidelberg@web.de","threadId":"16912","inReplyTo":null,"subject":"[PATCH] git-cherry: make <upstream> parameter optional","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2008-12-29T17:45:20Z","receivedAt":"2008-12-29T17:45:20Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"The upstream branch <upstream> now defaults to the first tracked\nremote branch, which is set by the configuration variables\nbranch.<name>.remote and branch.<name>.merge of the current branch.\n\nWithout such a remote branch, the command \"git cherry [-v]\" fails with\nusage output as before and an additional message.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n\nI'm not sure, whether the usage output would be still necessary.\n\n Documentation/git-cherry.txt |    3 ++-\n builtin-log.c                |   16 ++++++++++++++--\n 2 files changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt\nindex 74d14c4..556ea23 100644\n--- a/Documentation/git-cherry.txt\n+++ b/Documentation/git-cherry.txt\n@@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream\n \n SYNOPSIS\n --------\n-'git cherry' [-v] <upstream> [<head>] [<limit>]\n+'git cherry' [-v] [<upstream>] [<head>] [<limit>]\n \n DESCRIPTION\n -----------\n@@ -51,6 +51,7 @@ OPTIONS\n \n <upstream>::\n \tUpstream branch to compare against.\n+\tDefaults to the first tracked remote branch, if available.\n \n <head>::\n \tWorking branch; defaults to HEAD.\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 99d1137..243f857 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -16,6 +16,7 @@\n #include \"patch-ids.h\"\n #include \"run-command.h\"\n #include \"shortlog.h\"\n+#include \"remote.h\"\n \n /* Set a default date-time format for git log (\"log.date\" config variable) */\n static const char *default_date_mode = NULL;\n@@ -1070,13 +1071,14 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)\n }\n \n static const char cherry_usage[] =\n-\"git cherry [-v] <upstream> [<head>] [<limit>]\";\n+\"git cherry [-v] [<upstream>] [<head>] [<limit>]\";\n int cmd_cherry(int argc, const char **argv, const char *prefix)\n {\n \tstruct rev_info revs;\n \tstruct patch_ids ids;\n \tstruct commit *commit;\n \tstruct commit_list *list = NULL;\n+\tstruct branch *current_branch;\n \tconst char *upstream;\n \tconst char *head = \"HEAD\";\n \tconst char *limit = NULL;\n@@ -1099,7 +1101,17 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \t\tupstream = argv[1];\n \t\tbreak;\n \tdefault:\n-\t\tusage(cherry_usage);\n+\t\tcurrent_branch = branch_get(NULL);\n+\t\tif (!current_branch || !current_branch->merge\n+\t\t\t\t\t|| !current_branch->merge[0]\n+\t\t\t\t\t|| !current_branch->merge[0]->dst) {\n+\t\t\tfprintf(stderr, \"Could not find a tracked\"\n+\t\t\t\t\t\" remote branch, please\"\n+\t\t\t\t\t\" specify <upstream> manually.\\n\");\n+\t\t\tusage(cherry_usage);\n+\t\t}\n+\n+\t\tupstream = current_branch->merge[0]->dst;\n \t}\n \n \tinit_revisions(&revs, prefix);\n-- \n1.6.1.35.ge4490\n"},{"id":"98970","messageId":"alpine.DEB.1.00.0812301411480.30769@pacific.mpi-cbg.de","threadId":"16912","inReplyTo":"200812291845.20500.markus.heidelberg@web.de","subject":"Re: [PATCH] git-cherry: make <upstream> parameter optional","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-12-30T13:13:00Z","receivedAt":"2008-12-30T13:13:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 29 Dec 2008, Markus Heidelberg wrote:\n\n> The upstream branch <upstream> now defaults to the first tracked\n> remote branch, which is set by the configuration variables\n> branch.<name>.remote and branch.<name>.merge of the current branch.\n> \n> Without such a remote branch, the command \"git cherry [-v]\" fails with\n> usage output as before and an additional message.\n> \n> Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n\nThis would be a massively visible user interface change.  At the moment, \nit does this (which I like):\n\n\t$ git cherry-pick\n\tusage: git cherry-pick [options] <commit-ish>\n\n\t    -n, --no-commit       don't automatically commit\n\t    -e, --edit            edit the commit message\n\t    -x                    append commit name when cherry-picking\n\t    -r                    no-op (backward compatibility)\n\t    -s, --signoff         add Signed-off-by:\n\t    -m, --mainline <n>    parent number\n\nOpposed,\nDscho\n"},{"id":"98971","messageId":"200812301437.06726.markus.heidelberg@web.de","threadId":"16912","inReplyTo":"alpine.DEB.1.00.0812301411480.30769@pacific.mpi-cbg.de","subject":"Re: [PATCH] git-cherry: make <upstream> parameter optional","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2008-12-30T13:37:06Z","receivedAt":"2008-12-30T13:37:06Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Johannes Schindelin, 30.12.2008:\n> Hi,\n> \n> On Mon, 29 Dec 2008, Markus Heidelberg wrote:\n> \n> > The upstream branch <upstream> now defaults to the first tracked\n> > remote branch, which is set by the configuration variables\n> > branch.<name>.remote and branch.<name>.merge of the current branch.\n> > \n> > Without such a remote branch, the command \"git cherry [-v]\" fails with\n> > usage output as before and an additional message.\n> > \n> > Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n> \n> This would be a massively visible user interface change.  At the moment, \n> it does this (which I like):\n> \n> \t$ git cherry-pick\n> \tusage: git cherry-pick [options] <commit-ish>\n> \n> \t    -n, --no-commit       don't automatically commit\n> \t    -e, --edit            edit the commit message\n> \t    -x                    append commit name when cherry-picking\n> \t    -r                    no-op (backward compatibility)\n> \t    -s, --signoff         add Signed-off-by:\n> \t    -m, --mainline <n>    parent number\n> \n> Opposed,\n> Dscho\n\nThe patch was about git-cherry, not git-cherry-pick.\n\nMarkus\n"},{"id":"98972","messageId":"alpine.DEB.1.00.0812301441510.30769@pacific.mpi-cbg.de","threadId":"16912","inReplyTo":"200812301437.06726.markus.heidelberg@web.de","subject":"Re: [PATCH] git-cherry: make <upstream> parameter optional","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-12-30T13:44:40Z","receivedAt":"2008-12-30T13:44:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 30 Dec 2008, Markus Heidelberg wrote:\n\n> Johannes Schindelin, 30.12.2008:\n> \n> > On Mon, 29 Dec 2008, Markus Heidelberg wrote:\n> > \n> > > The upstream branch <upstream> now defaults to the first tracked \n> > > remote branch, which is set by the configuration variables \n> > > branch.<name>.remote and branch.<name>.merge of the current branch.\n> > > \n> > > Without such a remote branch, the command \"git cherry [-v]\" fails \n> > > with usage output as before and an additional message.\n> > > \n> > > Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n> > \n> > This would be a massively visible user interface change.  At the moment, \n> > it does this (which I like):\n> > \n> > \t$ git cherry-pick\n> > \tusage: git cherry-pick [options] <commit-ish>\n> > \n> > \t    -n, --no-commit       don't automatically commit\n> > \t    -e, --edit            edit the commit message\n> > \t    -x                    append commit name when cherry-picking\n> > \t    -r                    no-op (backward compatibility)\n> > \t    -s, --signoff         add Signed-off-by:\n> > \t    -m, --mainline <n>    parent number\n> \n> The patch was about git-cherry, not git-cherry-pick.\n\nOops.\n\nSorry,\nDscho\n\nP.S.: This certainly will not be the last time that I am bitten by the \ncloseness of the names \"cherry\" (which I _never_ use) and \"cherry-pick\", \nwhich I use frequently.  Even worse: the rev-list option that could make \nthat stand-alone plumbing command \"cherry\" obsolete is called \n_--cherry-pick_, of all things...\n"},{"id":"98973","messageId":"9b18b3110812300602i3bed6ab0xc9fa7757bf7cf464@mail.gmail.com","threadId":"16912","inReplyTo":"200812291845.20500.markus.heidelberg@web.de","subject":"Re: [PATCH] git-cherry: make <upstream> parameter optional","fromName":"demerphq","fromEmail":"demerphq@gmail.com","sentAt":"2008-12-30T14:02:11Z","receivedAt":"2008-12-30T14:02:11Z","isPatch":true,"sender":{"key":"demerphq@gmail.com","avatar":null},"body":"2008/12/29 Markus Heidelberg <markus.heidelberg@web.de>:\n> The upstream branch <upstream> now defaults to the first tracked\n> remote branch, which is set by the configuration variables\n> branch.<name>.remote and branch.<name>.merge of the current branch.\n>\n> Without such a remote branch, the command \"git cherry [-v]\" fails with\n> usage output as before and an additional message.\n>\n> Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n\nFWIW: I would find this useful. Thanks for writing it.\n\nYves\n\n-- \nperl -Mre=debug -e \"/just|another|perl|hacker/\"\n"},{"id":"99107","messageId":"7vr63mivx3.fsf@gitster.siamese.dyndns.org","threadId":"16912","inReplyTo":"200812291845.20500.markus.heidelberg@web.de","subject":"Re: [PATCH] git-cherry: make <upstream> parameter optional","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-01T21:00:24Z","receivedAt":"2009-01-01T21:00:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Markus Heidelberg <markus.heidelberg@web.de> writes:\n\n> diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt\n> index 74d14c4..556ea23 100644\n> --- a/Documentation/git-cherry.txt\n> +++ b/Documentation/git-cherry.txt\n> @@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream\n>  \n>  SYNOPSIS\n>  --------\n> -'git cherry' [-v] <upstream> [<head>] [<limit>]\n> +'git cherry' [-v] [<upstream>] [<head>] [<limit>]\n\nShouldn't this be [<upstream> [<head> [<limit>]]]?\n"},{"id":"99117","messageId":"200901012256.29546.markus.heidelberg@web.de","threadId":"16912","inReplyTo":"7vr63mivx3.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-cherry: make <upstream> parameter optional","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-01-01T21:56:29Z","receivedAt":"2009-01-01T21:56:29Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"The upstream branch <upstream> now defaults to the first tracked\nremote branch, which is set by the configuration variables\nbranch.<name>.remote and branch.<name>.merge of the current branch.\n\nWithout such a remote branch, the command \"git cherry [-v]\" fails with\nusage output as before and an additional message.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n\nJunio C Hamano, 01.01.2009:\n> > -'git cherry' [-v] <upstream> [<head>] [<limit>]\n> > +'git cherry' [-v] [<upstream>] [<head>] [<limit>]\n> \n> Shouldn't this be [<upstream> [<head> [<limit>]]]?\n\nSure.\n\n\n Documentation/git-cherry.txt |    3 ++-\n builtin-log.c                |   16 ++++++++++++++--\n 2 files changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt\nindex 74d14c4..7deefda 100644\n--- a/Documentation/git-cherry.txt\n+++ b/Documentation/git-cherry.txt\n@@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream\n \n SYNOPSIS\n --------\n-'git cherry' [-v] <upstream> [<head>] [<limit>]\n+'git cherry' [-v] [<upstream> [<head> [<limit>]]]\n \n DESCRIPTION\n -----------\n@@ -51,6 +51,7 @@ OPTIONS\n \n <upstream>::\n \tUpstream branch to compare against.\n+\tDefaults to the first tracked remote branch, if available.\n \n <head>::\n \tWorking branch; defaults to HEAD.\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 99d1137..7e9616e 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -16,6 +16,7 @@\n #include \"patch-ids.h\"\n #include \"run-command.h\"\n #include \"shortlog.h\"\n+#include \"remote.h\"\n \n /* Set a default date-time format for git log (\"log.date\" config variable) */\n static const char *default_date_mode = NULL;\n@@ -1070,13 +1071,14 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)\n }\n \n static const char cherry_usage[] =\n-\"git cherry [-v] <upstream> [<head>] [<limit>]\";\n+\"git cherry [-v] [<upstream> [<head> [<limit>]]]\";\n int cmd_cherry(int argc, const char **argv, const char *prefix)\n {\n \tstruct rev_info revs;\n \tstruct patch_ids ids;\n \tstruct commit *commit;\n \tstruct commit_list *list = NULL;\n+\tstruct branch *current_branch;\n \tconst char *upstream;\n \tconst char *head = \"HEAD\";\n \tconst char *limit = NULL;\n@@ -1099,7 +1101,17 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \t\tupstream = argv[1];\n \t\tbreak;\n \tdefault:\n-\t\tusage(cherry_usage);\n+\t\tcurrent_branch = branch_get(NULL);\n+\t\tif (!current_branch || !current_branch->merge\n+\t\t\t\t\t|| !current_branch->merge[0]\n+\t\t\t\t\t|| !current_branch->merge[0]->dst) {\n+\t\t\tfprintf(stderr, \"Could not find a tracked\"\n+\t\t\t\t\t\" remote branch, please\"\n+\t\t\t\t\t\" specify <upstream> manually.\\n\");\n+\t\t\tusage(cherry_usage);\n+\t\t}\n+\n+\t\tupstream = current_branch->merge[0]->dst;\n \t}\n \n \tinit_revisions(&revs, prefix);\n-- \n1.6.1.35.ge4490\n"}]}