2010-07-14 17:04:06 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2010 Will Palmer
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='git merge-tree'
|
2021-10-12 13:56:45 +00:00
|
|
|
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2010-07-14 17:04:06 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
test_commit "initial" "initial-file" "initial"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file add A, !B' '
|
2019-12-21 19:49:23 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "add-a-not-b" "ONE" "AAA" &&
|
|
|
|
git merge-tree initial initial add-a-not-b >actual &&
|
|
|
|
cat >expected <<EXPECTED &&
|
2010-07-14 17:04:06 +00:00
|
|
|
added in remote
|
2019-12-21 19:49:23 +00:00
|
|
|
their 100644 $(git rev-parse HEAD:ONE) ONE
|
2010-07-14 17:04:06 +00:00
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+AAA
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2010-07-14 17:04:07 +00:00
|
|
|
test_expect_success 'file add !A, B' '
|
2010-07-14 17:04:06 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "add-not-a-b" "ONE" "AAA" &&
|
|
|
|
git merge-tree initial add-not-a-b initial >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2010-07-14 17:04:06 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file add A, B (same)' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "add-a-b-same-A" "ONE" "AAA" &&
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "add-a-b-same-B" "ONE" "AAA" &&
|
|
|
|
git merge-tree initial add-a-b-same-A add-a-b-same-B >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2010-07-14 17:04:06 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file add A, B (different)' '
|
2019-12-21 19:49:23 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "add-a-b-diff-A" "ONE" "AAA" &&
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "add-a-b-diff-B" "ONE" "BBB" &&
|
|
|
|
git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual &&
|
|
|
|
cat >expected <<EXPECTED &&
|
2010-07-14 17:04:06 +00:00
|
|
|
added in both
|
2019-12-21 19:49:23 +00:00
|
|
|
our 100644 $(git rev-parse add-a-b-diff-A:ONE) ONE
|
|
|
|
their 100644 $(git rev-parse add-a-b-diff-B:ONE) ONE
|
2010-07-14 17:04:06 +00:00
|
|
|
@@ -1 +1,5 @@
|
|
|
|
+<<<<<<< .our
|
|
|
|
AAA
|
|
|
|
+=======
|
|
|
|
+BBB
|
|
|
|
+>>>>>>> .their
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file change A, !B' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-a-not-b" "initial-file" "BBB" &&
|
|
|
|
git merge-tree initial change-a-not-b initial >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2010-07-14 17:04:06 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file change !A, B' '
|
2019-12-21 19:49:23 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-not-a-b" "initial-file" "BBB" &&
|
|
|
|
git merge-tree initial initial change-not-a-b >actual &&
|
|
|
|
cat >expected <<EXPECTED &&
|
2010-07-14 17:04:06 +00:00
|
|
|
merged
|
2019-12-21 19:49:23 +00:00
|
|
|
result 100644 $(git rev-parse change-a-not-b:initial-file) initial-file
|
|
|
|
our 100644 $(git rev-parse initial:initial-file ) initial-file
|
2010-07-14 17:04:06 +00:00
|
|
|
@@ -1 +1 @@
|
|
|
|
-initial
|
|
|
|
+BBB
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file change A, B (same)' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-a-b-same-A" "initial-file" "AAA" &&
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-a-b-same-B" "initial-file" "AAA" &&
|
|
|
|
git merge-tree initial change-a-b-same-A change-a-b-same-B >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2010-07-14 17:04:06 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file change A, B (different)' '
|
2019-12-21 19:49:23 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-a-b-diff-A" "initial-file" "AAA" &&
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-a-b-diff-B" "initial-file" "BBB" &&
|
|
|
|
git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual &&
|
|
|
|
cat >expected <<EXPECTED &&
|
2010-07-14 17:04:06 +00:00
|
|
|
changed in both
|
2019-12-21 19:49:23 +00:00
|
|
|
base 100644 $(git rev-parse initial:initial-file ) initial-file
|
|
|
|
our 100644 $(git rev-parse change-a-b-diff-A:initial-file) initial-file
|
|
|
|
their 100644 $(git rev-parse change-a-b-diff-B:initial-file) initial-file
|
2010-07-14 17:04:06 +00:00
|
|
|
@@ -1 +1,5 @@
|
|
|
|
+<<<<<<< .our
|
|
|
|
AAA
|
|
|
|
+=======
|
|
|
|
+BBB
|
|
|
|
+>>>>>>> .their
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file change A, B (mixed)' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-a-b-mix-base" "ONE" "
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA" &&
|
|
|
|
test_commit "change-a-b-mix-A" "ONE" \
|
|
|
|
"$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/BBB/;}" <ONE)" &&
|
|
|
|
git reset --hard change-a-b-mix-base &&
|
|
|
|
test_commit "change-a-b-mix-B" "ONE" \
|
|
|
|
"$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/CCC/;}" <ONE)" &&
|
|
|
|
git merge-tree change-a-b-mix-base change-a-b-mix-A change-a-b-mix-B \
|
|
|
|
>actual &&
|
2019-12-21 19:49:23 +00:00
|
|
|
|
|
|
|
cat >expected <<EXPECTED &&
|
|
|
|
changed in both
|
|
|
|
base 100644 $(git rev-parse change-a-b-mix-base:ONE) ONE
|
|
|
|
our 100644 $(git rev-parse change-a-b-mix-A:ONE ) ONE
|
|
|
|
their 100644 $(git rev-parse change-a-b-mix-B:ONE ) ONE
|
|
|
|
@@ -7,7 +7,11 @@
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
+<<<<<<< .our
|
|
|
|
BBB
|
|
|
|
+=======
|
|
|
|
+CCC
|
|
|
|
+>>>>>>> .their
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
AAA
|
|
|
|
EXPECTED
|
|
|
|
|
2010-07-14 17:04:06 +00:00
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file remove A, !B' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "rm-a-not-b-base" "ONE" "AAA" &&
|
|
|
|
git rm ONE &&
|
|
|
|
git commit -m "rm-a-not-b" &&
|
|
|
|
git tag "rm-a-not-b" &&
|
|
|
|
git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2010-07-14 17:04:06 +00:00
|
|
|
'
|
|
|
|
|
2010-07-14 17:04:07 +00:00
|
|
|
test_expect_success 'file remove !A, B' '
|
2010-07-14 17:04:06 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "rm-not-a-b-base" "ONE" "AAA" &&
|
|
|
|
git rm ONE &&
|
|
|
|
git commit -m "rm-not-a-b" &&
|
|
|
|
git tag "rm-not-a-b" &&
|
|
|
|
git merge-tree rm-a-not-b-base rm-a-not-b-base rm-a-not-b >actual &&
|
2019-12-21 19:49:23 +00:00
|
|
|
cat >expected <<EXPECTED &&
|
|
|
|
removed in remote
|
|
|
|
base 100644 $(git rev-parse rm-a-not-b-base:ONE) ONE
|
|
|
|
our 100644 $(git rev-parse rm-a-not-b-base:ONE) ONE
|
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-AAA
|
|
|
|
EXPECTED
|
|
|
|
|
2010-07-14 17:04:06 +00:00
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2013-04-27 13:40:33 +00:00
|
|
|
test_expect_success 'file remove A, B (same)' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "rm-a-b-base" "ONE" "AAA" &&
|
|
|
|
git rm ONE &&
|
|
|
|
git commit -m "rm-a-b" &&
|
|
|
|
git tag "rm-a-b" &&
|
|
|
|
git merge-tree rm-a-b-base rm-a-b rm-a-b >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2013-04-27 13:40:33 +00:00
|
|
|
'
|
|
|
|
|
2010-07-14 17:04:07 +00:00
|
|
|
test_expect_success 'file change A, remove B' '
|
2010-07-14 17:04:06 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "change-a-rm-b-base" "ONE" "AAA" &&
|
|
|
|
test_commit "change-a-rm-b-A" "ONE" "BBB" &&
|
|
|
|
git reset --hard change-a-rm-b-base &&
|
|
|
|
git rm ONE &&
|
|
|
|
git commit -m "change-a-rm-b-B" &&
|
|
|
|
git tag "change-a-rm-b-B" &&
|
|
|
|
git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \
|
|
|
|
>actual &&
|
2019-12-21 19:49:23 +00:00
|
|
|
cat >expected <<EXPECTED &&
|
|
|
|
removed in remote
|
|
|
|
base 100644 $(git rev-parse change-a-rm-b-base:ONE) ONE
|
|
|
|
our 100644 $(git rev-parse change-a-rm-b-A:ONE ) ONE
|
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-BBB
|
|
|
|
EXPECTED
|
|
|
|
|
2010-07-14 17:04:06 +00:00
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'file remove A, change B' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
test_commit "rm-a-change-b-base" "ONE" "AAA" &&
|
|
|
|
|
|
|
|
git rm ONE &&
|
|
|
|
git commit -m "rm-a-change-b-A" &&
|
|
|
|
git tag "rm-a-change-b-A" &&
|
|
|
|
git reset --hard rm-a-change-b-base &&
|
|
|
|
test_commit "rm-a-change-b-B" "ONE" "BBB" &&
|
|
|
|
git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \
|
|
|
|
>actual &&
|
2019-12-21 19:49:23 +00:00
|
|
|
cat >expected <<EXPECTED &&
|
|
|
|
removed in local
|
|
|
|
base 100644 $(git rev-parse rm-a-change-b-base:ONE) ONE
|
|
|
|
their 100644 $(git rev-parse rm-a-change-b-B:ONE ) ONE
|
|
|
|
EXPECTED
|
2010-07-14 17:04:06 +00:00
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2013-05-06 15:20:54 +00:00
|
|
|
test_expect_success 'tree add A, B (same)' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
mkdir sub &&
|
|
|
|
test_commit "add sub/file" "sub/file" "file" add-tree-A &&
|
|
|
|
git merge-tree initial add-tree-A add-tree-A >actual &&
|
tests: use 'test_must_be_empty' instead of 'test_cmp <empty> <out>'
Using 'test_must_be_empty' is shorter and more idiomatic than
>empty &&
test_cmp empty out
as it saves the creation of an empty file. Furthermore, sometimes the
expected empty file doesn't have such a descriptive name like 'empty',
and its creation is far away from the place where it's finally used
for comparison (e.g. in 't7600-merge.sh', where two expected empty
files are created in the 'setup' test, but are used only about 500
lines later).
These cases were found by instrumenting 'test_cmp' to error out the
test script when it's used to compare empty files, and then converted
manually.
Note that even after this patch there still remain a lot of cases
where we use 'test_cmp' to check empty files:
- Sometimes the expected output is not hard-coded in the test, but
'test_cmp' is used to ensure that two similar git commands produce
the same output, and that output happens to be empty, e.g. the
test 'submodule update --merge - ignores --merge for new
submodules' in 't7406-submodule-update.sh'.
- Repetitive common tasks, including preparing the expected results
and running 'test_cmp', are often extracted into a helper
function, and some of this helper's callsites expect no output.
- For the same reason as above, the whole 'test_expect_success'
block is within a helper function, e.g. in 't3070-wildmatch.sh'.
- Or 'test_cmp' is invoked in a loop, e.g. the test 'cvs update
(-p)' in 't9400-git-cvsserver-server.sh'.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-08-19 21:57:25 +00:00
|
|
|
test_must_be_empty actual
|
2013-05-06 15:20:54 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'tree add A, B (different)' '
|
2019-12-21 19:49:23 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
mkdir sub &&
|
|
|
|
test_commit "add sub/file" "sub/file" "AAA" add-tree-a-b-A &&
|
|
|
|
git reset --hard initial &&
|
|
|
|
mkdir sub &&
|
|
|
|
test_commit "add sub/file" "sub/file" "BBB" add-tree-a-b-B &&
|
|
|
|
git merge-tree initial add-tree-a-b-A add-tree-a-b-B >actual &&
|
|
|
|
cat >expect <<-EOF &&
|
2013-05-06 15:20:54 +00:00
|
|
|
added in both
|
2019-12-21 19:49:23 +00:00
|
|
|
our 100644 $(git rev-parse add-tree-a-b-A:sub/file) sub/file
|
|
|
|
their 100644 $(git rev-parse add-tree-a-b-B:sub/file) sub/file
|
2013-05-06 15:20:54 +00:00
|
|
|
@@ -1 +1,5 @@
|
|
|
|
+<<<<<<< .our
|
|
|
|
AAA
|
|
|
|
+=======
|
|
|
|
+BBB
|
|
|
|
+>>>>>>> .their
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'tree unchanged A, removed B' '
|
|
|
|
git reset --hard initial &&
|
|
|
|
mkdir sub &&
|
|
|
|
test_commit "add sub/file" "sub/file" "AAA" tree-remove-b-initial &&
|
|
|
|
git rm sub/file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m "remove sub/file" &&
|
|
|
|
git tag tree-remove-b-B &&
|
|
|
|
git merge-tree tree-remove-b-initial tree-remove-b-initial tree-remove-b-B >actual &&
|
2019-12-21 19:49:23 +00:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
removed in remote
|
|
|
|
base 100644 $(git rev-parse tree-remove-b-initial:sub/file) sub/file
|
|
|
|
our 100644 $(git rev-parse tree-remove-b-initial:sub/file) sub/file
|
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-AAA
|
|
|
|
EOF
|
2013-05-06 15:20:54 +00:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2012-12-13 23:51:29 +00:00
|
|
|
test_expect_success 'turn file to tree' '
|
2012-12-07 00:15:45 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
rm initial-file &&
|
|
|
|
mkdir initial-file &&
|
|
|
|
test_commit "turn-file-to-tree" "initial-file/ONE" "CCC" &&
|
|
|
|
git merge-tree initial initial turn-file-to-tree >actual &&
|
2019-12-21 19:49:23 +00:00
|
|
|
cat >expect <<-EOF &&
|
2012-12-07 00:15:45 +00:00
|
|
|
added in remote
|
2019-12-21 19:49:23 +00:00
|
|
|
their 100644 $(git rev-parse turn-file-to-tree:initial-file/ONE) initial-file/ONE
|
2012-12-07 00:15:45 +00:00
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+CCC
|
|
|
|
removed in remote
|
2019-12-21 19:49:23 +00:00
|
|
|
base 100644 $(git rev-parse initial:initial-file) initial-file
|
|
|
|
our 100644 $(git rev-parse initial:initial-file) initial-file
|
2012-12-07 00:15:45 +00:00
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-initial
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2012-12-13 23:51:29 +00:00
|
|
|
test_expect_success 'turn tree to file' '
|
2012-12-07 00:15:45 +00:00
|
|
|
git reset --hard initial &&
|
|
|
|
mkdir dir &&
|
|
|
|
test_commit "add-tree" "dir/path" "AAA" &&
|
|
|
|
test_commit "add-another-tree" "dir/another" "BBB" &&
|
|
|
|
rm -fr dir &&
|
|
|
|
test_commit "make-file" "dir" "CCC" &&
|
|
|
|
git merge-tree add-tree add-another-tree make-file >actual &&
|
2019-12-21 19:49:23 +00:00
|
|
|
cat >expect <<-EOF &&
|
2012-12-07 00:15:45 +00:00
|
|
|
removed in remote
|
2019-12-21 19:49:23 +00:00
|
|
|
base 100644 $(git rev-parse add-tree:dir/path) dir/path
|
|
|
|
our 100644 $(git rev-parse add-tree:dir/path) dir/path
|
2012-12-07 00:15:45 +00:00
|
|
|
@@ -1 +0,0 @@
|
|
|
|
-AAA
|
|
|
|
added in remote
|
2019-12-21 19:49:23 +00:00
|
|
|
their 100644 $(git rev-parse make-file:dir) dir
|
2012-12-07 00:15:45 +00:00
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+CCC
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2023-05-10 19:07:34 +00:00
|
|
|
test_expect_success 'merge-tree respects core.useReplaceRefs=false' '
|
|
|
|
test_commit merge-to &&
|
|
|
|
test_commit valid base &&
|
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
test_commit malicious base &&
|
|
|
|
|
|
|
|
test_when_finished "git replace -d $(git rev-parse valid^0)" &&
|
|
|
|
git replace valid^0 malicious^0 &&
|
|
|
|
|
|
|
|
tree=$(git -c core.useReplaceRefs=true merge-tree --write-tree merge-to valid) &&
|
|
|
|
merged=$(git cat-file -p $tree:base) &&
|
|
|
|
test malicious = $merged &&
|
|
|
|
|
|
|
|
tree=$(git -c core.useReplaceRefs=false merge-tree --write-tree merge-to valid) &&
|
|
|
|
merged=$(git cat-file -p $tree:base) &&
|
|
|
|
test valid = $merged
|
|
|
|
'
|
|
|
|
|
2010-07-14 17:04:06 +00:00
|
|
|
test_done
|