Skip to content

Commit b25ec8b

Browse files
committed
t1517: more coverage for commands that work without repository
While most of the commands in Git suite are designed to do useful things in Git repositories, some commands are also usable outside any repository. Building on top of an earlier work abece6e (t1517: test commands that are designed to be run outside repository, 2024-05-20) that adds tests for such commands, let's give coverage to some more commands. This patch covers commands whose code has hits for $ git grep setup_git_directory_gently and passes a pointer to nongit_ok variable it uses to allow it to run outside a Git repository, but mostly they are tested only to see that they start up (as opposed to dying with "not in a git repository" complaint). We may want to update them to actually do something useful later, but this would at least help us catch regressions by mistake. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4674ab6 commit b25ec8b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

t/t1517-outside-repo.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,56 @@ test_expect_success 'grep outside repository' '
5656
test_cmp expect actual
5757
'
5858

59+
test_expect_success 'imap-send outside repository' '
60+
test_config_global imap.host imaps://localhost &&
61+
test_config_global imap.folder Drafts &&
62+
63+
echo nothing to send >expect &&
64+
test_must_fail git imap-send -v </dev/null 2>actual &&
65+
test_cmp expect actual &&
66+
67+
(
68+
cd non-repo &&
69+
test_must_fail git imap-send -v </dev/null 2>../actual
70+
) &&
71+
test_cmp expect actual
72+
'
73+
74+
test_expect_success 'check-ref-format outside repository' '
75+
git check-ref-format --branch refs/heads/xyzzy >expect &&
76+
nongit git check-ref-format --branch refs/heads/xyzzy >actual &&
77+
test_cmp expect actual
78+
'
79+
80+
test_expect_success 'diff outside repository' '
81+
echo one >one &&
82+
echo two >two &&
83+
test_must_fail git diff --no-index one two >expect.raw &&
84+
(
85+
cd non-repo &&
86+
cp ../one . &&
87+
cp ../two . &&
88+
test_must_fail git diff one two >../actual.raw
89+
) &&
90+
# outside repository diff falls back to SHA-1 but
91+
# GIT_DEFAULT_HASH may be set to sha256 on the in-repo side.
92+
sed -e "/^index /d" expect.raw >expect &&
93+
sed -e "/^index /d" actual.raw >actual &&
94+
test_cmp expect actual
95+
'
96+
97+
test_expect_success 'stripspace outside repository' '
98+
nongit git stripspace -s </dev/null
99+
'
100+
101+
test_expect_success 'remote-http outside repository' '
102+
test_must_fail git remote-http 2>actual &&
103+
test_grep "^error: remote-curl" actual &&
104+
(
105+
cd non-repo &&
106+
test_must_fail git remote-http 2>../actual
107+
) &&
108+
test_grep "^error: remote-curl" actual
109+
'
110+
59111
test_done

0 commit comments

Comments
 (0)