From b25ec8b8d58e73c4327b0fcc9298e7ef6fe8e7a7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 31 May 2024 01:43:27 -0700 Subject: [PATCH 1/2] 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 abece6e9 (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 --- t/t1517-outside-repo.sh | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh index 557808ffa7..990a036582 100755 --- a/t/t1517-outside-repo.sh +++ b/t/t1517-outside-repo.sh @@ -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 actual && + test_cmp expect actual && + + ( + cd non-repo && + test_must_fail git imap-send -v ../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 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 From 56f4f4a29d32e177ef9af0907a17e431e8b3737e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 4 Jun 2024 11:46:10 -0700 Subject: [PATCH 2/2] imap-send: minimum leakfix EVen with the minimum "no-op" invocation t1517 makes, "git imap-send" leaks an empty strbuf it used to read a 0-byte string into. There are a few other topics cooking in 'next' that plugs many other leaks in this program, so let's minimally fix this one, barely enough to make CI pass, leaving the rest for the other topic. Helped-by: Jeff King Signed-off-by: Junio C Hamano --- imap-send.c | 1 + 1 file changed, 1 insertion(+) diff --git a/imap-send.c b/imap-send.c index c0130d0e02..fb2506dbef 100644 --- a/imap-send.c +++ b/imap-send.c @@ -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; }