Sync with master
[git/jrn.git] / t / t2026-prune-linked-checkouts.sh
blob4ccfa4ee8a2244436ddeeeab31f08718eb29f8b7
1 #!/bin/sh
3 test_description='prune $GIT_DIR/repos'
5 . ./test-lib.sh
7 test_expect_success 'prune --repos on normal repo' '
8 git prune --repos &&
9 test_must_fail git prune --repos abc
12 test_expect_success 'prune files inside $GIT_DIR/repos' '
13 mkdir .git/repos &&
14 : >.git/repos/abc &&
15 git prune --repos --verbose >actual &&
16 cat >expect <<EOF &&
17 Removing repos/abc: not a valid directory
18 EOF
19 test_i18ncmp expect actual &&
20 ! test -f .git/repos/abc &&
21 ! test -d .git/repos
24 test_expect_success 'prune directories without gitdir' '
25 mkdir -p .git/repos/def/abc &&
26 : >.git/repos/def/def &&
27 cat >expect <<EOF &&
28 Removing repos/def: gitdir file does not exist
29 EOF
30 git prune --repos --verbose >actual &&
31 test_i18ncmp expect actual &&
32 ! test -d .git/repos/def &&
33 ! test -d .git/repos
36 test_expect_success POSIXPERM 'prune directories with unreadable gitdir' '
37 mkdir -p .git/repos/def/abc &&
38 : >.git/repos/def/def &&
39 : >.git/repos/def/gitdir &&
40 chmod u-r .git/repos/def/gitdir &&
41 git prune --repos --verbose >actual &&
42 test_i18ngrep "Removing repos/def: unable to read gitdir file" actual &&
43 ! test -d .git/repos/def &&
44 ! test -d .git/repos
47 test_expect_success 'prune directories with invalid gitdir' '
48 mkdir -p .git/repos/def/abc &&
49 : >.git/repos/def/def &&
50 : >.git/repos/def/gitdir &&
51 git prune --repos --verbose >actual &&
52 test_i18ngrep "Removing repos/def: invalid gitdir file" actual &&
53 ! test -d .git/repos/def &&
54 ! test -d .git/repos
57 test_expect_success 'prune directories with gitdir pointing to nowhere' '
58 mkdir -p .git/repos/def/abc &&
59 : >.git/repos/def/def &&
60 echo "$TRASH_DIRECTORY"/nowhere >.git/repos/def/gitdir &&
61 git prune --repos --verbose >actual &&
62 test_i18ngrep "Removing repos/def: gitdir file points to non-existent location" actual &&
63 ! test -d .git/repos/def &&
64 ! test -d .git/repos
67 test_expect_success 'not prune locked checkout' '
68 test_when_finished rm -r .git/repos
69 mkdir -p .git/repos/ghi &&
70 : >.git/repos/ghi/locked &&
71 git prune --repos &&
72 test -d .git/repos/ghi
75 test_expect_success 'not prune recent checkouts' '
76 test_when_finished rm -r .git/repos
77 mkdir zz &&
78 mkdir -p .git/repos/jlm &&
79 echo "$TRASH_DIRECTORY"/zz >.git/repos/jlm/gitdir &&
80 git prune --repos --verbose &&
81 test -d .git/repos/jlm
84 test_done