Skip to content

Commit a39e28a

Browse files
committed
Merge branch 'jc/t1517-more'
A new test was added to ensure git commands that are designed to run outside repositories do work. * jc/t1517-more: imap-send: minimum leakfix t1517: more coverage for commands that work without repository
2 parents 8d94cfb + 56f4f4a commit a39e28a

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

imap-send.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ int cmd_main(int argc, const char **argv)
15431543
}
15441544

15451545
if (all_msgs.len == 0) {
1546+
strbuf_release(&all_msgs);
15461547
fprintf(stderr, "nothing to send\n");
15471548
return 1;
15481549
}

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)