2008-02-03 08:47:22 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2011-03-23 10:38:51 +01:00
|
|
|
test_description='ancestor culling and limiting by parent number'
|
2008-02-03 08:47:22 +01:00
|
|
|
|
2020-11-19 00:44:36 +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-02-03 08:47:22 +01:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
2011-03-23 10:38:51 +01:00
|
|
|
check_revlist () {
|
|
|
|
rev_list_args="$1" &&
|
|
|
|
shift &&
|
|
|
|
git rev-parse "$@" >expect &&
|
|
|
|
git rev-list $rev_list_args --all >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
}
|
|
|
|
|
2008-02-03 08:47:22 +01:00
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
touch file &&
|
|
|
|
git add file &&
|
|
|
|
|
2011-03-21 11:14:05 +01:00
|
|
|
test_commit one &&
|
2008-02-03 08:47:22 +01:00
|
|
|
|
2010-10-31 02:46:54 +01:00
|
|
|
test_tick=$(($test_tick - 2400)) &&
|
2008-02-03 08:47:22 +01:00
|
|
|
|
2011-03-21 11:14:05 +01:00
|
|
|
test_commit two &&
|
|
|
|
test_commit three &&
|
|
|
|
test_commit four &&
|
2008-02-03 08:47:22 +01:00
|
|
|
|
|
|
|
git log --pretty=oneline --abbrev-commit
|
|
|
|
'
|
|
|
|
|
2008-03-18 02:56:33 +01:00
|
|
|
test_expect_success 'one is ancestor of others and should not be shown' '
|
2008-02-03 08:47:22 +01:00
|
|
|
|
|
|
|
git rev-list one --not four >result &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty result
|
2008-02-03 08:47:22 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2011-03-23 10:38:51 +01:00
|
|
|
test_expect_success 'setup roots, merges and octopuses' '
|
|
|
|
|
|
|
|
git checkout --orphan newroot &&
|
|
|
|
test_commit five &&
|
|
|
|
git checkout -b sidebranch two &&
|
|
|
|
test_commit six &&
|
|
|
|
git checkout -b anotherbranch three &&
|
|
|
|
test_commit seven &&
|
|
|
|
git checkout -b yetanotherbranch four &&
|
|
|
|
test_commit eight &&
|
2020-11-19 00:44:36 +01:00
|
|
|
git checkout main &&
|
merge: refuse to create too cool a merge by default
While it makes sense to allow merging unrelated histories of two
projects that started independently into one, in the way "gitk" was
merged to "git" itself aka "the coolest merge ever", such a merge is
still an unusual event. Worse, if somebody creates an independent
history by starting from a tarball of an established project and
sends a pull request to the original project, "git merge" however
happily creates such a merge without any sign of something unusual
is happening.
Teach "git merge" to refuse to create such a merge by default,
unless the user passes a new "--allow-unrelated-histories" option to
tell it that the user is aware that two unrelated projects are
merged.
Because such a "two project merge" is a rare event, a configuration
option to always allow such a merge is not added.
We could add the same option to "git pull" and have it passed
through to underlying "git merge". I do not have a fundamental
opposition against such a feature, but this commit does not do so
and instead leaves it as low-hanging fruit for others, because such
a "two project merge" would be done after fetching the other project
into some location in the working tree of an existing project and
making sure how well they fit together, it is sufficient to allow a
local merge without such an option pass-through from "git pull" to
"git merge". Many tests that are updated by this patch does the
pass-through manually by turning:
git pull something
into its equivalent:
git fetch something &&
git merge --allow-unrelated-histories FETCH_HEAD
If somebody is inclined to add such an option, updated tests in this
change need to be adjusted back to:
git pull --allow-unrelated-histories something
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-03-18 21:21:09 +01:00
|
|
|
test_tick &&
|
|
|
|
git merge --allow-unrelated-histories -m normalmerge newroot &&
|
|
|
|
git tag normalmerge &&
|
2011-03-23 10:38:51 +01:00
|
|
|
test_tick &&
|
|
|
|
git merge -m tripus sidebranch anotherbranch &&
|
|
|
|
git tag tripus &&
|
|
|
|
git checkout -b tetrabranch normalmerge &&
|
|
|
|
test_tick &&
|
|
|
|
git merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&
|
|
|
|
git tag tetrapus &&
|
2020-11-19 00:44:36 +01:00
|
|
|
git checkout main
|
2011-03-23 10:38:51 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list roots' '
|
|
|
|
|
|
|
|
check_revlist "--max-parents=0" one five
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list no merges' '
|
|
|
|
|
|
|
|
check_revlist "--max-parents=1" one eight seven six five four three two &&
|
|
|
|
check_revlist "--no-merges" one eight seven six five four three two
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list no octopuses' '
|
|
|
|
|
|
|
|
check_revlist "--max-parents=2" one normalmerge eight seven six five four three two
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list no roots' '
|
|
|
|
|
|
|
|
check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list merges' '
|
|
|
|
|
|
|
|
check_revlist "--min-parents=2" tetrapus tripus normalmerge &&
|
|
|
|
check_revlist "--merges" tetrapus tripus normalmerge
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list octopus' '
|
|
|
|
|
|
|
|
check_revlist "--min-parents=3" tetrapus tripus
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list ordinary commits' '
|
|
|
|
|
|
|
|
check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list --merges --no-merges yields empty set' '
|
|
|
|
|
|
|
|
check_revlist "--min-parents=2 --no-merges" &&
|
|
|
|
check_revlist "--merges --no-merges" &&
|
|
|
|
check_revlist "--no-merges --merges"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'rev-list override and infinities' '
|
|
|
|
|
|
|
|
check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&
|
|
|
|
check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&
|
|
|
|
check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&
|
|
|
|
check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&
|
|
|
|
check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&
|
|
|
|
check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five
|
|
|
|
'
|
|
|
|
|
2011-03-24 09:21:24 +01:00
|
|
|
test_expect_success 'dodecapus' '
|
2011-03-23 10:38:51 +01:00
|
|
|
|
2011-03-24 09:21:24 +01:00
|
|
|
roots= &&
|
2011-03-23 10:38:51 +01:00
|
|
|
for i in 1 2 3 4 5 6 7 8 9 10 11
|
|
|
|
do
|
2011-03-24 09:21:24 +01:00
|
|
|
git checkout -b root$i five &&
|
|
|
|
test_commit $i &&
|
|
|
|
roots="$roots root$i" ||
|
2021-12-09 06:11:15 +01:00
|
|
|
return 1
|
2011-03-23 10:38:51 +01:00
|
|
|
done &&
|
2020-11-19 00:44:36 +01:00
|
|
|
git checkout main &&
|
2011-03-23 10:38:51 +01:00
|
|
|
test_tick &&
|
2011-03-24 09:21:24 +01:00
|
|
|
git merge -m dodecapus $roots &&
|
|
|
|
git tag dodecapus &&
|
2011-03-23 10:38:51 +01:00
|
|
|
|
|
|
|
check_revlist "--min-parents=4" dodecapus tetrapus &&
|
|
|
|
check_revlist "--min-parents=8" dodecapus &&
|
|
|
|
check_revlist "--min-parents=12" dodecapus &&
|
|
|
|
check_revlist "--min-parents=13" &&
|
|
|
|
check_revlist "--min-parents=4 --max-parents=11" tetrapus
|
|
|
|
'
|
2013-03-22 19:38:19 +01:00
|
|
|
|
|
|
|
test_expect_success 'ancestors with the same commit time' '
|
|
|
|
|
|
|
|
test_tick_keep=$test_tick &&
|
|
|
|
for i in 1 2 3 4 5 6 7 8; do
|
tests: fix broken &&-chains in compound statements
The top-level &&-chain checker built into t/test-lib.sh causes tests to
magically exit with code 117 if the &&-chain is broken. However, it has
the shortcoming that the magic does not work within `{...}` groups,
`(...)` subshells, `$(...)` substitutions, or within bodies of compound
statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed`
partly fills in the gap by catching broken &&-chains in `(...)`
subshells, but bugs can still lurk behind broken &&-chains in the other
cases.
Fix broken &&-chains in compound statements in order to reduce the
number of possible lurking bugs.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-09 06:11:06 +01:00
|
|
|
test_tick=$test_tick_keep &&
|
2021-12-09 06:11:15 +01:00
|
|
|
test_commit t$i || return 1
|
2013-03-22 19:38:19 +01:00
|
|
|
done &&
|
|
|
|
git rev-list t1^! --not t$i >result &&
|
2018-07-27 19:48:11 +02:00
|
|
|
test_must_be_empty result
|
2013-03-22 19:38:19 +01:00
|
|
|
'
|
|
|
|
|
2008-02-03 08:47:22 +01:00
|
|
|
test_done
|