tg.sh: handle help -h
[topgit/pro.git] / t / t5011-update-skip-missing.sh
blob82653f92f2fa0b6caf1c2f10ea3e6482391c00c7
1 #!/bin/sh
3 test_description='tg update --skip-missing branches'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
9 test_plan 7
11 uctmp="$(test_get_temp update-check)" || die
13 branch_is_up_to_date() {
14 needs_update_check "$@" >"$uctmp" &&
16 read -r uc_processed &&
17 read -r uc_behind &&
18 read -r uc_ahead &&
19 read -r uc_partial
20 } <"$uctmp" &&
21 test z"$uc_behind" = z":"
24 test_expect_success 'setup' '
25 test_create_repo pristine &&
26 cd pristine &&
27 git config core.logallrefupdates false &&
28 git checkout --orphan release &&
29 git read-tree --empty &&
30 git reset --hard &&
31 test_commit "release~1" &&
32 tg_test_create_branches <<-EOT &&
33 t/patch1 [PATCH] alpha patch
34 release
36 t/patch2 [PATCH] beta patch
37 release
38 EOT
39 git checkout -f t/patch1 &&
40 test_commit "alpha~1" &&
41 tg_test_create_branch t/int -m "[INTERMEDIATE] extra level" t/patch2 &&
42 git checkout -f t/patch2 &&
43 test_commit "beta~1" &&
44 tg_test_create_branch stage -m "[STAGE] staging branch" release t/patch1 t/int &&
45 test_must_fail branch_is_up_to_date stage &&
46 git repack -afd &&
47 git prune --expire=now &&
48 git pack-refs --prune --all &&
49 test_when_finished test_tick=$test_tick &&
50 test_when_finished test_set_prereq SETUP
53 test_expect_success SETUP 'tg update succeeds with nothing missing' '
54 cp -pR pristine succeeds &&
55 cd succeeds &&
56 tg update --no-stash stage &&
57 branch_is_up_to_date stage
60 test_expect_success SETUP 'tg update fails with missing dependency' '
61 cp -pR pristine fails &&
62 cd fails &&
63 git checkout -f stage &&
64 git branch -M t/patch2 t-missing/patch2 &&
65 test_must_fail tg update --no-stash stage
68 test_expect_success SETUP,LASTOK 'tg update --skip-missing succeeds with missing dependency' '
69 cd fails &&
70 test_might_fail tg update --abort >/dev/null 2>&1 &&
71 git checkout -f stage &&
72 tg update --no-stash --skip-missing stage
75 test_expect_success SETUP,LASTOK 'branch up-to-date with missing depedency' '
76 cd fails &&
77 git checkout -f stage &&
78 branch_is_up_to_date stage
81 test_expect_success SETUP,LASTOK 'branch out of date after restoring branch' '
82 cd fails &&
83 git checkout -f stage &&
84 git branch -M t-missing/patch2 t/patch2 &&
85 test_must_fail branch_is_up_to_date stage
88 test_expect_success SETUP,LASTOK 'tg update finally succeeds completely' '
89 cd fails &&
90 git checkout -f stage &&
91 tg update --no-stash stage &&
92 branch_is_up_to_date stage
95 test_done