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 3/6] builtin rebase: fast-forward to onto if it is a proper descendant
Date: Wed, 8 Aug 2018 21:21:32 +0545 [thread overview]
Message-ID: <20180808153635.19944-4-predatoramigo@gmail.com> (raw)
In-Reply-To: <20180808153635.19944-1-predatoramigo@gmail.com>
When trying to rebase onto a direct descendant of HEAD, we can
take a shortcut and fast-forward instead. This commit makes it so.
Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
---
builtin/rebase.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index c51b9d288a..1bb64e7cd7 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1367,6 +1367,24 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
die(_("Could not detach HEAD"));
strbuf_release(&msg);
+ /*
+ * If the onto is a proper descendant of the tip of the branch, then
+ * we just fast-forwarded.
+ */
+ strbuf_reset(&msg);
+ if (!oidcmp(&merge_base, &options.orig_head)) {
+ printf(_("Fast-forwarded %s to %s. \n"),
+ branch_name, options.onto_name);
+ strbuf_addf(&msg, "rebase finished: %s onto %s",
+ options.head_name ? options.head_name : "detached HEAD",
+ oid_to_hex(&options.onto->object.oid));
+ reset_head(NULL, "Fast-forwarded", options.head_name, 0,
+ "HEAD", msg.buf);
+ strbuf_release(&msg);
+ ret = !!finish_rebase(&options);
+ goto cleanup;
+ }
+
strbuf_addf(&revisions, "%s..%s",
options.root ? oid_to_hex(&options.onto->object.oid) :
(options.restrict_revision ?
--
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 ` [PATCH 1/6] builtin rebase: optionally auto-detect the upstream Pratik Karki
2018-08-08 15:36 ` [PATCH 2/6] builtin rebase: optionally pass custom reflogs to reset_head() Pratik Karki
2018-08-08 15:36 ` Pratik Karki [this message]
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-4-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).