2008-11-15 01:14:24 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='pull options'
|
|
|
|
|
2020-11-19 00:44:33 +01:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19 00:44:19 +01:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2008-11-15 01:14:24 +01:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
mkdir parent &&
|
|
|
|
(cd parent && git init &&
|
|
|
|
echo one >file && git add file &&
|
|
|
|
git commit -m one)
|
|
|
|
'
|
|
|
|
|
2020-03-10 04:54:20 +01:00
|
|
|
test_expect_success 'git pull -q --no-rebase' '
|
2008-11-15 01:14:24 +01:00
|
|
|
mkdir clonedq &&
|
2010-02-24 19:22:05 +01:00
|
|
|
(cd clonedq && git init &&
|
2020-03-10 04:54:20 +01:00
|
|
|
git pull -q --no-rebase "../parent" >out 2>err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty err &&
|
|
|
|
test_must_be_empty out)
|
2008-11-15 01:14:24 +01:00
|
|
|
'
|
|
|
|
|
2013-03-15 03:26:08 +01:00
|
|
|
test_expect_success 'git pull -q --rebase' '
|
|
|
|
mkdir clonedqrb &&
|
|
|
|
(cd clonedqrb && git init &&
|
|
|
|
git pull -q --rebase "../parent" >out 2>err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty err &&
|
|
|
|
test_must_be_empty out &&
|
2013-03-15 03:26:08 +01:00
|
|
|
git pull -q --rebase "../parent" >out 2>err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty err &&
|
|
|
|
test_must_be_empty out)
|
2013-03-15 03:26:08 +01:00
|
|
|
'
|
|
|
|
|
2020-03-10 04:54:20 +01:00
|
|
|
test_expect_success 'git pull --no-rebase' '
|
2008-11-15 01:14:24 +01:00
|
|
|
mkdir cloned &&
|
2010-02-24 19:22:05 +01:00
|
|
|
(cd cloned && git init &&
|
2020-03-10 04:54:20 +01:00
|
|
|
git pull --no-rebase "../parent" >out 2>err &&
|
2010-02-24 19:22:05 +01:00
|
|
|
test -s err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty out)
|
2008-11-15 01:14:24 +01:00
|
|
|
'
|
|
|
|
|
2013-03-15 03:26:08 +01:00
|
|
|
test_expect_success 'git pull --rebase' '
|
|
|
|
mkdir clonedrb &&
|
|
|
|
(cd clonedrb && git init &&
|
|
|
|
git pull --rebase "../parent" >out 2>err &&
|
|
|
|
test -s err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty out)
|
2013-03-15 03:26:08 +01:00
|
|
|
'
|
|
|
|
|
2020-03-10 04:54:20 +01:00
|
|
|
test_expect_success 'git pull -v --no-rebase' '
|
2008-11-15 01:14:24 +01:00
|
|
|
mkdir clonedv &&
|
2010-02-24 19:22:05 +01:00
|
|
|
(cd clonedv && git init &&
|
2020-03-10 04:54:20 +01:00
|
|
|
git pull -v --no-rebase "../parent" >out 2>err &&
|
2010-02-24 19:22:05 +01:00
|
|
|
test -s err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty out)
|
2008-11-15 01:14:24 +01:00
|
|
|
'
|
|
|
|
|
2013-03-15 03:26:08 +01:00
|
|
|
test_expect_success 'git pull -v --rebase' '
|
|
|
|
mkdir clonedvrb &&
|
|
|
|
(cd clonedvrb && git init &&
|
|
|
|
git pull -v --rebase "../parent" >out 2>err &&
|
|
|
|
test -s err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty out)
|
2013-03-15 03:26:08 +01:00
|
|
|
'
|
|
|
|
|
2020-03-10 04:54:20 +01:00
|
|
|
test_expect_success 'git pull -v -q --no-rebase' '
|
2008-11-15 01:14:24 +01:00
|
|
|
mkdir clonedvq &&
|
2010-02-24 19:22:05 +01:00
|
|
|
(cd clonedvq && git init &&
|
2020-03-10 04:54:20 +01:00
|
|
|
git pull -v -q --no-rebase "../parent" >out 2>err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty out &&
|
|
|
|
test_must_be_empty err)
|
2008-11-15 01:14:24 +01:00
|
|
|
'
|
|
|
|
|
2020-03-10 04:54:20 +01:00
|
|
|
test_expect_success 'git pull -q -v --no-rebase' '
|
2008-11-15 01:14:24 +01:00
|
|
|
mkdir clonedqv &&
|
2010-02-24 19:22:05 +01:00
|
|
|
(cd clonedqv && git init &&
|
2020-03-10 04:54:20 +01:00
|
|
|
git pull -q -v --no-rebase "../parent" >out 2>err &&
|
2013-06-09 20:29:20 +02:00
|
|
|
test_must_be_empty out &&
|
2010-02-24 19:22:05 +01:00
|
|
|
test -s err)
|
2008-11-15 01:14:24 +01:00
|
|
|
'
|
2019-04-17 12:23:27 +02:00
|
|
|
test_expect_success 'git pull --cleanup errors early on invalid argument' '
|
|
|
|
mkdir clonedcleanup &&
|
|
|
|
(cd clonedcleanup && git init &&
|
2020-03-10 04:54:20 +01:00
|
|
|
test_must_fail git pull --no-rebase --cleanup invalid "../parent" >out 2>err &&
|
2019-04-17 12:23:27 +02:00
|
|
|
test_must_be_empty out &&
|
|
|
|
test -s err)
|
|
|
|
'
|
|
|
|
|
2020-08-18 16:25:22 +02:00
|
|
|
test_expect_success 'git pull --no-write-fetch-head fails' '
|
|
|
|
mkdir clonedwfh &&
|
|
|
|
(cd clonedwfh && git init &&
|
|
|
|
test_expect_code 129 git pull --no-write-fetch-head "../parent" >out 2>err &&
|
|
|
|
test_must_be_empty out &&
|
|
|
|
test_i18ngrep "no-write-fetch-head" err)
|
|
|
|
'
|
2008-11-15 01:14:24 +01:00
|
|
|
|
2010-02-24 19:22:06 +01:00
|
|
|
test_expect_success 'git pull --force' '
|
|
|
|
mkdir clonedoldstyle &&
|
|
|
|
(cd clonedoldstyle && git init &&
|
|
|
|
cat >>.git/config <<-\EOF &&
|
|
|
|
[remote "one"]
|
|
|
|
url = ../parent
|
2020-11-19 00:44:33 +01:00
|
|
|
fetch = refs/heads/main:refs/heads/mirror
|
2010-02-24 19:22:06 +01:00
|
|
|
[remote "two"]
|
|
|
|
url = ../parent
|
2020-11-19 00:44:33 +01:00
|
|
|
fetch = refs/heads/main:refs/heads/origin
|
|
|
|
[branch "main"]
|
2010-02-24 19:22:06 +01:00
|
|
|
remote = two
|
2020-11-19 00:44:33 +01:00
|
|
|
merge = refs/heads/main
|
2010-02-24 19:22:06 +01:00
|
|
|
EOF
|
|
|
|
git pull two &&
|
|
|
|
test_commit A &&
|
|
|
|
git branch -f origin &&
|
|
|
|
git pull --all --force
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2010-02-24 20:02:05 +01:00
|
|
|
test_expect_success 'git pull --all' '
|
|
|
|
mkdir clonedmulti &&
|
|
|
|
(cd clonedmulti && git init &&
|
|
|
|
cat >>.git/config <<-\EOF &&
|
|
|
|
[remote "one"]
|
|
|
|
url = ../parent
|
|
|
|
fetch = refs/heads/*:refs/remotes/one/*
|
|
|
|
[remote "two"]
|
|
|
|
url = ../parent
|
|
|
|
fetch = refs/heads/*:refs/remotes/two/*
|
2020-11-19 00:44:33 +01:00
|
|
|
[branch "main"]
|
2010-02-24 20:02:05 +01:00
|
|
|
remote = one
|
2020-11-19 00:44:33 +01:00
|
|
|
merge = refs/heads/main
|
2010-02-24 20:02:05 +01:00
|
|
|
EOF
|
|
|
|
git pull --all
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2015-05-29 13:44:44 +02:00
|
|
|
test_expect_success 'git pull --dry-run' '
|
|
|
|
test_when_finished "rm -rf clonedry" &&
|
|
|
|
git init clonedry &&
|
|
|
|
(
|
|
|
|
cd clonedry &&
|
|
|
|
git pull --dry-run ../parent &&
|
|
|
|
test_path_is_missing .git/FETCH_HEAD &&
|
2020-11-19 00:44:33 +01:00
|
|
|
test_path_is_missing .git/refs/heads/main &&
|
2015-05-29 13:44:44 +02:00
|
|
|
test_path_is_missing .git/index &&
|
|
|
|
test_path_is_missing file
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2015-06-02 16:22:52 +02:00
|
|
|
test_expect_success 'git pull --all --dry-run' '
|
|
|
|
test_when_finished "rm -rf cloneddry" &&
|
|
|
|
git init clonedry &&
|
|
|
|
(
|
|
|
|
cd clonedry &&
|
|
|
|
git remote add origin ../parent &&
|
|
|
|
git pull --all --dry-run &&
|
|
|
|
test_path_is_missing .git/FETCH_HEAD &&
|
2020-11-19 00:44:33 +01:00
|
|
|
test_path_is_missing .git/refs/remotes/origin/main &&
|
2015-06-02 16:22:52 +02:00
|
|
|
test_path_is_missing .git/index &&
|
|
|
|
test_path_is_missing file
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2016-03-18 21:21:09 +01:00
|
|
|
test_expect_success 'git pull --allow-unrelated-histories' '
|
|
|
|
test_when_finished "rm -fr src dst" &&
|
|
|
|
git init src &&
|
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
test_commit one &&
|
|
|
|
test_commit two
|
|
|
|
) &&
|
|
|
|
git clone src dst &&
|
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
git checkout --orphan side HEAD^ &&
|
|
|
|
test_commit three
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_must_fail git pull ../src side &&
|
|
|
|
git pull --allow-unrelated-histories ../src side
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2017-10-12 20:35:42 +02:00
|
|
|
test_expect_success 'git pull does not add a sign-off line' '
|
|
|
|
test_when_finished "rm -fr src dst actual" &&
|
|
|
|
git init src &&
|
|
|
|
test_commit -C src one &&
|
|
|
|
git clone src dst &&
|
|
|
|
test_commit -C src two &&
|
|
|
|
git -C dst pull --no-ff &&
|
|
|
|
git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
|
|
|
|
test_must_be_empty actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git pull --no-signoff does not add sign-off line' '
|
|
|
|
test_when_finished "rm -fr src dst actual" &&
|
|
|
|
git init src &&
|
|
|
|
test_commit -C src one &&
|
|
|
|
git clone src dst &&
|
|
|
|
test_commit -C src two &&
|
|
|
|
git -C dst pull --no-signoff --no-ff &&
|
|
|
|
git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
|
|
|
|
test_must_be_empty actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git pull --signoff add a sign-off line' '
|
|
|
|
test_when_finished "rm -fr src dst expected actual" &&
|
|
|
|
echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
|
|
|
|
git init src &&
|
|
|
|
test_commit -C src one &&
|
|
|
|
git clone src dst &&
|
|
|
|
test_commit -C src two &&
|
|
|
|
git -C dst pull --signoff --no-ff &&
|
|
|
|
git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git pull --no-signoff flag cancels --signoff flag' '
|
|
|
|
test_when_finished "rm -fr src dst actual" &&
|
|
|
|
git init src &&
|
|
|
|
test_commit -C src one &&
|
|
|
|
git clone src dst &&
|
|
|
|
test_commit -C src two &&
|
|
|
|
git -C dst pull --signoff --no-signoff --no-ff &&
|
|
|
|
git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
|
|
|
|
test_must_be_empty actual
|
|
|
|
'
|
|
|
|
|
2008-11-15 01:14:24 +01:00
|
|
|
test_done
|