t1200: cleanup and modernize test style
[alt-git.git] / t / t1200-tutorial.sh
blobc57c9d5300d7f6cbd8c0ea1174cc9e27191f3740
1 #!/bin/sh
3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='A simple turial in the form of a test case'
8 . ./test-lib.sh
10 test_expect_success 'blob' '
11 echo "Hello World" > hello &&
12 echo "Silly example" > example &&
14 git update-index --add hello example &&
16 test blob = "$(git cat-file -t 557db03)"
19 test_expect_success 'blob 557db03' '
20 test "Hello World" = "$(git cat-file blob 557db03)"
23 echo "It's a new day for git" >>hello
24 cat > diff.expect << EOF
25 diff --git a/hello b/hello
26 index 557db03..263414f 100644
27 --- a/hello
28 +++ b/hello
29 @@ -1 +1,2 @@
30 Hello World
31 +It's a new day for git
32 EOF
34 test_expect_success 'git diff-files -p' '
35 git diff-files -p > diff.output &&
36 cmp diff.expect diff.output
39 test_expect_success 'git diff' '
40 git diff > diff.output &&
41 cmp diff.expect diff.output
44 test_expect_success 'tree' '
45 tree=$(git write-tree 2>/dev/null)
46 test 8988da15d077d4829fc51d8544c097def6644dbb = $tree
49 test_expect_success 'git diff-index -p HEAD' '
50 echo "Initial commit" | \
51 git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master &&
52 git diff-index -p HEAD > diff.output &&
53 cmp diff.expect diff.output
56 test_expect_success 'git diff HEAD' '
57 git diff HEAD > diff.output &&
58 cmp diff.expect diff.output
61 cat > whatchanged.expect << EOF
62 commit VARIABLE
63 Author: VARIABLE
64 Date: VARIABLE
66 Initial commit
68 diff --git a/example b/example
69 new file mode 100644
70 index 0000000..f24c74a
71 --- /dev/null
72 +++ b/example
73 @@ -0,0 +1 @@
74 +Silly example
75 diff --git a/hello b/hello
76 new file mode 100644
77 index 0000000..557db03
78 --- /dev/null
79 +++ b/hello
80 @@ -0,0 +1 @@
81 +Hello World
82 EOF
84 test_expect_success 'git whatchanged -p --root' '
85 git whatchanged -p --root | \
86 sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \
87 -e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \
88 > whatchanged.output &&
89 cmp whatchanged.expect whatchanged.output
92 test_expect_success 'git tag my-first-tag' '
93 git tag my-first-tag &&
94 cmp .git/refs/heads/master .git/refs/tags/my-first-tag
97 test_expect_success 'git checkout -b mybranch' '
98 git checkout -b mybranch &&
99 cmp .git/refs/heads/master .git/refs/heads/mybranch
102 cat > branch.expect <<EOF
103 master
104 * mybranch
107 test_expect_success 'git branch' '
108 git branch > branch.output &&
109 cmp branch.expect branch.output
112 test_expect_success 'git resolve now fails' '
113 git checkout mybranch &&
114 echo "Work, work, work" >>hello &&
115 git commit -m "Some work." -i hello &&
117 git checkout master &&
119 echo "Play, play, play" >>hello &&
120 echo "Lots of fun" >>example &&
121 git commit -m "Some fun." -i hello example &&
123 test_must_fail git merge -m "Merge work in mybranch" mybranch
126 cat > hello << EOF
127 Hello World
128 It's a new day for git
129 Play, play, play
130 Work, work, work
133 cat > show-branch.expect << EOF
134 * [master] Merged "mybranch" changes.
135 ! [mybranch] Some work.
137 - [master] Merged "mybranch" changes.
138 *+ [mybranch] Some work.
141 test_expect_success 'git show-branch' '
142 git commit -m "Merged \"mybranch\" changes." -i hello &&
143 git show-branch --topo-order master mybranch > show-branch.output &&
144 cmp show-branch.expect show-branch.output
147 cat > resolve.expect << EOF
148 Updating VARIABLE..VARIABLE
149 Fast forward (no commit created; -m option ignored)
150 example | 1 +
151 hello | 1 +
152 2 files changed, 2 insertions(+), 0 deletions(-)
155 test_expect_success 'git resolve' '
156 git checkout mybranch &&
157 git merge -m "Merge upstream changes." master | \
158 sed -e "1s/[0-9a-f]\{7\}/VARIABLE/g" >resolve.output &&
159 cmp resolve.expect resolve.output
162 cat > show-branch2.expect << EOF
163 ! [master] Merged "mybranch" changes.
164 * [mybranch] Merged "mybranch" changes.
166 -- [master] Merged "mybranch" changes.
169 test_expect_success 'git show-branch (part 2)' '
170 git show-branch --topo-order master mybranch > show-branch2.output &&
171 cmp show-branch2.expect show-branch2.output
174 test_expect_success 'git repack' 'git repack'
175 test_expect_success 'git prune-packed' 'git prune-packed'
176 test_expect_success '-> only packed objects' '
177 git prune && # Remove conflict marked blobs
178 ! find .git/objects/[0-9a-f][0-9a-f] -type f
181 test_done