diff options
author | Markus Heidelberg <markus.heidelberg@web.de> | 2008-12-29 18:45:20 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-01-01 04:40:16 -0800 |
commit | f29680221124d05581dd2db52a4e7f0fa15fa929 (patch) | |
tree | 823b5395a4e0dc001aa81d60d548a71777acf1a7 /builtin-log.c | |
parent | 8104ebfe8276657ee803cca7eb8665a78cf3ef83 (diff) | |
download | git-f29680221124d05581dd2db52a4e7f0fa15fa929.tar.gz |
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.
Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-log.c')
-rw-r--r-- | builtin-log.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/builtin-log.c b/builtin-log.c index 99d1137b08..243f8573e4 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -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); |