Skip to content

Commit

Permalink
Merge branch 'mh/cherry-default'
Browse files Browse the repository at this point in the history
* mh/cherry-default:
  Documentation: clarify which parameters are optional to git-cherry
  git-cherry: make <upstream> parameter optional
  • Loading branch information
Junio C Hamano committed Jan 14, 2009
2 parents 3ea95d2 + 3bc52d7 commit 7a4566b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Documentation/git-cherry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 14 additions & 2 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1061,13 +1062,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;
Expand All @@ -1090,7 +1092,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);
Expand Down

0 comments on commit 7a4566b

Please sign in to comment.