glossary: Add definitions for dangling and unreachable objects
[git/mingw/4msysgit/kblees.git] / t / t7201-co.sh
blob867bbd26cbbacbe03ef76cadb6ff34976c324da5
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='git-checkout tests.'
8 . ./test-lib.sh
10 fill () {
11 for i
13 echo "$i"
14 done
18 test_expect_success setup '
20 fill 1 2 3 4 5 6 7 8 >one &&
21 fill a b c d e >two &&
22 git add one two &&
23 git commit -m "Initial A one, A two" &&
25 git checkout -b renamer &&
26 rm -f one &&
27 fill 1 3 4 5 6 7 8 >uno &&
28 git add uno &&
29 fill a b c d e f >two &&
30 git commit -a -m "Renamer R one->uno, M two" &&
32 git checkout -b side master &&
33 fill 1 2 3 4 5 6 7 >one &&
34 fill A B C D E >three &&
35 rm -f two &&
36 git update-index --add --remove one two three &&
37 git commit -m "Side M one, D two, A three" &&
39 git checkout master
42 test_expect_success "checkout from non-existing branch" '
44 git checkout -b delete-me master &&
45 rm .git/refs/heads/delete-me &&
46 test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
47 git checkout master &&
48 test refs/heads/master = "$(git symbolic-ref HEAD)"
51 test_expect_success "checkout with dirty tree without -m" '
53 fill 0 1 2 3 4 5 6 7 8 >one &&
54 if git checkout side
55 then
56 echo Not happy
57 false
58 else
59 echo "happy - failed correctly"
64 test_expect_success "checkout -m with dirty tree" '
66 git checkout -f master &&
67 git clean &&
69 fill 0 1 2 3 4 5 6 7 8 >one &&
70 git checkout -m side &&
72 test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
74 fill "M one" "A three" "D two" >expect.master &&
75 git diff --name-status master >current.master &&
76 diff expect.master current.master &&
78 fill "M one" >expect.side &&
79 git diff --name-status side >current.side &&
80 diff expect.side current.side &&
82 : >expect.index &&
83 git diff --cached >current.index &&
84 diff expect.index current.index
87 test_expect_success "checkout -m with dirty tree, renamed" '
89 git checkout -f master && git clean &&
91 fill 1 2 3 4 5 7 8 >one &&
92 if git checkout renamer
93 then
94 echo Not happy
95 false
96 else
97 echo "happy - failed correctly"
98 fi &&
100 git checkout -m renamer &&
101 fill 1 3 4 5 7 8 >expect &&
102 diff expect uno &&
103 ! test -f one &&
104 git diff --cached >current &&
105 ! test -s current
109 test_expect_success 'checkout -m with merge conflict' '
111 git checkout -f master && git clean &&
113 fill 1 T 3 4 5 6 S 8 >one &&
114 if git checkout renamer
115 then
116 echo Not happy
117 false
118 else
119 echo "happy - failed correctly"
120 fi &&
122 git checkout -m renamer &&
124 git diff master:one :3:uno |
125 sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
126 fill d2 aT d7 aS >expect &&
127 diff current expect &&
128 git diff --cached two >current &&
129 ! test -s current
132 test_done