1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Peter Collingbourne
4 #
6 test_description='git apply submodule tests'
8 . ./test-lib.sh
10 test_expect_success setup '
11 cat > create-sm.patch <<EOF &&
12 diff --git a/dir/sm b/dir/sm
13 new file mode 160000
14 index 0000000..0123456
15 --- /dev/null
16 +++ b/dir/sm
17 @@ -0,0 +1 @@
18 +Subproject commit 0123456789abcdef0123456789abcdef01234567
19 EOF
20 cat > remove-sm.patch <<EOF
21 diff --git a/dir/sm b/dir/sm
22 deleted file mode 160000
23 index 0123456..0000000
24 --- a/dir/sm
25 +++ /dev/null
26 @@ -1 +0,0 @@
27 -Subproject commit 0123456789abcdef0123456789abcdef01234567
28 EOF
29 '
31 test_expect_success 'removing a submodule also removes all leading subdirectories' '
32 git apply --index create-sm.patch &&
33 test -d dir/sm &&
34 git apply --index remove-sm.patch &&
35 test \! -d dir
36 '
38 test_done