3 # Copyright (c) 2005 Johannes Schindelin
6 test_description
='A simple turial in the form of a test case'
10 echo "Hello World" > hello
11 echo "Silly example" > example
13 git update-index
--add hello example
15 test_expect_success
'blob' "test blob = \"$(git cat-file -t 557db03)\""
17 test_expect_success
'blob 557db03' "test \"Hello World\" = \"$(git cat-file blob 557db03)\""
19 echo "It's a new day for git" >>hello
20 cat > diff.expect
<< EOF
21 diff --git a/hello b/hello
22 index 557db03..263414f 100644
27 +It's a new day for git
29 git diff-files
-p > diff.output
30 test_expect_success
'git diff-files -p' 'cmp diff.expect diff.output'
31 git
diff > diff.output
32 test_expect_success
'git diff' 'cmp diff.expect diff.output'
34 tree
=$
(git write-tree
2>/dev
/null
)
36 test_expect_success
'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tree"
38 output
="$(echo "Initial commit
" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)"
40 git diff-index
-p HEAD
> diff.output
41 test_expect_success
'git diff-index -p HEAD' 'cmp diff.expect diff.output'
43 git
diff HEAD
> diff.output
44 test_expect_success
'git diff HEAD' 'cmp diff.expect diff.output'
47 #test_expect_success 'git read-tree --reset HEAD' "git read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git update-index --refresh)\""
49 cat > whatchanged.expect
<< EOF
56 diff --git a/example b/example
58 index 0000000..f24c74a
63 diff --git a/hello b/hello
65 index 0000000..557db03
72 git whatchanged
-p --root | \
73 sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \
74 -e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \
76 test_expect_success
'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'
79 test_expect_success
'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'
81 # TODO: test git-clone
83 git checkout
-b mybranch
84 test_expect_success
'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch'
86 cat > branch.expect
<<EOF
91 git branch
> branch.output
92 test_expect_success
'git branch' 'cmp branch.expect branch.output'
95 echo "Work, work, work" >>hello
96 git commit
-m 'Some work.' -i hello
100 echo "Play, play, play" >>hello
101 echo "Lots of fun" >>example
102 git commit
-m 'Some fun.' -i hello example
104 test_expect_failure
'git resolve now fails' '
105 git merge -m "Merge work in mybranch" mybranch
110 It's a new day for git
115 git commit
-m 'Merged "mybranch" changes.' -i hello
119 cat > show-branch.expect
<< EOF
120 * [master] Merged "mybranch" changes.
121 ! [mybranch] Some work.
123 - [master] Merged "mybranch" changes.
124 *+ [mybranch] Some work.
127 git show-branch
--topo-order master mybranch
> show-branch.output
128 test_expect_success
'git show-branch' 'cmp show-branch.expect show-branch.output'
130 git checkout mybranch
132 cat > resolve.expect
<< EOF
133 Updating from VARIABLE to VARIABLE
136 2 files changed, 2 insertions(+), 0 deletions(-)
139 git merge
-s "Merge upstream changes." master | \
140 sed -e "1s/[0-9a-f]\{40\}/VARIABLE/g" >resolve.output
141 test_expect_success
'git resolve' 'cmp resolve.expect resolve.output'
143 cat > show-branch2.expect
<< EOF
144 ! [master] Merged "mybranch" changes.
145 * [mybranch] Merged "mybranch" changes.
147 -- [master] Merged "mybranch" changes.
150 git show-branch
--topo-order master mybranch
> show-branch2.output
151 test_expect_success
'git show-branch' 'cmp show-branch2.expect show-branch2.output'
153 # TODO: test git fetch
155 # TODO: test git push
157 test_expect_success
'git repack' 'git repack'
158 test_expect_success
'git prune-packed' 'git prune-packed'
159 test_expect_failure
'-> only packed objects' '/usr/bin/find -type f .git/objects/[0-9a-f][0-9a-f]'