tg-export: wayback to older patch sets
[topgit/pro.git] / t / t8300-wayback-export.sh
blob0928f8ec1a3d8381616fe2083a427c915721d64c
1 #!/bin/sh
3 test_description='wayback export'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
9 test_plan 12
11 topbases="$(tg --top-bases)" && [ -n "$topbases" ] || die 'no --top-bases!'
13 test_expect_success 'setup' '
14 test_create_repo patches &&
15 cd patches &&
16 tg_test_create_branch patch -m "the patch" : &&
17 git checkout -f patch &&
18 git tag patchbase &&
19 test_commit "the patch v1" "patchfile" "first version of patch" patchv1 &&
20 tg_test_create_tag t/first refs/heads/patch "$topbases/patch" &&
21 git diff-tree -p HEAD^! >../patch1.patch &&
22 git patch-id <../patch1.patch >../patch1.id &&
23 tg patch patch >../patch1.tgpatch &&
24 git patch-id <../patch1.tgpatch >../patch1.tgid &&
25 test_diff ../patch1.id ../patch1.tgid &&
26 printf "%s\n" "alternate patch" "I like this better" >patchfile &&
27 git add patchfile &&
28 test_tick &&
29 git commit -m "new alternate patch" &&
30 git diff patchbase HEAD >../patch2.patch &&
31 git patch-id <../patch2.patch >../patch2.id &&
32 tg patch patch >../patch2.tgpatch &&
33 git patch-id <../patch2.tgpatch >../patch2.tgid &&
34 test_diff ../patch2.id ../patch2.tgid &&
35 git tag patchv2 &&
36 cd .. &&
37 git clone --mirror --no-shared patches patches.git
40 # this test is supposed to be about export, but export will end up calling
41 # patch for --linearize and --quilt modes so we test it first some more
43 test_expect_success 'patch first' '
44 tg -C patches -w t/first patch patch >p1 &&
45 git patch-id <p1 >p1.id &&
46 test_diff patch1.id p1.id
49 test_expect_success 'patch second' '
50 tg -C patches -w : patch patch >p2 &&
51 git patch-id <p2 >p2.id &&
52 test_diff patch2.id p2.id
55 # on to the export tests
57 test_expect_success 'tg export --linearize bare no go' '
58 test_must_fail tg -C patches.git export --linearize out
61 test_expect_success 'tg export --collapse bare ok' '
62 tg -C patches.git export --collapse out &&
63 git -C patches.git diff-tree -p out^! >co.patch &&
64 git patch-id <co.patch >co.id &&
65 test_diff co.id patch2.id &&
66 git -C patches.git update-ref -d refs/heads/out out
69 test_expect_success 'tg export --quilt bare ok' '
70 mkdir qu &&
71 tg -C patches.git export --quilt "$PWD/qu" &&
72 git patch-id <qu/patch.diff >qu.id &&
73 test_diff qu.id patch2.id
76 # now the "wayback" tests
78 test_expect_success 'tg export --collapse wayback first' '
79 tg -C patches.git -w t/first export --collapse out &&
80 git -C patches.git diff-tree -p out^! >wc1.patch &&
81 git patch-id <wc1.patch >wc1.id &&
82 test_diff wc1.id patch1.id &&
83 git -C patches.git update-ref -d refs/heads/out out
86 test_expect_success 'tg export --collapse wayback second' '
87 tg -C patches.git -w : export --collapse out &&
88 git -C patches.git diff-tree -p out^! >wc2.patch &&
89 git patch-id <wc2.patch >wc2.id &&
90 test_diff wc2.id patch2.id &&
91 git -C patches.git update-ref -d refs/heads/out out
94 test_expect_success 'tg export --linearize wayback first' '
95 tg -C patches.git -w t/first export --linearize out &&
96 git -C patches.git diff-tree -p out^! >wl1.patch &&
97 git patch-id <wl1.patch >wl1.id &&
98 test_diff wl1.id patch1.id &&
99 git -C patches.git update-ref -d refs/heads/out out
102 test_expect_success 'tg export --linearize wayback second' '
103 tg -C patches.git -w : export --linearize out &&
104 git -C patches.git diff-tree -p out^! >wl2.patch &&
105 git patch-id <wl2.patch >wl2.id &&
106 test_diff wl2.id patch2.id &&
107 git -C patches.git update-ref -d refs/heads/out out
110 test_expect_success 'tg export --quilt wayback first' '
111 tg -C patches.git -w t/first export --quilt "$PWD/qu1" &&
112 git patch-id <qu1/patch.diff >qu1.id &&
113 test_diff qu1.id patch1.id
116 test_expect_success 'tg export --quilt wayback second' '
117 tg -C patches.git -w : export --quilt "$PWD/qu2" &&
118 git patch-id <qu2/patch.diff >qu2.id &&
119 test_diff qu2.id patch2.id
122 test_done