3 test_description
='prune $GIT_DIR/repos'
7 test_expect_success
'prune --repos on normal repo' '
9 test_must_fail git prune --repos abc
12 test_expect_success
'prune files inside $GIT_DIR/repos' '
15 git prune --repos --verbose >actual &&
17 Removing repos/abc: not a valid directory
19 test_i18ncmp expect actual &&
20 ! test -f .git/repos/abc &&
24 test_expect_success
'prune directories without gitdir' '
25 mkdir -p .git/repos/def/abc &&
26 : >.git/repos/def/def &&
28 Removing repos/def: gitdir file does not exist
30 git prune --repos --verbose >actual &&
31 test_i18ncmp expect actual &&
32 ! test -d .git/repos/def &&
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 &&
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 &&
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 &&
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 &&
72 test -d .git/repos/ghi
75 test_expect_success
'not prune recent checkouts' '
76 test_when_finished rm -r .git/repos
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