diff mbox series

[RFC,WIP,v8,12/13] rebase: add a should_fast_forward() utility function

Message ID 20190508001252.15752-13-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v7,1/6] t3431: add rebase --fork-point tests | expand

Commit Message

Ævar Arnfjörð Bjarmason May 8, 2019, 12:12 a.m. UTC
The is_interactive() test gets tricky around --rebase-merges. Let's
split our use of it for the purposes of whether we should try
fast-forwarding a rebase into a utility function to prepare for adding
more logic to that specific codepath.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/rebase.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/builtin/rebase.c b/builtin/rebase.c
index cb5d7fcb53..167d4fcf67 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -890,6 +890,11 @@  static void populate_merge_bases(struct commit *head, struct commit *onto,
 	oidcpy(merge_base, &merge_bases->item->object.oid);
 }
 
+static int should_fast_forward(struct rebase_options *opts)
+{
+	return !is_interactive(opts);
+}
+
 static int can_fast_forward(struct commit *head,
 			    struct commit *onto, struct commit *upstream,
 			    struct commit *restrict_revision,
@@ -1715,7 +1720,7 @@  int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (head_commit)
 		populate_merge_bases(head_commit, options.onto, merge_bases,
 				     &merge_base);
-	if (!is_interactive(&options) &&
+	if (should_fast_forward(&options) &&
 	    can_fast_forward(head_commit, options.onto, options.upstream,
 			     options.restrict_revision, &options.orig_head,
 			     merge_bases, &merge_base)) {