3 # Copyright (c) 2005 Pvel Roskin
5 test_description
="Tests basic cg-clean functionality
7 Create files and directories and check that cg-clean removes them
8 (and keeps files and directories it should keep)."
12 # Use spaces in names to make sure they are handled properly.
13 echo "repo file 1" >"repo file 1"
15 echo "repo file 2" >"repo dir/repo file 2"
16 echo "*.ign" >".gitignore"
17 echo "*.ign1" >"repo dir/.gitignore"
19 test_expect_success
'initialize repo' \
20 "(cg-add -r * .gitignore && \
21 cg-commit -C -m\"Initial commit\")"
23 echo "extra file 1" >"extra file 1"
25 echo "extra file 2" >"repo dir/extra file 2"
26 mkdir
"repo dir/extra dir 2"
27 echo "extra file 3" >"extra dir 1/extra file 3"
28 echo "ign file 1" >"ign file 1.ign"
29 echo "ign file 2" >"ign file 2.ign1"
30 echo "ign file 3" >"repo dir/ign file 3.ign"
31 echo "ign file 4" >"repo dir/ign file 4.ign1"
33 # Create file lists under .git/temp, exclude .git/ from listings.
34 # Compare lists before and after cg-clean and check if only the expected
38 list
="$topdir/.git/temp/list"
43 find .
2>/dev
/null |
sed -n "/^.\/.git\//d;s/^..//p" |
50 echo "$loss" |
cat - "$list-new" |
51 grep -v ^$ |
sort >"$list-combined"
52 diff -u "$list-init" "$list-combined" > "$list.diff" &&
53 cp -f "$list-new" "$list-init"
58 test_expect_success
'cg-clean -n in top-level dir' \
59 "(cg-clean -n && check_loss)"
61 test_expect_success
'cg-clean -Ddxqn in top-level dir' \
62 "(cg-clean -Ddxqn && check_loss)"
64 test_expect_success
'cg-clean -n in subdir' \
65 "(cd 'repo dir' && cg-clean -n && check_loss)"
67 loss
='repo dir/extra file 2'
68 test_expect_success
'cg-clean in subdir' \
69 "(cd 'repo dir' && cg-clean && check_loss)"
71 loss
='repo dir/extra dir 2'
72 test_expect_success
'cg-clean -d in subdir' \
73 "(cd 'repo dir' && cg-clean -d && check_loss)"
75 loss
='repo dir/ign file 3.ign
76 repo dir/ign file 4.ign1'
77 test_expect_success
'cg-clean -x in subdir' \
78 "(cd 'repo dir' && cg-clean -x && check_loss)"
80 # Restore extra files in "repo dir"
81 echo "extra file 2" >"repo dir/extra file 2"
82 mkdir
"repo dir/extra dir 2"
83 echo "ign file 3" >"repo dir/ign file 3.ign"
84 echo "ign file 4" >"repo dir/ign file 4.ign1"
89 repo dir/extra file 2'
90 test_expect_success
'cg-clean in top-level dir' \
91 "(cg-clean && check_loss)"
94 repo dir/ign file 3.ign
95 repo dir/ign file 4.ign1'
96 test_expect_success
'cg-clean -x in top-level dir' \
97 "(cg-clean -x && check_loss)"
100 extra dir 1/extra file 3
101 repo dir/extra dir 2'
102 test_expect_success
'cg-clean -d in top-level dir' \
103 "(cg-clean -d && check_loss)"
106 chmod 000 "extra dir 3"
109 test_expect_success
'cg-clean -D in top-level dir' \
110 "(cg-clean -D && check_loss)"