git-cherry: make <upstream> parameter optional
PATCH 1/1 git-cherry: make <upstream> parameter optional
The upstream branch <upstream> now defaults to the first tracked remote branch, which is set by the configuration variables branch.<name>.remote and branch.<name>.merge of the current branch.
Without such a remote branch, the command "git cherry [-v]" fails with usage output as before and an additional message.
---
I'm not sure, whether the usage output would be still necessary.
Documentation/git-cherry.txt | 3 ++- builtin-log.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
Documentation/git-cherry.txt +2 -1
@@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream SYNOPSIS -------- -'git cherry' [-v] <upstream> [<head>] [<limit>] +'git cherry' [-v] [<upstream>] [<head>] [<limit>] DESCRIPTION -----------
@@ -51,6 +51,7 @@ OPTIONS <upstream>:: Upstream branch to compare against. + Defaults to the first tracked remote branch, if available. <head>:: Working branch; defaults to HEAD.
builtin-log.c +14 -2
@@ -16,6 +16,7 @@#include "patch-ids.h" #include "run-command.h" #include "shortlog.h" +#include "remote.h" /* Set a default date-time format for git log ("log.date" config variable) */ static const char *default_date_mode =NULL ;
@@ -1070,13 +1071,14 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags) }static const char cherry_usage[] = -"git cherry [-v] <upstream> [<head>] [<limit>]" ; +"git cherry [-v] [<upstream>] [<head>] [<limit>]" ;int cmd_cherry (int argc,const char **argv,const char *prefix) {struct rev_info revs;struct patch_ids ids;struct commit *commit;struct commit_list *list =NULL ; +struct branch *current_branch;const char *upstream;const char *head ="HEAD" ;const char *limit =NULL ;
@@ -1099,7 +1101,17 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) upstream = argv[1 ];break ;default : -usage (cherry_usage); + current_branch =branch_get (NULL ); +if (!current_branch || !current_branch->merge + || !current_branch->merge[0 ] + || !current_branch->merge[0 ]->dst) { +fprintf (stderr,"Could not find a tracked" +" remote branch, please" +" specify <upstream> manually.\n" ); +usage (cherry_usage); + } + + upstream = current_branch->merge[0 ]->dst; }init_revisions (&revs, prefix);
Signature · 1 line
1.6.1.35.ge4490
2008/12/29 Markus Heidelberg <[email protected]>:
Quoted 8 lines
The upstream branch <upstream> now defaults to the first tracked remote branch, which is set by the configuration variables branch.<name>.remote and branch.<name>.merge of the current branch.
Without such a remote branch, the command "git cherry [-v]" fails with usage output as before and an additional message.
Signed-off-by Markus Heidelberg <[email protected]>
FWIW: I would find this useful. Thanks for writing it.
Yves
Signature · 1 line
perl -Mre=debug -e "/just|another|perl|hacker/"
Hi,
Quoted 8 lines · Markus Heidelberg
The upstream branch <upstream> now defaults to the first tracked remote branch, which is set by the configuration variables branch.<name>.remote and branch.<name>.merge of the current branch.
Without such a remote branch, the command "git cherry [-v]" fails with usage output as before and an additional message.
Signed-off-by Markus Heidelberg <[email protected]>
This would be a massively visible user interface change. At the moment, it does this (which I like):
$ git cherry-pick usage: git cherry-pick [options] <commit-ish>
-n, --no-commit don't automatically commit -e, --edit edit the commit message -x append commit name when cherry-picking -r no-op (backward compatibility) -s, --signoff add Signed-off-by: -m, --mainline <n> parent number
Opposed,
Dscho
Johannes Schindelin, 30.12.2008:
Quoted 26 lines
Hi,
Quoted 8 lines · Markus Heidelberg
The upstream branch <upstream> now defaults to the first tracked remote branch, which is set by the configuration variables branch.<name>.remote and branch.<name>.merge of the current branch.
Without such a remote branch, the command "git cherry [-v]" fails with usage output as before and an additional message.
Signed-off-by Markus Heidelberg <[email protected]>This would be a massively visible user interface change. At the moment, it does this (which I like):
$ git cherry-pick usage: git cherry-pick [options] <commit-ish>-n, --no-commit don't automatically commit -e, --edit edit the commit message -x append commit name when cherry-picking -r no-op (backward compatibility) -s, --signoff add Signed-off-by: -m, --mainline <n> parent number
Quoted 2 lines
Opposed,
Dscho
The patch was about git-cherry, not git-cherry-pick.
Markus
Hi,
Quoted 19 lines · Markus Heidelberg
Johannes Schindelin, 30.12.2008:
Quoted 17 lines · Markus Heidelberg
Quoted 9 lines
The upstream branch <upstream> now defaults to the first tracked remote branch, which is set by the configuration variables branch.<name>.remote and branch.<name>.merge of the current branch.
Without such a remote branch, the command "git cherry [-v]" fails with usage output as before and an additional message.
Signed-off-by Markus Heidelberg <[email protected]>This would be a massively visible user interface change. At the moment, it does this (which I like):
$ git cherry-pick usage: git cherry-pick [options] <commit-ish>
Quoted 8 lines
Quoted 6 lines
-n, --no-commit don't automatically commit -e, --edit edit the commit message -x append commit name when cherry-picking -r no-op (backward compatibility) -s, --signoff add Signed-off-by: -m, --mainline <n> parent numberThe patch was about git-cherry, not git-cherry-pick.
Oops.
Sorry,
Dscho
P.S.: This certainly will not be the last time that I am bitten by the closeness of the names "cherry" (which I _never_ use) and "cherry-pick", which I use frequently. Even worse: the rev-list option that could make that stand-alone plumbing command "cherry" obsolete is called _--cherry-pick_, of all things...
Documentation/git-cherry.txt git-cherry - Find commits not merged upstream · line 10
Quoted 10 lines · Markus Heidelberg
Documentation/git-cherry.txt +1
-1@@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream SYNOPSIS -------- -'git cherry' [-v] <upstream> [<head>] [<limit>] +'git cherry' [-v] [<upstream>] [<head>] [<limit>]
Shouldn't this be [<upstream> [<head> [<limit>]]]?
The upstream branch <upstream> now defaults to the first tracked remote branch, which is set by the configuration variables branch.<name>.remote and branch.<name>.merge of the current branch.
Without such a remote branch, the command "git cherry [-v]" fails with usage output as before and an additional message.
---
Junio C Hamano, 01.01.2009:
Quoted 4 lines
Quoted 2 lines
-'git cherry' [-v] <upstream> [<head>] [<limit>] +'git cherry' [-v] [<upstream>] [<head>] [<limit>]
Shouldn't this be [<upstream> [<head> [<limit>]]]?
Sure.
Documentation/git-cherry.txt | 3 ++- builtin-log.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-)
Documentation/git-cherry.txt +2 -1
@@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream SYNOPSIS -------- -'git cherry' [-v] <upstream> [<head>] [<limit>] +'git cherry' [-v] [<upstream> [<head> [<limit>]]] DESCRIPTION -----------
@@ -51,6 +51,7 @@ OPTIONS <upstream>:: Upstream branch to compare against. + Defaults to the first tracked remote branch, if available. <head>:: Working branch; defaults to HEAD.
builtin-log.c +14 -2
@@ -16,6 +16,7 @@#include "patch-ids.h" #include "run-command.h" #include "shortlog.h" +#include "remote.h" /* Set a default date-time format for git log ("log.date" config variable) */ static const char *default_date_mode =NULL ;
@@ -1070,13 +1071,14 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags) }static const char cherry_usage[] = -"git cherry [-v] <upstream> [<head>] [<limit>]" ; +"git cherry [-v] [<upstream> [<head> [<limit>]]]" ;int cmd_cherry (int argc,const char **argv,const char *prefix) {struct rev_info revs;struct patch_ids ids;struct commit *commit;struct commit_list *list =NULL ; +struct branch *current_branch;const char *upstream;const char *head ="HEAD" ;const char *limit =NULL ;
@@ -1099,7 +1101,17 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) upstream = argv[1 ];break ;default : -usage (cherry_usage); + current_branch =branch_get (NULL ); +if (!current_branch || !current_branch->merge + || !current_branch->merge[0 ] + || !current_branch->merge[0 ]->dst) { +fprintf (stderr,"Could not find a tracked" +" remote branch, please" +" specify <upstream> manually.\n" ); +usage (cherry_usage); + } + + upstream = current_branch->merge[0 ]->dst; }init_revisions (&revs, prefix);
Signature · 1 line
1.6.1.35.ge4490