t6036, t6043: increase code coverage for file collision handling
Stolee's coverage reports found a few code blocks for file collision conflicts that had not previously been covered by testcases; add a few more testcases to cover those too. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
48c9cb9d6d
commit
b8cd1bb713
@ -240,6 +240,57 @@ test_expect_success 'git detects differently handled merges conflict' '
|
||||
)
|
||||
'
|
||||
|
||||
# Repeat the above testcase with precisely the same setup, other than with
|
||||
# the two merge bases having different orderings of commit timestamps so
|
||||
# that they are reversed in the order they are provided to merge-recursive,
|
||||
# so that we can improve code coverage.
|
||||
test_expect_success 'git detects differently handled merges conflict, swapped' '
|
||||
(
|
||||
cd rename-add &&
|
||||
|
||||
# Difference #1: Do cleanup from previous testrun
|
||||
git reset --hard &&
|
||||
git clean -fdqx &&
|
||||
|
||||
# Difference #2: Change commit timestamps
|
||||
btime=$(git log --no-walk --date=raw --format=%cd B | awk "{print \$1}") &&
|
||||
ctime=$(git log --no-walk --date=raw --format=%cd C | awk "{print \$1}") &&
|
||||
newctime=$(($btime+1)) &&
|
||||
git fast-export --no-data --all | sed -e s/$ctime/$newctime/ | git fast-import --force --quiet &&
|
||||
# End of differences; rest is copy-paste of last test
|
||||
|
||||
git checkout D^0 &&
|
||||
test_must_fail git merge -s recursive E^0 &&
|
||||
|
||||
git ls-files -s >out &&
|
||||
test_line_count = 3 out &&
|
||||
git ls-files -u >out &&
|
||||
test_line_count = 3 out &&
|
||||
git ls-files -o >out &&
|
||||
test_line_count = 1 out &&
|
||||
|
||||
git rev-parse >expect \
|
||||
C:new_a D:new_a E:new_a &&
|
||||
git rev-parse >actual \
|
||||
:1:new_a :2:new_a :3:new_a &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
# Test that the two-way merge in new_a is as expected
|
||||
git cat-file -p D:new_a >ours &&
|
||||
git cat-file -p E:new_a >theirs &&
|
||||
>empty &&
|
||||
test_must_fail git merge-file \
|
||||
-L "HEAD" \
|
||||
-L "" \
|
||||
-L "E^0" \
|
||||
ours empty theirs &&
|
||||
sed -e "s/^\([<=>]\)/\1\1\1/" ours >expect &&
|
||||
git hash-object new_a >actual &&
|
||||
git hash-object ours >expect &&
|
||||
test_cmp expect actual
|
||||
)
|
||||
'
|
||||
|
||||
#
|
||||
# criss-cross + modify/delete:
|
||||
#
|
||||
|
@ -3163,6 +3163,43 @@ test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2)
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success '10c-check: Overwrite untracked with dir rename/rename(1to2), other direction' '
|
||||
(
|
||||
cd 10c &&
|
||||
|
||||
git reset --hard &&
|
||||
git clean -fdqx &&
|
||||
|
||||
git checkout B^0 &&
|
||||
mkdir y &&
|
||||
echo important >y/c &&
|
||||
|
||||
test_must_fail git merge -s recursive A^0 >out 2>err &&
|
||||
test_i18ngrep "CONFLICT (rename/rename)" out &&
|
||||
test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~HEAD instead" out &&
|
||||
|
||||
git ls-files -s >out &&
|
||||
test_line_count = 6 out &&
|
||||
git ls-files -u >out &&
|
||||
test_line_count = 3 out &&
|
||||
git ls-files -o >out &&
|
||||
test_line_count = 3 out &&
|
||||
|
||||
git rev-parse >actual \
|
||||
:0:y/a :0:y/b :0:x/d :1:x/c :3:w/c :2:y/c &&
|
||||
git rev-parse >expect \
|
||||
O:z/a O:z/b O:x/d O:x/c O:x/c O:x/c &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
git hash-object y/c~HEAD >actual &&
|
||||
git rev-parse O:x/c >expect &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
echo important >expect &&
|
||||
test_cmp expect y/c
|
||||
)
|
||||
'
|
||||
|
||||
# Testcase 10d, Delete untracked w/ dir rename/rename(2to1)
|
||||
# Commit O: z/{a,b,c_1}, x/{d,e,f_2}
|
||||
# Commit A: y/{a,b}, x/{d,e,f_2,wham_1} + untracked y/wham
|
||||
|
Loading…
Reference in New Issue
Block a user