Test commit
[cogito/jonas.git] / t / t9000-init.sh
blobb3b9df331a649f2fd5778bb3642412d5133fb75e
1 #!/usr/bin/env bash
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)."
10 . ./test-lib.sh
12 rm -rf .git
14 echo file1 >file1
15 echo file2 >file2
16 test_expect_success 'initialize w/o the initial commit' \
17 'cg-init -I'
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' \
33 'rm -rf .git'
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' \
45 'rm -rf .git'
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
54 continued" ]'
55 test_expect_success 'blow away the repository' \
56 'rm -rf .git'
58 echo file3 >file3
59 echo file4 >file4
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' \
67 'rm -rf .git'
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' \
77 'rm -rf .git'
79 test_done