]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5553-set-upstream.sh
The ninth batch
[thirdparty/git.git] / t / t5553-set-upstream.sh
index 9c12c0f8c321def9e39d0887d463b5d227d3157d..48050162c27440dab8a0dbc5cd19a2781bee2d37 100755 (executable)
@@ -91,6 +91,17 @@ test_expect_success 'fetch --set-upstream with valid URL sets upstream to URL' '
        check_config_missing other2
 '
 
+test_expect_success 'fetch --set-upstream with a detached HEAD' '
+       git checkout HEAD^0 &&
+       test_when_finished "git checkout -" &&
+       cat >expect <<-\EOF &&
+       warning: could not set upstream of HEAD to '"'"'main'"'"' from '"'"'upstream'"'"' when it does not point to any branch.
+       EOF
+       git fetch --set-upstream upstream main 2>actual.raw &&
+       grep ^warning: actual.raw >actual &&
+       test_cmp expect actual
+'
+
 # tests for pull --set-upstream
 
 test_expect_success 'setup bare parent pull' '
@@ -178,4 +189,15 @@ test_expect_success 'pull --set-upstream with valid URL and branch sets branch'
        check_config_missing other2
 '
 
+test_expect_success 'pull --set-upstream with a detached HEAD' '
+       git checkout HEAD^0 &&
+       test_when_finished "git checkout -" &&
+       cat >expect <<-\EOF &&
+       warning: could not set upstream of HEAD to '"'"'main'"'"' from '"'"'upstream'"'"' when it does not point to any branch.
+       EOF
+       git pull --no-rebase --set-upstream upstream main 2>actual.raw &&
+       grep ^warning: actual.raw >actual &&
+       test_cmp expect actual
+'
+
 test_done