tg.sh: handle help -h
[topgit/pro.git] / t / t5002-update-base-issue-11.sh
blobe8e42af67ae749fa8296a321dabdd303f70ce0e7
1 #!/bin/sh
3 test_description='test update --base zeroing out patches
5 After using tg update --base on a [BASE] branch to cause
6 it to "accumulate" all of the updates and then merging it
7 throughout the rest of the branches, they should all
8 end up reporting a "0" in the `tg summary` output AND
9 none of the should disappear.
12 TEST_NO_CREATE_REPO=1
14 . ./test-lib.sh
16 test_plan 8
18 squish() {
19 tab=" " # single tab in there
20 tr -s "$tab" " "
23 test_expect_success 'setup upstream' '
24 test_create_repo upstream &&
25 cd upstream &&
26 test_commit "README file" README &&
27 test_commit "add tiny.h" tiny.h "/* tiny h file */" &&
28 test_commit "add tiny.c" tiny.c "/* tiny c file */" "U1.0" &&
29 test_when_finished test_tick="$test_tick"
32 test_expect_success LASTOK 'setup tgtest' '
33 test_create_repo tgtest &&
34 cd tgtest &&
35 tg_test_setup_topgit &&
36 git remote add origin ../upstream &&
37 git fetch &&
38 git checkout -b frabjous "U1.0"
41 test_expect_success LASTOK 'create [BASE] and two [PATCH] tg branches' '
42 cd tgtest &&
43 tg_test_create_branch thebase -m "[BASE] the base" :HEAD &&
44 git checkout -f thebase &&
45 tg_test_create_branch t/feat1 thebase &&
46 git checkout -f t/feat1 &&
47 test_tick &&
48 echo "/* changes */" >>tiny.c &&
49 git commit -am "modify" &&
50 tg_test_create_branch t/feat2 thebase &&
51 git checkout -f t/feat2 &&
52 test_tick &&
53 echo "/* changes */" >>tiny.h &&
54 git commit -am "modify" &&
55 test_when_finished test_tick="$test_tick"
58 test_expect_success LASTOK 'create [STAGE] with both patches and tag' '
59 cd tgtest &&
60 tg_test_create_branch stage -m "[STAGE] combined patches" t/feat1 t/feat2 &&
61 git checkout -f stage &&
62 test_tick &&
63 tg update &&
64 test_tick &&
65 git commit --amend --reset-author --no-edit &&
66 test_tick &&
67 git tag -a -m "tag S1.0" S1.0 &&
68 git update-ref --no-deref HEAD HEAD HEAD &&
69 test_when_finished test_tick="$test_tick"
72 printf "%s" "\
73 0 stage [STAGE] combined patches
74 t/feat1 [PATCH] branch t/feat1
75 t/feat2 [PATCH] branch t/feat2
76 0 thebase [BASE] the base
77 " > initial_summary.raw ||
78 die failed to make initial_summary.raw
79 < initial_summary.raw squish > initial_summary ||
80 die failed to make initial_summary
82 test_expect_success LASTOK 'summary has two non-zero patches' '
83 tg -C tgtest summary > actual.raw &&
84 squish < actual.raw > actual &&
85 test_cmp actual initial_summary
88 test_expect_success LASTOK 'update thebase to tag' '
89 cd tgtest &&
90 test_tick &&
91 tg update --base --no-edit thebase S1.0 &&
92 git checkout -f thebase &&
93 test_tick &&
94 git commit --amend --reset-author --no-edit &&
95 test_when_finished test_tick="$test_tick"
98 test_expect_success LASTOK 'update all dependents' '
99 cd tgtest &&
100 git checkout -f t/feat1 &&
101 test_tick &&
102 tg update &&
103 test_tick &&
104 git commit --amend --reset-author --no-edit &&
105 git checkout -f t/feat2 &&
106 test_tick &&
107 tg update &&
108 test_tick &&
109 git commit --amend --reset-author --no-edit &&
110 git checkout -f stage &&
111 test_tick &&
112 tg update &&
113 test_tick &&
114 git commit --amend --reset-author --no-edit &&
115 git update-ref --no-deref HEAD HEAD HEAD &&
116 test_when_finished test_tick="$test_tick"
119 printf "%s" "\
120 0 stage [STAGE] combined patches
121 0 t/feat1 [PATCH] branch t/feat1
122 0 t/feat2 [PATCH] branch t/feat2
123 0 thebase [BASE] the base
124 " > zero_summary.raw ||
125 die failed to make zero_summary.raw
126 < zero_summary.raw squish > zero_summary ||
127 die failed to make zero_summary
129 test_expect_success LASTOK 'summary has four zero patches' '
130 tg -C tgtest summary > actual.raw &&
131 squish < actual.raw > actual &&
132 test_cmp actual zero_summary
135 test_done