Merge branch 'mh/cherry-default'
* mh/cherry-default: Documentation: clarify which parameters are optional to git-cherry git-cherry: make <upstream> parameter optional
This commit is contained in:
commit
7a4566befe
@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream
|
|||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
'git cherry' [-v] <upstream> [<head>] [<limit>]
|
'git cherry' [-v] [<upstream> [<head> [<limit>]]]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@ -51,6 +51,7 @@ OPTIONS
|
|||||||
|
|
||||||
<upstream>::
|
<upstream>::
|
||||||
Upstream branch to compare against.
|
Upstream branch to compare against.
|
||||||
|
Defaults to the first tracked remote branch, if available.
|
||||||
|
|
||||||
<head>::
|
<head>::
|
||||||
Working branch; defaults to HEAD.
|
Working branch; defaults to HEAD.
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "patch-ids.h"
|
#include "patch-ids.h"
|
||||||
#include "run-command.h"
|
#include "run-command.h"
|
||||||
#include "shortlog.h"
|
#include "shortlog.h"
|
||||||
|
#include "remote.h"
|
||||||
|
|
||||||
/* Set a default date-time format for git log ("log.date" config variable) */
|
/* Set a default date-time format for git log ("log.date" config variable) */
|
||||||
static const char *default_date_mode = NULL;
|
static const char *default_date_mode = NULL;
|
||||||
@ -1061,13 +1062,14 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char cherry_usage[] =
|
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)
|
int cmd_cherry(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
struct patch_ids ids;
|
struct patch_ids ids;
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
struct commit_list *list = NULL;
|
struct commit_list *list = NULL;
|
||||||
|
struct branch *current_branch;
|
||||||
const char *upstream;
|
const char *upstream;
|
||||||
const char *head = "HEAD";
|
const char *head = "HEAD";
|
||||||
const char *limit = NULL;
|
const char *limit = NULL;
|
||||||
@ -1090,7 +1092,17 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
|
|||||||
upstream = argv[1];
|
upstream = argv[1];
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
init_revisions(&revs, prefix);
|
||||||
|
Loading…
Reference in New Issue
Block a user