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