diagnose.c: add option to configure archive contents
[alt-git.git] / t / t5900-repo-selection.sh
bloba84faac242d0406f523a78bd201ddcb59ae3acd8
1 #!/bin/sh
3 test_description='selecting remote repo in ambiguous cases'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 reset() {
9 rm -rf foo foo.git fetch clone
12 make_tree() {
13 git init "$1" &&
14 (cd "$1" && test_commit "$1")
17 make_bare() {
18 git init --bare "$1" &&
19 (cd "$1" &&
20 tree=$(git hash-object -w -t tree /dev/null) &&
21 commit=$(echo "$1" | git commit-tree $tree) &&
22 git update-ref HEAD $commit
26 get() {
27 git init --bare fetch &&
28 (cd fetch && git fetch "../$1") &&
29 git clone "$1" clone
32 check() {
33 echo "$1" >expect &&
34 (cd fetch && git log -1 --format=%s FETCH_HEAD) >actual.fetch &&
35 (cd clone && git log -1 --format=%s HEAD) >actual.clone &&
36 test_cmp expect actual.fetch &&
37 test_cmp expect actual.clone
40 test_expect_success 'find .git dir in worktree' '
41 reset &&
42 make_tree foo &&
43 get foo &&
44 check foo
47 test_expect_success 'automagically add .git suffix' '
48 reset &&
49 make_bare foo.git &&
50 get foo &&
51 check foo.git
54 test_expect_success 'automagically add .git suffix to worktree' '
55 reset &&
56 make_tree foo.git &&
57 get foo &&
58 check foo.git
61 test_expect_success 'prefer worktree foo over bare foo.git' '
62 reset &&
63 make_tree foo &&
64 make_bare foo.git &&
65 get foo &&
66 check foo
69 test_expect_success 'prefer bare foo over bare foo.git' '
70 reset &&
71 make_bare foo &&
72 make_bare foo.git &&
73 get foo &&
74 check foo
77 test_expect_success 'disambiguate with full foo.git' '
78 reset &&
79 make_bare foo &&
80 make_bare foo.git &&
81 get foo.git &&
82 check foo.git
85 test_expect_success 'we are not fooled by non-git foo directory' '
86 reset &&
87 make_bare foo.git &&
88 mkdir foo &&
89 get foo &&
90 check foo.git
93 test_expect_success 'prefer inner .git over outer bare' '
94 reset &&
95 make_tree foo &&
96 make_bare foo.git &&
97 mv foo/.git foo.git &&
98 get foo.git &&
99 check foo
102 test_done