* [PATCH] git-cherry: make <upstream> parameter optional
@ 2008-12-29 17:45 Markus Heidelberg
2008-12-30 13:13 ` Johannes Schindelin
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Markus Heidelberg @ 2008-12-29 17:45 UTC (permalink / raw)
To: git
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>
---
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(-)
diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt
index 74d14c4..556ea23 100644
--- a/Documentation/git-cherry.txt
+++ b/Documentation/git-cherry.txt
@@ -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.
diff --git a/builtin-log.c b/builtin-log.c
index 99d1137..243f857 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);
--
1.6.1.35.ge4490
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] git-cherry: make <upstream> parameter optional
2008-12-29 17:45 [PATCH] git-cherry: make <upstream> parameter optional Markus Heidelberg
@ 2008-12-30 13:13 ` Johannes Schindelin
2008-12-30 13:37 ` Markus Heidelberg
2008-12-30 14:02 ` demerphq
2009-01-01 21:00 ` Junio C Hamano
2 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2008-12-30 13:13 UTC (permalink / raw)
To: Markus Heidelberg; +Cc: git
Hi,
On Mon, 29 Dec 2008, Markus Heidelberg wrote:
> 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>
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-cherry: make <upstream> parameter optional
2008-12-30 13:13 ` Johannes Schindelin
@ 2008-12-30 13:37 ` Markus Heidelberg
2008-12-30 13:44 ` Johannes Schindelin
0 siblings, 1 reply; 7+ messages in thread
From: Markus Heidelberg @ 2008-12-30 13:37 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin, 30.12.2008:
> Hi,
>
> On Mon, 29 Dec 2008, Markus Heidelberg wrote:
>
> > 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>
>
> 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
The patch was about git-cherry, not git-cherry-pick.
Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-cherry: make <upstream> parameter optional
2008-12-30 13:37 ` Markus Heidelberg
@ 2008-12-30 13:44 ` Johannes Schindelin
0 siblings, 0 replies; 7+ messages in thread
From: Johannes Schindelin @ 2008-12-30 13:44 UTC (permalink / raw)
To: Markus Heidelberg; +Cc: git
Hi,
On Tue, 30 Dec 2008, Markus Heidelberg wrote:
> Johannes Schindelin, 30.12.2008:
>
> > On Mon, 29 Dec 2008, Markus Heidelberg wrote:
> >
> > > 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>
> >
> > 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
>
> The 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...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-cherry: make <upstream> parameter optional
2008-12-29 17:45 [PATCH] git-cherry: make <upstream> parameter optional Markus Heidelberg
2008-12-30 13:13 ` Johannes Schindelin
@ 2008-12-30 14:02 ` demerphq
2009-01-01 21:00 ` Junio C Hamano
2 siblings, 0 replies; 7+ messages in thread
From: demerphq @ 2008-12-30 14:02 UTC (permalink / raw)
To: markus.heidelberg; +Cc: git
2008/12/29 Markus Heidelberg <markus.heidelberg@web.de>:
> 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>
FWIW: I would find this useful. Thanks for writing it.
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-cherry: make <upstream> parameter optional
2008-12-29 17:45 [PATCH] git-cherry: make <upstream> parameter optional Markus Heidelberg
2008-12-30 13:13 ` Johannes Schindelin
2008-12-30 14:02 ` demerphq
@ 2009-01-01 21:00 ` Junio C Hamano
2009-01-01 21:56 ` Markus Heidelberg
2 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2009-01-01 21:00 UTC (permalink / raw)
To: markus.heidelberg; +Cc: git
Markus Heidelberg <markus.heidelberg@web.de> writes:
> diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt
> index 74d14c4..556ea23 100644
> --- a/Documentation/git-cherry.txt
> +++ b/Documentation/git-cherry.txt
> @@ -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>]]]?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-cherry: make <upstream> parameter optional
2009-01-01 21:00 ` Junio C Hamano
@ 2009-01-01 21:56 ` Markus Heidelberg
0 siblings, 0 replies; 7+ messages in thread
From: Markus Heidelberg @ 2009-01-01 21:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
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>
---
Junio C Hamano, 01.01.2009:
> > -'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(-)
diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt
index 74d14c4..7deefda 100644
--- a/Documentation/git-cherry.txt
+++ b/Documentation/git-cherry.txt
@@ -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.
diff --git a/builtin-log.c b/builtin-log.c
index 99d1137..7e9616e 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);
--
1.6.1.35.ge4490
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-01-01 21:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-29 17:45 [PATCH] git-cherry: make <upstream> parameter optional Markus Heidelberg
2008-12-30 13:13 ` Johannes Schindelin
2008-12-30 13:37 ` Markus Heidelberg
2008-12-30 13:44 ` Johannes Schindelin
2008-12-30 14:02 ` demerphq
2009-01-01 21:00 ` Junio C Hamano
2009-01-01 21:56 ` Markus Heidelberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).