rebase: add rebase.updateRefs config option

The previous change added the --update-refs command-line option. For users who always want this mode, create the rebase.updateRefs config option which behaves the same way as rebase.autoSquash does with the --autosquash option. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jul 19, 2022 at 18:33 UTC 3113fedaeb67eed4c46ef7bdd670b8406317a303
4 files changed +25
Documentation/config/rebase.txt
+3
@@ -21,6 +21,9 @@ rebase.autoStash::
21 `--autostash` options of linkgit:git-rebase[1].
22 Defaults to false.
23
24 +rebase.updateRefs::
25 + If set to true enable `--update-refs` option by default.
26 +
27 rebase.missingCommitsCheck::
28 If set to "warn", git rebase -i will print a warning if some
29 commits are removed (e.g. a line was deleted), however the
Documentation/git-rebase.txt
+3
@@ -614,6 +614,9 @@ start would be overridden by the presence of
614 Automatically force-update any branches that point to commits that
615 are being rebased. Any branches that are checked out in a worktree
616 are not updated in this way.
617 ++
618 +If the configuration variable `rebase.updateRefs` is set, then this option
619 +can be used to override and disable this setting.
620
621 INCOMPATIBLE OPTIONS
622 --------------------
builtin/rebase.c
+5
@@ -802,6 +802,11 @@ static int rebase_config(const char *var, const char *value, void *data)
802 return 0;
803 }
804
805 + if (!strcmp(var, "rebase.updaterefs")) {
806 + opts->update_refs = git_config_bool(var, value);
807 + return 0;
808 + }
809 +
810 if (!strcmp(var, "rebase.reschedulefailedexec")) {
811 opts->reschedule_failed_exec = git_config_bool(var, value);
812 return 0;
t/t3404-rebase-interactive.sh
+14
@@ -1772,6 +1772,12 @@ test_expect_success '--update-refs adds label and update-ref commands' '
1772 EOF
1773
1774 test_must_fail git rebase -i --autosquash --update-refs primary >todo &&
1775 + test_cmp expect todo &&
1776 +
1777 + test_must_fail git -c rebase.autosquash=true \
1778 + -c rebase.updaterefs=true \
1779 + rebase -i primary >todo &&
1780 +
1781 test_cmp expect todo
1782 )
1783 '
@@ -1813,6 +1819,14 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
1819 --rebase-merges=rebase-cousins \
1820 --update-refs primary >todo &&
1821
1822 + test_cmp expect todo &&
1823 +
1824 + test_must_fail git -c rebase.autosquash=true \
1825 + -c rebase.updaterefs=true \
1826 + rebase -i \
1827 + --rebase-merges=rebase-cousins \
1828 + primary >todo &&
1829 +
1830 test_cmp expect todo
1831 )
1832 '