]>
Commit | Line | Data |
---|---|---|
2ae6c706 JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Johannes Schindelin | |
4 | # | |
5 | ||
b599deec | 6 | test_description='A simple turial in the form of a test case' |
2ae6c706 JS |
7 | |
8 | . ./test-lib.sh | |
9 | ||
10 | echo "Hello World" > hello | |
11 | echo "Silly example" > example | |
12 | ||
5be60078 | 13 | git update-index --add hello example |
2ae6c706 | 14 | |
5be60078 | 15 | test_expect_success 'blob' "test blob = \"$(git cat-file -t 557db03)\"" |
2ae6c706 | 16 | |
5be60078 | 17 | test_expect_success 'blob 557db03' "test \"Hello World\" = \"$(git cat-file blob 557db03)\"" |
2ae6c706 JS |
18 | |
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 | |
23 | --- a/hello | |
24 | +++ b/hello | |
25 | @@ -1 +1,2 @@ | |
26 | Hello World | |
27 | +It's a new day for git | |
28 | EOF | |
5be60078 JH |
29 | git diff-files -p > diff.output |
30 | test_expect_success 'git diff-files -p' 'cmp diff.expect diff.output' | |
2ae6c706 JS |
31 | git diff > diff.output |
32 | test_expect_success 'git diff' 'cmp diff.expect diff.output' | |
33 | ||
5be60078 | 34 | tree=$(git write-tree 2>/dev/null) |
2ae6c706 JS |
35 | |
36 | test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tree" | |
37 | ||
5be60078 | 38 | output="$(echo "Initial commit" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)" |
2ae6c706 | 39 | |
5be60078 JH |
40 | git diff-index -p HEAD > diff.output |
41 | test_expect_success 'git diff-index -p HEAD' 'cmp diff.expect diff.output' | |
2ae6c706 JS |
42 | |
43 | git diff HEAD > diff.output | |
44 | test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output' | |
45 | ||
46 | #rm hello | |
5be60078 | 47 | #test_expect_success 'git read-tree --reset HEAD' "git read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git update-index --refresh)\"" |
2ae6c706 JS |
48 | |
49 | cat > whatchanged.expect << EOF | |
91539833 | 50 | commit VARIABLE |
2ae6c706 JS |
51 | Author: VARIABLE |
52 | Date: VARIABLE | |
53 | ||
54 | Initial commit | |
55 | ||
56 | diff --git a/example b/example | |
57 | new file mode 100644 | |
58 | index 0000000..f24c74a | |
59 | --- /dev/null | |
60 | +++ b/example | |
61 | @@ -0,0 +1 @@ | |
62 | +Silly example | |
63 | diff --git a/hello b/hello | |
64 | new file mode 100644 | |
65 | index 0000000..557db03 | |
66 | --- /dev/null | |
67 | +++ b/hello | |
68 | @@ -0,0 +1 @@ | |
69 | +Hello World | |
70 | EOF | |
71 | ||
5be60078 | 72 | git whatchanged -p --root | \ |
91539833 | 73 | sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \ |
2ae6c706 JS |
74 | -e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \ |
75 | > whatchanged.output | |
5be60078 | 76 | test_expect_success 'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output' |
2ae6c706 JS |
77 | |
78 | git tag my-first-tag | |
79 | test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag' | |
80 | ||
81 | # TODO: test git-clone | |
82 | ||
83 | git checkout -b mybranch | |
84 | test_expect_success 'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch' | |
85 | ||
86 | cat > branch.expect <<EOF | |
87 | master | |
88 | * mybranch | |
89 | EOF | |
90 | ||
91 | git branch > branch.output | |
92 | test_expect_success 'git branch' 'cmp branch.expect branch.output' | |
93 | ||
94 | git checkout mybranch | |
95 | echo "Work, work, work" >>hello | |
130fcca6 | 96 | git commit -m 'Some work.' -i hello |
2ae6c706 JS |
97 | |
98 | git checkout master | |
99 | ||
100 | echo "Play, play, play" >>hello | |
101 | echo "Lots of fun" >>example | |
130fcca6 | 102 | git commit -m 'Some fun.' -i hello example |
2ae6c706 | 103 | |
41ac414e JH |
104 | test_expect_success 'git resolve now fails' ' |
105 | ! git merge -m "Merge work in mybranch" mybranch | |
207dfa07 | 106 | ' |
2ae6c706 JS |
107 | |
108 | cat > hello << EOF | |
109 | Hello World | |
110 | It's a new day for git | |
111 | Play, play, play | |
112 | Work, work, work | |
113 | EOF | |
114 | ||
130fcca6 | 115 | git commit -m 'Merged "mybranch" changes.' -i hello |
2ae6c706 | 116 | |
6a74642c JH |
117 | test_done |
118 | ||
2ae6c706 JS |
119 | cat > show-branch.expect << EOF |
120 | * [master] Merged "mybranch" changes. | |
121 | ! [mybranch] Some work. | |
122 | -- | |
ebedc319 JH |
123 | - [master] Merged "mybranch" changes. |
124 | *+ [mybranch] Some work. | |
2ae6c706 JS |
125 | EOF |
126 | ||
4bc51db0 | 127 | git show-branch --topo-order master mybranch > show-branch.output |
2ae6c706 JS |
128 | test_expect_success 'git show-branch' 'cmp show-branch.expect show-branch.output' |
129 | ||
130 | git checkout mybranch | |
131 | ||
132 | cat > resolve.expect << EOF | |
eb0e0024 | 133 | Updating from VARIABLE to VARIABLE |
2ae6c706 JS |
134 | example | 1 + |
135 | hello | 1 + | |
136 | 2 files changed, 2 insertions(+), 0 deletions(-) | |
137 | EOF | |
138 | ||
207dfa07 JH |
139 | git merge -s "Merge upstream changes." master | \ |
140 | sed -e "1s/[0-9a-f]\{40\}/VARIABLE/g" >resolve.output | |
2ae6c706 JS |
141 | test_expect_success 'git resolve' 'cmp resolve.expect resolve.output' |
142 | ||
143 | cat > show-branch2.expect << EOF | |
144 | ! [master] Merged "mybranch" changes. | |
145 | * [mybranch] Merged "mybranch" changes. | |
146 | -- | |
ebedc319 | 147 | -- [master] Merged "mybranch" changes. |
2ae6c706 JS |
148 | EOF |
149 | ||
4bc51db0 | 150 | git show-branch --topo-order master mybranch > show-branch2.output |
2ae6c706 JS |
151 | test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.output' |
152 | ||
153 | # TODO: test git fetch | |
154 | ||
155 | # TODO: test git push | |
156 | ||
157 | test_expect_success 'git repack' 'git repack' | |
158 | test_expect_success 'git prune-packed' 'git prune-packed' | |
41ac414e JH |
159 | test_expect_success '-> only packed objects' ' |
160 | ! find -type f .git/objects/[0-9a-f][0-9a-f] | |
161 | ' | |
2ae6c706 JS |
162 | |
163 | test_done |