builtin rebase: support `fork-point` option
This commit adds support for `--fork-point` and `--no-fork-point`. This is converted as-is from `git-legacy-rebase.sh`. Signed-off-by: Pratik Karki <predatoramigo@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pratik Karki committed
Sep 4, 2018 at 15:00 UTC
92d0d74e8d703d0f9c0bce779d5e25bb3c25f7df
1 file changed
+11
builtin/rebase.c
+11
@@ -632,6 +632,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
632
struct string_list whitespace = STRING_LIST_INIT_NODUP;
633
struct string_list exec = STRING_LIST_INIT_NODUP;
634
const char *rebase_merges = NULL;
635
+ int fork_point = -1;
636
struct option builtin_rebase_options[] = {
637
OPT_STRING(0, "onto", &options.onto_name,
638
N_("revision"),
@@ -715,6 +716,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
716
N_("mode"),
717
N_("try to rebase merges instead of skipping them"),
718
PARSE_OPT_OPTARG, NULL, (intptr_t)""},
719
+ OPT_BOOL(0, "fork-point", &fork_point,
720
+ N_("use 'merge-base --fork-point' to refine upstream")),
721
OPT_END(),
722
};
723
@@ -1063,6 +1066,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1066
} else
1067
BUG("unexpected number of arguments left to parse");
1068
1069
+ if (fork_point > 0) {
1070
+ struct commit *head =
1071
+ lookup_commit_reference(the_repository,
1072
+ &options.orig_head);
1073
+ options.restrict_revision =
1074
+ get_fork_point(options.upstream_name, head);
1075
+ }
1076
+
1077
if (read_index(the_repository->index) < 0)
1078
die(_("could not read index"));
1079