{"thread":{"id":"55021","subject":"[PATCH v2] rebase: add a config option for --no-fork-point","startedAt":"2021-01-21T04:20:33Z","lastAt":"2021-01-21T04:20:33Z","messageCount":1,"participants":["Alex Henrie"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"414883","messageId":"20210121041320.66192-1-alexhenrie24@gmail.com","threadId":"55021","inReplyTo":null,"subject":"[PATCH v2] rebase: add a config option for --no-fork-point","fromName":"Alex Henrie","fromEmail":"alexhenrie24@gmail.com","sentAt":"2021-01-21T04:13:20Z","receivedAt":"2021-01-21T04:20:33Z","isPatch":true,"sender":{"key":"alexhenrie24@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5951993?v=4"},"body":"Some users (myself included) would prefer to have this feature off by\ndefault because it can silently drop commits.\n\nSigned-off-by: Alex Henrie <alexhenrie24@gmail.com>\n---\n Documentation/config/rebase.txt |  3 +++\n builtin/rebase.c                | 20 +++++++++++++-------\n t/t3431-rebase-fork-point.sh    | 10 ++++++++++\n 3 files changed, 26 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/config/rebase.txt b/Documentation/config/rebase.txt\nindex 7f7a07d22f..8531a4b3f7 100644\n--- a/Documentation/config/rebase.txt\n+++ b/Documentation/config/rebase.txt\n@@ -68,3 +68,6 @@ rebase.rescheduleFailedExec::\n \tAutomatically reschedule `exec` commands that failed. This only makes\n \tsense in interactive mode (or when an `--exec` option was provided).\n \tThis is the same as specifying the `--reschedule-failed-exec` option.\n+\n+rebase.forkPoint:\n+\tIf set to false set `--no-fork-point` option by default.\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 840dbd7eb7..de400f9a19 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -102,6 +102,7 @@ struct rebase_options {\n \tint reschedule_failed_exec;\n \tint use_legacy_rebase;\n \tint reapply_cherry_picks;\n+\tint fork_point;\n };\n \n #define REBASE_OPTIONS_INIT {\t\t\t  \t\\\n@@ -111,7 +112,8 @@ struct rebase_options {\n \t\t.default_backend = \"merge\",\t  \t\\\n \t\t.flags = REBASE_NO_QUIET, \t\t\\\n \t\t.git_am_opts = STRVEC_INIT,\t\t\\\n-\t\t.git_format_patch_opt = STRBUF_INIT\t\\\n+\t\t.git_format_patch_opt = STRBUF_INIT,\t\\\n+\t\t.fork_point = -1,\t\t\t\\\n \t}\n \n static struct replay_opts get_replay_opts(const struct rebase_options *opts)\n@@ -1095,6 +1097,11 @@ static int rebase_config(const char *var, const char *value, void *data)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"rebase.forkpoint\")) {\n+\t\topts->fork_point = git_config_bool(var, value) ? -1 : 0;\n+\t\treturn 0;\n+\t}\n+\n \tif (!strcmp(var, \"rebase.usebuiltin\")) {\n \t\topts->use_legacy_rebase = !git_config_bool(var, value);\n \t\treturn 0;\n@@ -1306,7 +1313,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \tconst char *gpg_sign = NULL;\n \tstruct string_list exec = STRING_LIST_INIT_NODUP;\n \tconst char *rebase_merges = NULL;\n-\tint fork_point = -1;\n \tstruct string_list strategy_options = STRING_LIST_INIT_NODUP;\n \tstruct object_id squash_onto;\n \tchar *squash_onto_name = NULL;\n@@ -1406,7 +1412,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"mode\"),\n \t\t\tN_(\"try to rebase merges instead of skipping them\"),\n \t\t\tPARSE_OPT_OPTARG, NULL, (intptr_t)\"\"},\n-\t\tOPT_BOOL(0, \"fork-point\", &fork_point,\n+\t\tOPT_BOOL(0, \"fork-point\", &options.fork_point,\n \t\t\t N_(\"use 'merge-base --fork-point' to refine upstream\")),\n \t\tOPT_STRING('s', \"strategy\", &options.strategy,\n \t\t\t   N_(\"strategy\"), N_(\"use the given merge strategy\")),\n@@ -1494,7 +1500,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"cannot combine '--keep-base' with '--root'\"));\n \t}\n \n-\tif (options.root && fork_point > 0)\n+\tif (options.root && options.fork_point > 0)\n \t\tdie(_(\"cannot combine '--root' with '--fork-point'\"));\n \n \tif (action != ACTION_NONE && !in_progress)\n@@ -1840,8 +1846,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\t\t\t\t\t\t    NULL);\n \t\t\tif (!options.upstream_name)\n \t\t\t\terror_on_missing_default_upstream();\n-\t\t\tif (fork_point < 0)\n-\t\t\t\tfork_point = 1;\n+\t\t\tif (options.fork_point < 0)\n+\t\t\t\toptions.fork_point = 1;\n \t\t} else {\n \t\t\toptions.upstream_name = argv[0];\n \t\t\targc--;\n@@ -1945,7 +1951,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t} else\n \t\tBUG(\"unexpected number of arguments left to parse\");\n \n-\tif (fork_point > 0) {\n+\tif (options.fork_point > 0) {\n \t\tstruct commit *head =\n \t\t\tlookup_commit_reference(the_repository,\n \t\t\t\t\t\t&options.orig_head);\ndiff --git a/t/t3431-rebase-fork-point.sh b/t/t3431-rebase-fork-point.sh\nindex 172562789e..e48c4014cf 100755\n--- a/t/t3431-rebase-fork-point.sh\n+++ b/t/t3431-rebase-fork-point.sh\n@@ -74,4 +74,14 @@ test_expect_success 'git rebase --fork-point with ambigous refname' '\n \ttest_must_fail git rebase --fork-point --onto D one\n '\n \n+test_expect_success '--fork-point and --root both given' '\n+\ttest_must_fail git rebase --fork-point --root 2>err &&\n+\ttest_i18ngrep \"cannot combine\" err\n+'\n+\n+test_expect_success 'rebase.forkPoint true and --root given' '\n+\ttest_config rebase.forkPoint true &&\n+\tgit rebase --root\n+'\n+\n test_done\n-- \n2.30.0\n\n"}]}