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
20 glst
() { git ls-tree
--full-tree --name-only "$1" -- :/.topdeps
:/.topmsg
; }
22 test_expect_success
'setup t/frabjous' '
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 &&
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' '
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' '
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"' '
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' '
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' '
73 glst "$(tg base t/frabjous)" >../actual &&
74 test_cmp ../actual ../expected
77 test_expect_success LASTOK
'add new commit to branch' '
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"' '
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' '
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' '
101 tg files t/frabjous >../actual &&
102 test_cmp ../actual ../expected
105 test_expect_success LASTOK
'branch with .topdeps and .topmsg files redux' '
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' '
115 glst "$(tg base t/frabjous)" >../actual &&
116 test_cmp ../actual ../expected