]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t3200-branch.sh
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / t / t3200-branch.sh
index 8a619d785e4f7b031bcf437ca5c80086777e89b8..1bc3795847dbbbe810e230dee5313d0b20b641aa 100755 (executable)
@@ -979,15 +979,15 @@ test_expect_success 'disabled option --set-upstream fails' '
        test_must_fail git branch --set-upstream origin/main
 '
 
-test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '
+test_expect_success '--set-upstream-to notices an error to set branch as own upstream' "
        git branch --set-upstream-to refs/heads/my13 my13 2>actual &&
        cat >expect <<-\EOF &&
-       warning: not setting branch my13 as its own upstream
+       warning: not setting branch 'my13' as its own upstream
        EOF
        test_expect_code 1 git config branch.my13.remote &&
        test_expect_code 1 git config branch.my13.merge &&
        test_cmp expect actual
-'
+"
 
 # Keep this test last, as it changes the current branch
 cat >expect <<EOF
@@ -1461,4 +1461,37 @@ test_expect_success 'invalid sort parameter in configuration' '
        )
 '
 
+test_expect_success 'tracking info copied with --track=inherit' '
+       git branch --track=inherit foo2 my1 &&
+       test_cmp_config local branch.foo2.remote &&
+       test_cmp_config refs/heads/main branch.foo2.merge
+'
+
+test_expect_success 'tracking info copied with autoSetupMerge=inherit' '
+       test_unconfig branch.autoSetupMerge &&
+       # default config does not copy tracking info
+       git branch foo-no-inherit my1 &&
+       test_cmp_config "" --default "" branch.foo-no-inherit.remote &&
+       test_cmp_config "" --default "" branch.foo-no-inherit.merge &&
+       # with autoSetupMerge=inherit, we copy tracking info from my1
+       test_config branch.autoSetupMerge inherit &&
+       git branch foo3 my1 &&
+       test_cmp_config local branch.foo3.remote &&
+       test_cmp_config refs/heads/main branch.foo3.merge &&
+       # no tracking info to inherit from main
+       git branch main2 main &&
+       test_cmp_config "" --default "" branch.main2.remote &&
+       test_cmp_config "" --default "" branch.main2.merge
+'
+
+test_expect_success '--track overrides branch.autoSetupMerge' '
+       test_config branch.autoSetupMerge inherit &&
+       git branch --track=direct foo4 my1 &&
+       test_cmp_config . branch.foo4.remote &&
+       test_cmp_config refs/heads/my1 branch.foo4.merge &&
+       git branch --no-track foo5 my1 &&
+       test_cmp_config "" --default "" branch.foo5.remote &&
+       test_cmp_config "" --default "" branch.foo5.merge
+'
+
 test_done