. ./test-lib.sh
-get_clean_checkout () {
- git reset --hard &&
- git clean -fdqx &&
- git checkout "$1"
-}
-
#
# L1 L2
# o---o
git ls-files -o >out &&
test_line_count = 3 out &&
- test $(git rev-parse :2:three) = $(git rev-parse L2:three) &&
- test $(git rev-parse :3:three) = $(git rev-parse R2:three) &&
-
- test $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&
- test $(git rev-parse R2:three) = $(git hash-object three~R2^0)
+ git rev-parse >expect \
+ L2:three R2:three \
+ L2:three R2:three &&
+ git rev-parse >actual \
+ :2:three :3:three &&
+ git hash-object >>actual \
+ three~HEAD three~R2^0
+ test_cmp expect actual
)
'
git ls-files -o >out &&
test_line_count = 3 out &&
- test $(git rev-parse :2:three) = $(git rev-parse L2:three) &&
- test $(git rev-parse :3:three) = $(git rev-parse R2:three) &&
-
- test $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&
- test $(git rev-parse R2:three) = $(git hash-object three~R2^0)
+ git rev-parse >expect \
+ L2:three R2:three \
+ L2:three R2:three &&
+ git rev-parse >actual \
+ :2:three :3:three &&
+ git hash-object >>actual \
+ three~HEAD three~R2^0
+ test_cmp expect actual
)
'
git ls-files -o >out &&
test_line_count = 1 out &&
- test $(git rev-parse :2:new_a) = $(git rev-parse D:new_a) &&
- test $(git rev-parse :3:new_a) = $(git rev-parse E:new_a) &&
+ git rev-parse >expect \
+ D:new_a E:new_a &&
+ git rev-parse >actual \
+ :2:new_a :3:new_a &&
+ test_cmp expect actual
- git cat-file -p B:new_a >>merged &&
- git cat-file -p C:new_a >>merge-me &&
+ git cat-file -p B:new_a >ours &&
+ git cat-file -p C:new_a >theirs &&
>empty &&
test_must_fail git merge-file \
-L "Temporary merge branch 2" \
-L "" \
-L "Temporary merge branch 1" \
- merged empty merge-me &&
- sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal &&
- test $(git rev-parse :1:new_a) = $(git hash-object merged-internal)
+ ours empty theirs &&
+ sed -e "s/^\([<=>]\)/\1\1\1/" ours >expect &&
+ git cat-file -p :1:new_a >actual &&
+ test_cmp expect actual
)
'
git ls-files -u >out &&
test_line_count = 2 out &&
- test $(git rev-parse :1:file) = $(git rev-parse master:file) &&
- test $(git rev-parse :2:file) = $(git rev-parse B:file)
+ git rev-parse >expect \
+ master:file B:file &&
+ git rev-parse >actual \
+ :1:file :2:file &&
+ test_cmp expect actual
)
'
git ls-files -u >out &&
test_line_count = 2 out &&
- test $(git rev-parse :1:file) = $(git rev-parse master:file) &&
- test $(git rev-parse :3:file) = $(git rev-parse B:file)
+ git rev-parse >expect \
+ master:file B:file &&
+ git rev-parse >actual \
+ :1:file :3:file &&
+ test_cmp expect actual
)
'
'
test_expect_success 'merge of D & E1 fails but has appropriate contents' '
+ test_when_finished "git -C directory-file reset --hard" &&
+ test_when_finished "git -C directory-file clean -fdqx" &&
(
cd directory-file &&
- get_clean_checkout D^0 &&
+ git checkout D^0 &&
test_must_fail git merge -s recursive E1^0 &&
git ls-files -o >out &&
test_line_count = 1 out &&
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
- test $(git rev-parse :2:a) = $(git rev-parse B:a)
+ git rev-parse >expect \
+ A:ignore-me B:a &&
+ git rev-parse >actual \
+ :0:ignore-me :2:a &&
+ test_cmp expect actual
)
'
test_expect_success 'merge of E1 & D fails but has appropriate contents' '
+ test_when_finished "git -C directory-file reset --hard" &&
+ test_when_finished "git -C directory-file clean -fdqx" &&
(
cd directory-file &&
- get_clean_checkout E1^0 &&
+ git checkout E1^0 &&
test_must_fail git merge -s recursive D^0 &&
git ls-files -o >out &&
test_line_count = 1 out &&
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
- test $(git rev-parse :3:a) = $(git rev-parse B:a)
+ git rev-parse >expect \
+ A:ignore-me B:a &&
+ git rev-parse >actual \
+ :0:ignore-me :3:a &&
+ test_cmp expect actual
)
'
test_expect_success 'merge of D & E2 fails but has appropriate contents' '
+ test_when_finished "git -C directory-file reset --hard" &&
+ test_when_finished "git -C directory-file clean -fdqx" &&
(
cd directory-file &&
- get_clean_checkout D^0 &&
+ git checkout D^0 &&
test_must_fail git merge -s recursive E2^0 &&
git ls-files -o >out &&
test_line_count = 2 out &&
- test $(git rev-parse :2:a) = $(git rev-parse B:a) &&
- test $(git rev-parse :3:a/file) = $(git rev-parse E2:a/file) &&
- test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
+ git rev-parse >expect \
+ B:a E2:a/file c:a/file A:ignore-me &&
+ git rev-parse >actual \
+ :2:a :3:a/file :1:a/file :0:ignore-me &&
+ test_cmp expect actual
- test -f a~HEAD
+ test_path_is_file a~HEAD
)
'
test_expect_success 'merge of E2 & D fails but has appropriate contents' '
+ test_when_finished "git -C directory-file reset --hard" &&
+ test_when_finished "git -C directory-file clean -fdqx" &&
(
cd directory-file &&
- get_clean_checkout E2^0 &&
+ git checkout E2^0 &&
test_must_fail git merge -s recursive D^0 &&
git ls-files -o >out &&
test_line_count = 2 out &&
- test $(git rev-parse :3:a) = $(git rev-parse B:a) &&
- test $(git rev-parse :2:a/file) = $(git rev-parse E2:a/file) &&
- test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
- test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
+ git rev-parse >expect \
+ B:a E2:a/file c:a/file A:ignore-me &&
+ git rev-parse >actual \
+ :3:a :2:a/file :1:a/file :0:ignore-me &&
+ test_cmp expect actual
- test -f a~D^0
+ test_path_is_file a~D^0
)
'
git ls-files -o >out &&
test_line_count = 1 out &&
- test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
- test $(git rev-parse HEAD:c) = $(git rev-parse A:a) &&
- test "$(cat a)" = "$(printf "1\n2\n3\n4\n5\n6\n7\n8\n")"
+ printf "1\n2\n3\n4\n5\n6\n7\n8\n" >correct &&
+ git rev-parse >expect \
+ A:a A:a \
+ correct &&
+ git rev-parse >actual \
+ :0:b :0:c &&
+ git hash-object >>actual \
+ a &&
+ test_cmp expect actual
)
'
git ls-files -o >out &&
test_line_count = 1 out &&
- test $(git rev-parse HEAD:a) = $(git rev-parse A:a) &&
- test $(git rev-parse HEAD:c) = $(git rev-parse E:c)
+ git rev-parse >expect \
+ A:a E:c &&
+ git rev-parse >actual \
+ :0:a :0:c &&
+ test_cmp expect actual
)
'