1#!/bin/sh
2#
3# Copyright (c) 2010 Peter Collingbourne
4#
5
6test_description='git apply submodule tests'
7
8. ./test-lib.sh
9
10test_expect_success setup '
11 cat > create-sm.patch <<EOF &&
12diff --git a/dir/sm b/dir/sm
13new file mode 160000
14index 0000000..0123456
15--- /dev/null
16+++ b/dir/sm
17@@ -0,0 +1 @@
18+Subproject commit 0123456789abcdef0123456789abcdef01234567
19EOF
20 cat > remove-sm.patch <<EOF
21diff --git a/dir/sm b/dir/sm
22deleted file mode 160000
23index 0123456..0000000
24--- a/dir/sm
25+++ /dev/null
26@@ -1 +0,0 @@
27-Subproject commit 0123456789abcdef0123456789abcdef01234567
28EOF
29'
30
31test_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'
37
38test_done