topgit: version 0.19.13
[topgit/pro.git] / t / t5001-update-base-fast-forward.sh
blob30066a2ee5667a1f2ee480455db44ea0659044c8
1 #!/bin/sh
3 test_description='tg update --base fast-forward tests
5 Some have expressed a temptation to use `tg update --base branch branch`
6 in order to "empty" out the patch content of a TopGit topic branch.
8 This has, however, consequences with regard to the .topdeps and .topmsg
9 files.
11 Hence these tests.
14 TEST_NO_CREATE_REPO=1
16 . ./test-lib.sh
18 test_plan 12
20 glst() { git ls-tree --full-tree --name-only "$1" -- :/.topdeps :/.topmsg; }
22 test_expect_success 'setup t/frabjous' '
23 test_create_repo r &&
24 cd r &&
25 tg_test_setup_topgit &&
26 tg_test_create_branch t/frabjous : &&
27 git checkout -f t/frabjous &&
28 test_commit "test file" file test &&
29 echo file >../expected &&
30 tg files >../actual &&
31 test_cmp ../actual ../expected &&
32 tgb="$(tg base)" &&
33 >../expected &&
34 glst "$tgb" >../actual &&
35 test_cmp ../actual ../expected &&
36 printf "%s\n" .topdeps .topmsg >../expected &&
37 glst HEAD >../actual &&
38 test_cmp ../actual ../expected &&
39 test_when_finished test_tick="$test_tick"
42 test_expect_success LASTOK 'commit on top of base' '
43 cd r &&
44 git checkout -f "$(tg base t/frabjous)" &&
45 test_commit "base file" base base addtobase &&
46 test_when_finished test_tick="$test_tick"
49 test_expect_success LASTOK 'update base with new commit' '
50 cd r &&
51 test_tick &&
52 tg update --no-stash --base --no-edit t/frabjous addtobase &&
53 test_when_finished test_tick="$test_tick"
56 test_expect_success LASTOK 'branch files just "file"' '
57 cd r &&
58 echo file >../expected &&
59 tg files t/frabjous >../actual &&
60 test_cmp ../actual ../expected
63 test_expect_success LASTOK 'branch with .topdeps and .topmsg files' '
64 cd r &&
65 printf "%s\n" .topdeps .topmsg >../expected &&
66 glst t/frabjous >../actual &&
67 test_cmp ../actual ../expected
70 test_expect_success LASTOK 'base without .topdeps and .topmsg files' '
71 cd r &&
72 >../expected &&
73 glst "$(tg base t/frabjous)" >../actual &&
74 test_cmp ../actual ../expected
77 test_expect_success LASTOK 'add new commit to branch' '
78 cd r &&
79 git checkout -f t/frabjous &&
80 test_commit "extra file" extra &&
81 test_when_finished test_tick="$test_tick"
84 test_expect_success LASTOK 'branch files just "extra" and "file"' '
85 cd r &&
86 printf "%s\n" extra file >../expected &&
87 tg files t/frabjous >../actual &&
88 test_cmp ../actual ../expected
91 test_expect_success LASTOK 'fast forward base to branch' '
92 cd r &&
93 test_tick &&
94 tg update --no-stash --base --no-edit t/frabjous t/frabjous^0 &&
95 test_when_finished test_tick="$test_tick"
98 test_expect_success LASTOK 'branch files empty' '
99 cd r &&
100 >../expected &&
101 tg files t/frabjous >../actual &&
102 test_cmp ../actual ../expected
105 test_expect_success LASTOK 'branch with .topdeps and .topmsg files redux' '
106 cd r &&
107 printf "%s\n" .topdeps .topmsg >../expected &&
108 glst t/frabjous >../actual &&
109 test_cmp ../actual ../expected
112 test_expect_success LASTOK 'base without .topdeps and .topmsg files redux' '
113 cd r &&
114 >../expected &&
115 glst "$(tg base t/frabjous)" >../actual &&
116 test_cmp ../actual ../expected
119 test_done