Raw
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Shawn Pearce
4 #
5
6 test_description='git reset should cull empty subdirs'
7
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-diff-data.sh
10
11 test_expect_success 'creating initial files' '
12 mkdir path0 &&
13 COPYING_test_data >path0/COPYING &&
14 git add path0/COPYING &&
15 git commit -m add -a
16 '
17
18 test_expect_success 'creating second files' '
19 mkdir path1 &&
20 mkdir path1/path2 &&
21 COPYING_test_data >path1/path2/COPYING &&
22 COPYING_test_data >path1/COPYING &&
23 COPYING_test_data >COPYING &&
24 COPYING_test_data >path0/COPYING-TOO &&
25 git add path1/path2/COPYING &&
26 git add path1/COPYING &&
27 git add COPYING &&
28 git add path0/COPYING-TOO &&
29 git commit -m change -a
30 '
31
32 test_expect_success 'resetting tree HEAD^' '
33 git reset --hard HEAD^
34 '
35
36 test_expect_success 'checking initial files exist after rewind' '
37 test_path_is_dir path0 &&
38 test_path_is_file path0/COPYING
39 '
40
41 test_expect_success 'checking lack of path1/path2/COPYING' '
42 test_path_is_missing path1/path2/COPYING
43 '
44
45 test_expect_success 'checking lack of path1/COPYING' '
46 test_path_is_missing path1/COPYING
47 '
48
49 test_expect_success 'checking lack of COPYING' '
50 test_path_is_missing COPYING
51 '
52
53 test_expect_success 'checking lack of path0/COPYING-TOO' '
54 test_path_is_missing path0/COPYING-TOO
55 '
56
57 test_expect_success 'checking lack of path1/path2' '
58 test_path_is_missing path1/path2
59 '
60
61 test_expect_success 'checking lack of path1' '
62 test_path_is_missing path1
63 '
64
65 test_done