]>
Commit | Line | Data |
---|---|---|
36d56de6 JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='test git rev-list --cherry-pick -- file' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | # A---B | |
8 | # \ | |
9 | # \ | |
10 | # C | |
11 | # | |
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. | |
14 | ||
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 | |
33 | ' | |
34 | ||
f69c5018 TR |
35 | cat >expect <<EOF |
36 | <tags/B | |
37 | >tags/C | |
38 | EOF | |
39 | ||
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 | |
45 | ' | |
46 | ||
47 | test_expect_success '--count' ' | |
48 | git rev-list --count B...C > actual && | |
49 | test "$(cat actual)" = 2 | |
50 | ' | |
51 | ||
36d56de6 JS |
52 | test_expect_success '--cherry-pick foo comes up empty' ' |
53 | test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)" | |
54 | ' | |
55 | ||
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)" | |
58 | ' | |
59 | ||
023756f4 JS |
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)" | |
72 | ' | |
73 | ||
f69c5018 TR |
74 | cat >expect <<EOF |
75 | 1 2 | |
76 | EOF | |
77 | ||
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 | |
84 | ' | |
85 | ||
36d56de6 | 86 | test_done |