update-index -h: show usage even with corrupt index
[git/srabbelier.git] / t / t6007-rev-list-cherry-pick-file.sh
blobb565638e92655c12c841c29a108516a8b13cf8d2
1 #!/bin/sh
3 test_description='test git rev-list --cherry-pick -- file'
5 . ./test-lib.sh
7 # A---B
8 # \
9 # \
10 # C
12 # B changes a file foo.c, adding a line of text. C changes foo.c as
13 # well as bar.c, but the change in foo.c was identical to change B.
15 test_expect_success setup '
16 echo Hallo > foo &&
17 git add foo &&
18 test_tick &&
19 git commit -m "A" &&
20 git tag A &&
21 git checkout -b branch &&
22 echo Bello > foo &&
23 echo Cello > bar &&
24 git add foo bar &&
25 test_tick &&
26 git commit -m "C" &&
27 git tag C &&
28 git checkout master &&
29 git checkout branch foo &&
30 test_tick &&
31 git commit -m "B" &&
32 git tag B
35 cat >expect <<EOF
36 <tags/B
37 >tags/C
38 EOF
40 test_expect_success '--left-right' '
41 git rev-list --left-right B...C > actual &&
42 git name-rev --stdin --name-only --refs="*tags/*" \
43 < actual > actual.named &&
44 test_cmp actual.named expect
47 test_expect_success '--count' '
48 git rev-list --count B...C > actual &&
49 test "$(cat actual)" = 2
52 test_expect_success '--cherry-pick foo comes up empty' '
53 test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)"
56 test_expect_success '--cherry-pick bar does not come up empty' '
57 ! test -z "$(git rev-list --left-right --cherry-pick B...C -- bar)"
60 test_expect_success '--cherry-pick with independent, but identical branches' '
61 git symbolic-ref HEAD refs/heads/independent &&
62 rm .git/index &&
63 echo Hallo > foo &&
64 git add foo &&
65 test_tick &&
66 git commit -m "independent" &&
67 echo Bello > foo &&
68 test_tick &&
69 git commit -m "independent, too" foo &&
70 test -z "$(git rev-list --left-right --cherry-pick \
71 HEAD...master -- foo)"
74 cat >expect <<EOF
75 1 2
76 EOF
78 # Insert an extra commit to break the symmetry
79 test_expect_success '--count --left-right' '
80 git checkout branch &&
81 test_commit D &&
82 git rev-list --count --left-right B...D > actual &&
83 test_cmp expect actual
86 test_done