tg.sh: handle help -h
[topgit/pro.git] / t / t2200-depend-add.sh
bloba50e0b813db78a4965d2895c0e57b98cb87ec82a
1 #!/bin/sh
3 test_description='tg depend add tests'
5 . ./test-lib.sh
7 test_plan 4
9 # true if $1 is contained by (or the same as) $2
10 # this is never slower than merge-base --is-ancestor and is often slightly faster
11 contained_by() {
12 [ "$(git rev-list --count --max-count=1 "$1" --not "$2" --)" = "0" ]
15 test_expect_success 'setup' '
16 tg_test_create_branches <<-EOT &&
17 t/one
20 t/two
23 t/tri
26 t/six
29 stage
31 EOT
32 git checkout -f t/one &&
33 test_commit "test one" one.txt &&
34 git checkout -f t/two &&
35 test_commit "test two" two.txt &&
36 git checkout -f t/tri &&
37 test_commit "test tri" tri.txt &&
38 git checkout -f t/six &&
39 test_commit "test six" six.txt &&
40 test_when_finished test_tick=$test_tick &&
41 test_when_finished test_set_prereq SETUP
44 test_expect_success SETUP 'add multiple deps' '
45 git checkout -f stage &&
46 test_tick &&
47 tg -c topgit.autostash=false depend add t/one t/two t/tri t/six &&
48 test_when_finished test_tick=$test_tick &&
49 test_when_finished test_set_prereq ADDED
52 test_expect_success ADDED 'four deps added' '
53 printf "%s\n" t/one t/two t/tri t/six >expected &&
54 test_cmp .topdeps expected
57 test_expect_success ADDED 'dependencies are contained in base' '
58 topbases="$(tg --top-bases)" &&
59 test -n "$topbases" &&
60 contained_by refs/heads/t/one "$topbases/stage" &&
61 contained_by refs/heads/t/two "$topbases/stage" &&
62 contained_by refs/heads/t/tri "$topbases/stage" &&
63 contained_by refs/heads/t/six "$topbases/stage" &&
64 contained_by "$topbases/stage" refs/heads/stage
67 test_done