3 # Copyright (c) 2005 Petr Baudis
5 test_description
="Tests cg-init
7 Whether it works, properly does initial commit, and all the options except -N
8 work properly (-N is not tested since it's weird and I'm lazy)."
16 test_expect_success
'initialize w/o the initial commit' \
18 test_expect_success
'check if we have the proper repository' \
19 '[ -d .git ] && [ -s .git/index ] && [ -d .git/objects ] &&
20 [ $(git-symbolic-ref HEAD) = refs/heads/master ] &&
21 [ -d .git/refs ] && [ -d .git/refs/heads ] && [ -d .git/refs/tags ]'
22 test_expect_failure
'check if we really have no commit' \
23 '[ -s .git/refs/heads/master ] || cg-object-id -c HEAD'
24 test_expect_failure
'check if we really have empty index' \
25 '[ "$(git-ls-files)" ]'
26 test_expect_success
'try manual initial commit' \
27 '(cg-add file1 file2 && cg-commit -C -m"Initial commit")'
28 test_expect_success
'check if we have a commit' \
29 '[ -s .git/refs/heads/master ] && cg-object-id -c HEAD'
30 test_expect_success
'check if we have populated index' \
31 '[ "$(git-ls-files | tr '\''\n'\'' " ")" = "file1 file2 " ]'
32 test_expect_success
'blow away the repository' \
35 test_expect_success
'initialize with the initial commit' \
36 'echo "silly commit message" | cg-init'
37 test_expect_success
'check if we have a commit' \
38 '[ -s .git/refs/heads/master ] && cg-object-id -c HEAD'
39 test_expect_success
'check if the commit is proper' \
40 '[ "$(git-cat-file commit HEAD | sed -n '\''/^parent/q; /^$/{n; :a p; n; b a}'\'')" = "Initial commit
41 silly commit message" ]'
42 test_expect_success
'check if we have populated index' \
43 '[ "$(git-ls-files | tr '\''\n'\'' " ")" = "file1 file2 " ]'
44 test_expect_success
'blow away the repository' \
47 test_expect_success
'initialize with the initial commit and -m' \
48 'cg-init -m"silly commit message" -m"continued"'
49 test_expect_success
'check if we have a commit' \
50 '[ -s .git/refs/heads/master ] && cg-object-id -c HEAD'
51 test_expect_success
'check if the commit is proper' \
52 '[ "$(git-cat-file commit HEAD | sed -n '\''/^parent/q; /^$/{n; :a p; n; b a}'\'')" = "silly commit message
55 test_expect_success
'blow away the repository' \
60 test_expect_success
'initialize with the initial commit and -e' \
61 'echo "silly commit message" | cg-init -e "file2" -e "file[34]"'
62 test_expect_success
'check if we have a commit' \
63 '[ -s .git/refs/heads/master ] && cg-object-id -c HEAD'
64 test_expect_success
'check if we have properly populated index' \
65 '[ "$(git-ls-files | tr '\''\n'\'' " ")" = "file1 " ]'
66 test_expect_success
'blow away the repository' \
69 echo "file[12]" >.gitignore
70 test_expect_success
'initialize with the initial commit and .gitignore' \
71 'echo "silly commit message" | cg-init'
72 test_expect_success
'check if we have a commit' \
73 '[ -s .git/refs/heads/master ] && cg-object-id -c HEAD'
74 test_expect_success
'check if we have properly populated index' \
75 '[ "$(git-ls-files | tr '\''\n'\'' " ")" = ".gitignore file3 file4 " ]'
76 test_expect_success
'blow away the repository' \