Skip to content

Commit 92d0d74

Browse files
prertikgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 103148a commit 92d0d74

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

builtin/rebase.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
632632
struct string_list whitespace = STRING_LIST_INIT_NODUP;
633633
struct string_list exec = STRING_LIST_INIT_NODUP;
634634
const char *rebase_merges = NULL;
635+
int fork_point = -1;
635636
struct option builtin_rebase_options[] = {
636637
OPT_STRING(0, "onto", &options.onto_name,
637638
N_("revision"),
@@ -715,6 +716,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
715716
N_("mode"),
716717
N_("try to rebase merges instead of skipping them"),
717718
PARSE_OPT_OPTARG, NULL, (intptr_t)""},
719+
OPT_BOOL(0, "fork-point", &fork_point,
720+
N_("use 'merge-base --fork-point' to refine upstream")),
718721
OPT_END(),
719722
};
720723

@@ -1063,6 +1066,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
10631066
} else
10641067
BUG("unexpected number of arguments left to parse");
10651068

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+
10661077
if (read_index(the_repository->index) < 0)
10671078
die(_("could not read index"));
10681079

0 commit comments

Comments
 (0)