2006-12-13 00:36:16 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='Test merge without common ancestors'
|
2020-11-18 23:44:38 +00: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-18 23:44:19 +00:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2006-12-13 00:36:16 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
# This scenario is based on a real-world repository of Shawn Pearce.
|
|
|
|
|
|
|
|
# 1 - A - D - F
|
|
|
|
# \ X /
|
|
|
|
# B X
|
|
|
|
# X \
|
|
|
|
# 2 - C - E - G
|
|
|
|
|
2006-12-28 09:10:50 +00:00
|
|
|
GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100"
|
|
|
|
export GIT_COMMITTER_DATE
|
|
|
|
|
2019-11-06 01:34:09 +00:00
|
|
|
test_expect_success 'setup tests' '
|
commit-reach: use corrected commit dates in paint_down_to_common()
091f4cf (commit: don't use generation numbers if not needed,
2018-08-30) changed paint_down_to_common() to use commit dates instead
of generation numbers v1 (topological levels) as the performance
regressed on certain topologies. With generation number v2 (corrected
commit dates) implemented, we no longer have to rely on commit dates and
can use generation numbers.
For example, the command `git merge-base v4.8 v4.9` on the Linux
repository walks 167468 commits, taking 0.135s for committer date and
167496 commits, taking 0.157s for corrected committer date respectively.
While using corrected commit dates, Git walks nearly the same number of
commits as commit date, the process is slower as for each comparision we
have to access a commit-slab (for corrected committer date) instead of
accessing struct member (for committer date).
This change incidentally broke the fragile t6404-recursive-merge test.
t6404-recursive-merge sets up a unique repository where all commits have
the same committer date without a well-defined merge-base.
While running tests with GIT_TEST_COMMIT_GRAPH unset, we use committer
date as a heuristic in paint_down_to_common(). 6404.1 'combined merge
conflicts' merges commits in the order:
- Merge C with B to form an intermediate commit.
- Merge the intermediate commit with A.
With GIT_TEST_COMMIT_GRAPH=1, we write a commit-graph and subsequently
use the corrected committer date, which changes the order in which
commits are merged:
- Merge A with B to form an intermediate commit.
- Merge the intermediate commit with C.
While resulting repositories are equivalent, 6404.4 'virtual trees were
processed' fails with GIT_TEST_COMMIT_GRAPH=1 as we are selecting
different merge-bases and thus have different object ids for the
intermediate commits.
As this has already causes problems (as noted in 859fdc0 (commit-graph:
define GIT_TEST_COMMIT_GRAPH, 2018-08-29)), we disable commit graph
within t6404-recursive-merge.
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-16 18:11:17 +00:00
|
|
|
GIT_TEST_COMMIT_GRAPH=0 &&
|
|
|
|
export GIT_TEST_COMMIT_GRAPH &&
|
2019-11-06 01:34:09 +00:00
|
|
|
echo 1 >a1 &&
|
|
|
|
git add a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 &&
|
|
|
|
|
2020-11-18 23:44:38 +00:00
|
|
|
git checkout -b A main &&
|
2019-11-06 01:34:09 +00:00
|
|
|
echo A >a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 &&
|
|
|
|
|
2020-11-18 23:44:38 +00:00
|
|
|
git checkout -b B main &&
|
2019-11-06 01:34:09 +00:00
|
|
|
echo B >a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 &&
|
|
|
|
|
|
|
|
git checkout -b D A &&
|
|
|
|
git rev-parse B >.git/MERGE_HEAD &&
|
|
|
|
echo D >a1 &&
|
|
|
|
git update-index a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
|
|
|
|
|
|
|
|
git symbolic-ref HEAD refs/heads/other &&
|
|
|
|
echo 2 >a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 &&
|
|
|
|
|
|
|
|
git checkout -b C &&
|
|
|
|
echo C >a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
|
|
|
|
|
|
|
|
git checkout -b E C &&
|
|
|
|
git rev-parse B >.git/MERGE_HEAD &&
|
|
|
|
echo E >a1 &&
|
|
|
|
git update-index a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
|
|
|
|
|
|
|
|
git checkout -b G E &&
|
|
|
|
git rev-parse A >.git/MERGE_HEAD &&
|
|
|
|
echo G >a1 &&
|
|
|
|
git update-index a1 &&
|
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
|
|
|
|
|
|
|
|
git checkout -b F D &&
|
|
|
|
git rev-parse C >.git/MERGE_HEAD &&
|
|
|
|
echo F >a1 &&
|
|
|
|
git update-index a1 &&
|
2020-02-07 00:52:54 +00:00
|
|
|
GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F &&
|
|
|
|
|
|
|
|
test_oid_cache <<-EOF
|
|
|
|
idxstage1 sha1:ec3fe2a791706733f2d8fa7ad45d9a9672031f5e
|
|
|
|
idxstage1 sha256:b3c8488929903aaebdeb22270cb6d36e5b8724b01ae0d4da24632f158c99676f
|
|
|
|
EOF
|
2006-12-28 09:10:50 +00:00
|
|
|
'
|
2006-12-13 00:36:16 +00:00
|
|
|
|
2018-08-29 12:49:04 +00:00
|
|
|
test_expect_success 'combined merge conflicts' '
|
commit-reach: use corrected commit dates in paint_down_to_common()
091f4cf (commit: don't use generation numbers if not needed,
2018-08-30) changed paint_down_to_common() to use commit dates instead
of generation numbers v1 (topological levels) as the performance
regressed on certain topologies. With generation number v2 (corrected
commit dates) implemented, we no longer have to rely on commit dates and
can use generation numbers.
For example, the command `git merge-base v4.8 v4.9` on the Linux
repository walks 167468 commits, taking 0.135s for committer date and
167496 commits, taking 0.157s for corrected committer date respectively.
While using corrected commit dates, Git walks nearly the same number of
commits as commit date, the process is slower as for each comparision we
have to access a commit-slab (for corrected committer date) instead of
accessing struct member (for committer date).
This change incidentally broke the fragile t6404-recursive-merge test.
t6404-recursive-merge sets up a unique repository where all commits have
the same committer date without a well-defined merge-base.
While running tests with GIT_TEST_COMMIT_GRAPH unset, we use committer
date as a heuristic in paint_down_to_common(). 6404.1 'combined merge
conflicts' merges commits in the order:
- Merge C with B to form an intermediate commit.
- Merge the intermediate commit with A.
With GIT_TEST_COMMIT_GRAPH=1, we write a commit-graph and subsequently
use the corrected committer date, which changes the order in which
commits are merged:
- Merge A with B to form an intermediate commit.
- Merge the intermediate commit with C.
While resulting repositories are equivalent, 6404.4 'virtual trees were
processed' fails with GIT_TEST_COMMIT_GRAPH=1 as we are selecting
different merge-bases and thus have different object ids for the
intermediate commits.
As this has already causes problems (as noted in 859fdc0 (commit-graph:
define GIT_TEST_COMMIT_GRAPH, 2018-08-29)), we disable commit graph
within t6404-recursive-merge.
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-16 18:11:17 +00:00
|
|
|
test_must_fail git merge -m final G
|
2018-08-29 12:49:04 +00:00
|
|
|
'
|
2006-12-13 00:36:16 +00:00
|
|
|
|
2019-11-06 01:34:09 +00:00
|
|
|
test_expect_success 'result contains a conflict' '
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
<<<<<<< HEAD
|
|
|
|
F
|
|
|
|
=======
|
|
|
|
G
|
|
|
|
>>>>>>> G
|
|
|
|
EOF
|
2006-12-13 03:05:39 +00:00
|
|
|
|
2019-11-06 01:34:09 +00:00
|
|
|
test_cmp expect a1
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'virtual trees were processed' '
|
commit-reach: use corrected commit dates in paint_down_to_common()
091f4cf (commit: don't use generation numbers if not needed,
2018-08-30) changed paint_down_to_common() to use commit dates instead
of generation numbers v1 (topological levels) as the performance
regressed on certain topologies. With generation number v2 (corrected
commit dates) implemented, we no longer have to rely on commit dates and
can use generation numbers.
For example, the command `git merge-base v4.8 v4.9` on the Linux
repository walks 167468 commits, taking 0.135s for committer date and
167496 commits, taking 0.157s for corrected committer date respectively.
While using corrected commit dates, Git walks nearly the same number of
commits as commit date, the process is slower as for each comparision we
have to access a commit-slab (for corrected committer date) instead of
accessing struct member (for committer date).
This change incidentally broke the fragile t6404-recursive-merge test.
t6404-recursive-merge sets up a unique repository where all commits have
the same committer date without a well-defined merge-base.
While running tests with GIT_TEST_COMMIT_GRAPH unset, we use committer
date as a heuristic in paint_down_to_common(). 6404.1 'combined merge
conflicts' merges commits in the order:
- Merge C with B to form an intermediate commit.
- Merge the intermediate commit with A.
With GIT_TEST_COMMIT_GRAPH=1, we write a commit-graph and subsequently
use the corrected committer date, which changes the order in which
commits are merged:
- Merge A with B to form an intermediate commit.
- Merge the intermediate commit with C.
While resulting repositories are equivalent, 6404.4 'virtual trees were
processed' fails with GIT_TEST_COMMIT_GRAPH=1 as we are selecting
different merge-bases and thus have different object ids for the
intermediate commits.
As this has already causes problems (as noted in 859fdc0 (commit-graph:
define GIT_TEST_COMMIT_GRAPH, 2018-08-29)), we disable commit graph
within t6404-recursive-merge.
Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-16 18:11:17 +00:00
|
|
|
# TODO: fragile test, relies on ambigious merge-base resolution
|
2019-11-06 01:34:09 +00:00
|
|
|
git ls-files --stage >out &&
|
2006-12-13 03:05:39 +00:00
|
|
|
|
2020-02-07 00:52:54 +00:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
100644 $(test_oid idxstage1) 1 a1
|
|
|
|
100644 $(git rev-parse F:a1) 2 a1
|
|
|
|
100644 $(git rev-parse G:a1) 3 a1
|
2019-11-06 01:34:09 +00:00
|
|
|
EOF
|
2006-12-13 00:36:16 +00:00
|
|
|
|
2019-11-06 01:34:09 +00:00
|
|
|
test_cmp expect out
|
|
|
|
'
|
2006-12-13 00:36:16 +00:00
|
|
|
|
2007-06-05 02:36:49 +00:00
|
|
|
test_expect_success 'refuse to merge binary files' '
|
2008-03-01 09:10:12 +00:00
|
|
|
git reset --hard &&
|
2019-11-06 01:34:09 +00:00
|
|
|
printf "\0" >binary-file &&
|
2007-06-05 02:36:49 +00:00
|
|
|
git add binary-file &&
|
|
|
|
git commit -m binary &&
|
|
|
|
git checkout G &&
|
2019-11-06 01:34:09 +00:00
|
|
|
printf "\0\0" >binary-file &&
|
2007-06-05 02:36:49 +00:00
|
|
|
git add binary-file &&
|
|
|
|
git commit -m binary2 &&
|
2022-02-02 02:37:31 +00:00
|
|
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
|
|
|
then
|
|
|
|
test_must_fail git merge F >merge_output
|
|
|
|
else
|
|
|
|
test_must_fail git merge F 2>merge_output
|
|
|
|
fi &&
|
|
|
|
grep "Cannot merge binary files: binary-file (HEAD vs. F)" merge_output
|
2007-06-05 02:36:49 +00:00
|
|
|
'
|
|
|
|
|
2008-12-22 22:10:20 +00:00
|
|
|
test_expect_success 'mark rename/delete as unmerged' '
|
|
|
|
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout -b delete &&
|
|
|
|
git rm a1 &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m delete &&
|
|
|
|
git checkout -b rename HEAD^ &&
|
2010-10-31 01:46:54 +00:00
|
|
|
git mv a1 a2 &&
|
2008-12-22 22:10:20 +00:00
|
|
|
test_tick &&
|
|
|
|
git commit -m rename &&
|
|
|
|
test_must_fail git merge delete &&
|
2020-10-26 17:01:39 +00:00
|
|
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
|
|
|
then
|
|
|
|
test 2 = $(git ls-files --unmerged | wc -l)
|
|
|
|
else
|
|
|
|
test 1 = $(git ls-files --unmerged | wc -l)
|
|
|
|
fi &&
|
2008-12-22 22:10:20 +00:00
|
|
|
git rev-parse --verify :2:a2 &&
|
|
|
|
test_must_fail git rev-parse --verify :3:a2 &&
|
|
|
|
git checkout -f delete &&
|
|
|
|
test_must_fail git merge rename &&
|
2020-10-26 17:01:39 +00:00
|
|
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
|
|
|
then
|
|
|
|
test 2 = $(git ls-files --unmerged | wc -l)
|
|
|
|
else
|
|
|
|
test 1 = $(git ls-files --unmerged | wc -l)
|
|
|
|
fi &&
|
2008-12-22 22:10:20 +00:00
|
|
|
test_must_fail git rev-parse --verify :2:a2 &&
|
|
|
|
git rev-parse --verify :3:a2
|
|
|
|
'
|
|
|
|
|
2006-12-13 00:36:16 +00:00
|
|
|
test_done
|