summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-23 06:48:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-23 06:48:10 (GMT)
commitdcaf17c75d925531ba399a211e63664784d96821 (patch)
tree6ff3464e3c5cbf5bb7caf01ae6f30ede32b5dbc9 /t
parent597af311a2899bfd6640b9b107622c5795d5f998 (diff)
parent17baeaf82db5581f451c876320bf9719d72da675 (diff)
downloadgit-dcaf17c75d925531ba399a211e63664784d96821.zip
git-dcaf17c75d925531ba399a211e63664784d96821.tar.gz
git-dcaf17c75d925531ba399a211e63664784d96821.tar.bz2
Merge branch 'ab/fetch-set-upstream-while-detached'
"git fetch --set-upstream" did not check if there is a current branch, leading to a segfault when it is run on a detached HEAD, which has been corrected. * ab/fetch-set-upstream-while-detached: pull, fetch: fix segfault in --set-upstream option
Diffstat (limited to 't')
-rwxr-xr-xt/t5553-set-upstream.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh
index 9c12c0f..4805016 100755
--- a/t/t5553-set-upstream.sh
+++ b/t/t5553-set-upstream.sh
@@ -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