]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: add rebase.updateRefs config option
authorDerrick Stolee <derrickstolee@github.com>
Tue, 19 Jul 2022 18:33:42 +0000 (18:33 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jul 2022 19:49:04 +0000 (12:49 -0700)
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>
Documentation/config/rebase.txt
Documentation/git-rebase.txt
builtin/rebase.c
t/t3404-rebase-interactive.sh

index 8c979cb20f2a57d624efbbcc32d56339531d49de..f19bd0e04079051d6be21ee461d1a98c9a632629 100644 (file)
@@ -21,6 +21,9 @@ rebase.autoStash::
        `--autostash` options of linkgit:git-rebase[1].
        Defaults to false.
 
+rebase.updateRefs::
+       If set to true enable `--update-refs` option by default.
+
 rebase.missingCommitsCheck::
        If set to "warn", git rebase -i will print a warning if some
        commits are removed (e.g. a line was deleted), however the
index dfd847d661549bf86ead75765a1cb3e53334e042..305255f1e15061bc3b59ca0c550775215824cc22 100644 (file)
@@ -614,6 +614,9 @@ start would be overridden by the presence of
        Automatically force-update any branches that point to commits that
        are being rebased. Any branches that are checked out in a worktree
        are not updated in this way.
++
+If the configuration variable `rebase.updateRefs` is set, then this option
+can be used to override and disable this setting.
 
 INCOMPATIBLE OPTIONS
 --------------------
index 2497533e8fbe13326d7fbe73e76d03b17a23e57e..56e4214b44104a445f8b68d185c0aadd3442247d 100644 (file)
@@ -802,6 +802,11 @@ static int rebase_config(const char *var, const char *value, void *data)
                return 0;
        }
 
+       if (!strcmp(var, "rebase.updaterefs")) {
+               opts->update_refs = git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "rebase.reschedulefailedexec")) {
                opts->reschedule_failed_exec = git_config_bool(var, value);
                return 0;
index bebf9b4def7393ca8d9ab6a459eb001e28fee1a5..1a27bb0626dd7c0ecc19cb23a6b653f5c9360c66 100755 (executable)
@@ -1772,6 +1772,12 @@ test_expect_success '--update-refs adds label and update-ref commands' '
                EOF
 
                test_must_fail git rebase -i --autosquash --update-refs primary >todo &&
+               test_cmp expect todo &&
+
+               test_must_fail git -c rebase.autosquash=true \
+                                  -c rebase.updaterefs=true \
+                                  rebase -i primary >todo &&
+
                test_cmp expect todo
        )
 '
@@ -1813,6 +1819,14 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
                                   --rebase-merges=rebase-cousins \
                                   --update-refs primary >todo &&
 
+               test_cmp expect todo &&
+
+               test_must_fail git -c rebase.autosquash=true \
+                                  -c rebase.updaterefs=true \
+                                  rebase -i \
+                                  --rebase-merges=rebase-cousins \
+                                  primary >todo &&
+
                test_cmp expect todo
        )
 '