From: Pratik Karki <predatoramigo@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, Johannes.Schindelin@gmx.de,
sbeller@google.com, alban.gruin@gmail.com, gitster@pobox.com,
Pratik Karki <predatoramigo@gmail.com>
Subject: [PATCH 1/6] builtin rebase: optionally auto-detect the upstream
Date: Wed, 8 Aug 2018 21:21:30 +0545 [thread overview]
Message-ID: <20180808153635.19944-2-predatoramigo@gmail.com> (raw)
In-Reply-To: <20180808153635.19944-1-predatoramigo@gmail.com>
The `git rebase` command, when called without the `<upstream>`
command-line argument, automatically looks for the upstream
branch configured for the current branch.
With this commit, the builtin rebase learned that trick, too.
Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
---
builtin/rebase.c | 44 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 41 insertions(+), 3 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 94abaaa890..c5b2534717 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -622,6 +622,36 @@ static int parse_opt_interactive(const struct option *opt, const char *arg,
return 0;
}
+static void NORETURN error_on_missing_default_upstream(void)
+{
+ struct branch *current_branch = branch_get(NULL);
+
+ printf(_("%s\n"
+ "Please specify which branch you want to rebase against.\n"
+ "See git-rebase(1) for details.\n"
+ "\n"
+ " git rebase '<branch>'\n"
+ "\n"),
+ current_branch ? _("There is no tracking information for "
+ "the current branch.") :
+ _("You are not currently on a branch."));
+
+ if (current_branch) {
+ const char *remote = current_branch->remote_name;
+
+ if (!remote)
+ remote = _("<remote>");
+
+ printf(_("If you wish to set tracking information for this "
+ "branch you can do so with:\n"
+ "\n"
+ " git branch --set-upstream-to=%s/<branch> %s\n"
+ "\n"),
+ remote, current_branch->name);
+ }
+ exit(1);
+}
+
int cmd_rebase(int argc, const char **argv, const char *prefix)
{
struct rebase_options options = {
@@ -1056,9 +1086,17 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
}
if (!options.root) {
- if (argc < 1)
- die("TODO: handle @{upstream}");
- else {
+ if (argc < 1) {
+ struct branch *branch;
+
+ branch = branch_get(NULL);
+ options.upstream_name = branch_get_upstream(branch,
+ NULL);
+ if (!options.upstream_name)
+ error_on_missing_default_upstream();
+ if (fork_point < 0)
+ fork_point = 1;
+ } else {
options.upstream_name = argv[0];
argc--;
argv++;
--
2.18.0
next prev parent reply other threads:[~2018-08-08 15:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-08 15:36 [GSoC] [PATCH 0/6] builtin rebase rest Pratik Karki
2018-08-08 15:36 ` Pratik Karki [this message]
2018-08-08 15:36 ` [PATCH 2/6] builtin rebase: optionally pass custom reflogs to reset_head() Pratik Karki
2018-08-08 15:36 ` [PATCH 3/6] builtin rebase: fast-forward to onto if it is a proper descendant Pratik Karki
2018-08-08 15:36 ` [PATCH 4/6] builtin rebase: show progress when connected to a terminal Pratik Karki
2018-08-08 15:36 ` [PATCH 5/6] builtin rebase: use no-op editor when interactive is "implied" Pratik Karki
2018-08-08 15:36 ` [PATCH 6/6] builtin rebase: error out on incompatible option/mode combinations Pratik Karki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180808153635.19944-2-predatoramigo@gmail.com \
--to=predatoramigo@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=alban.gruin@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).