1
0
mirror of https://github.com/git/git.git synced 2024-10-18 12:18:44 +02:00

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
This commit is contained in:
Junio C Hamano 2024-06-12 13:37:13 -07:00
commit a39e28ace7
2 changed files with 53 additions and 0 deletions

@ -1543,6 +1543,7 @@ int cmd_main(int argc, const char **argv)
}
if (all_msgs.len == 0) {
strbuf_release(&all_msgs);
fprintf(stderr, "nothing to send\n");
return 1;
}

@ -56,4 +56,56 @@ test_expect_success 'grep outside repository' '
test_cmp expect actual
'
test_expect_success 'imap-send outside repository' '
test_config_global imap.host imaps://localhost &&
test_config_global imap.folder Drafts &&
echo nothing to send >expect &&
test_must_fail git imap-send -v </dev/null 2>actual &&
test_cmp expect actual &&
(
cd non-repo &&
test_must_fail git imap-send -v </dev/null 2>../actual
) &&
test_cmp expect actual
'
test_expect_success 'check-ref-format outside repository' '
git check-ref-format --branch refs/heads/xyzzy >expect &&
nongit git check-ref-format --branch refs/heads/xyzzy >actual &&
test_cmp expect actual
'
test_expect_success 'diff outside repository' '
echo one >one &&
echo two >two &&
test_must_fail git diff --no-index one two >expect.raw &&
(
cd non-repo &&
cp ../one . &&
cp ../two . &&
test_must_fail git diff one two >../actual.raw
) &&
# outside repository diff falls back to SHA-1 but
# GIT_DEFAULT_HASH may be set to sha256 on the in-repo side.
sed -e "/^index /d" expect.raw >expect &&
sed -e "/^index /d" actual.raw >actual &&
test_cmp expect actual
'
test_expect_success 'stripspace outside repository' '
nongit git stripspace -s </dev/null
'
test_expect_success 'remote-http outside repository' '
test_must_fail git remote-http 2>actual &&
test_grep "^error: remote-curl" actual &&
(
cd non-repo &&
test_must_fail git remote-http 2>../actual
) &&
test_grep "^error: remote-curl" actual
'
test_done