1f50069e583292cae3e4f877f344deda569f3656
[stgit] / t / t2100-pull-policy-fetch.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Yann Dirson
4 #
5
6 test_description='Excercise pull-policy "fetch-rebase".'
7
8 . ./test-lib.sh
9
10 # don't need this repo, but better not drop it, see t1100
11 #rm -rf .git
12
13 # Need a repo to clone
14 test_create_repo upstream
15
16 test_expect_success \
17 'Setup upstream repo, clone it, and add patches to the clone' \
18 '
19 (cd upstream && stg init) &&
20 stg clone upstream clone &&
21 (cd clone &&
22 git repo-config branch.master.stgit.pull-policy fetch-rebase &&
23 git repo-config --list &&
24 stg new c1 -m c1 &&
25 echo a > file && stg add file && stg refresh
26 )
27 '
28
29 test_expect_success \
30 'Add non-rewinding commit upstream and pull it from clone' \
31 '
32 (cd upstream && stg new u1 -m u1 &&
33 echo a > file2 && stg add file2 && stg refresh) &&
34 (cd clone && stg pull) &&
35 test -e clone/file2
36 '
37
38 # note: with pre-1.5 Git the clone is not automatically recorded
39 # as rewinding, and thus heads/origin is not moved, but the stack
40 # is still correctly rebased
41 test_expect_success \
42 'Rewind/rewrite upstream commit and pull it from clone' \
43 '
44 (cd upstream && echo b >> file2 && stg refresh) &&
45 (cd clone && stg pull) &&
46 test `wc -l <clone/file2` = 2
47 '
48
49 # this one ensures the guard against commits does not unduly trigger
50 test_expect_success \
51 'Rewind/rewrite upstream commit and fetch it from clone before pulling' \
52 '
53 (cd upstream && echo c >> file2 && stg refresh) &&
54 (cd clone && git fetch && stg pull) &&
55 test `wc -l <clone/file2` = 3
56 '
57
58 # this one exercises the guard against commits
59 # (use a new file to avoid mistaking a conflict for a success)
60 test_expect_success \
61 'New upstream commit and commit a patch in clone' \
62 '
63 (cd upstream && stg new u2 -m u2 &&
64 echo a > file3 && stg add file3 && stg refresh) &&
65 (cd clone && stg commit && stg new c2 -m c2 &&
66 echo a >> file && stg refresh)
67 '
68 test_expect_success \
69 'Try to and commit a patch in clone' \
70 '(cd clone && ! stg pull)'
71
72 test_done