{"thread":{"id":"61566","subject":"[PATCH] t1517: more coverage for commands that work without repository","startedAt":"2024-05-30T16:58:51Z","lastAt":"2024-05-31T14:57:50Z","messageCount":4,"participants":["Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"495965","messageId":"xmqqbk4np77d.fsf@gitster.g","threadId":"61566","inReplyTo":null,"subject":"[PATCH] t1517: more coverage for commands that work without repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-30T16:58:46Z","receivedAt":"2024-05-30T16:58:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"While most of the commands in Git suite are designed to do useful\nthings in Git repositories, some commands are also usable outside\nany repository.  Building on top of an earlier work abece6e9 (t1517:\ntest commands that are designed to be run outside repository,\n2024-05-20) that adds tests for such commands, let's give coverage\nto some more commands.\n\nThis patch covers commands whose code has hits for\n\n    $ git grep setup_git_directory_gently\n\nand passes a pointer to nongit_ok variable it uses to allow it to\nrun outside a Git repository, but mostly they are tested only to see\nthat they start up (as opposed to dying with \"not in a git\nrepository\" complaint).  We may want to update them to actually do\nsomething useful later, but this would at least help us catch\nregressions by mistake.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * Designed to apply on top of jc/undecided-is-not-necessarily-sha1-fix\n   that introduces t1517.\n\n t/t1517-outside-repo.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 48 insertions(+)\n\ndiff --git c/t/t1517-outside-repo.sh w/t/t1517-outside-repo.sh\nindex 557808ffa7..b77017ac5f 100755\n--- c/t/t1517-outside-repo.sh\n+++ w/t/t1517-outside-repo.sh\n@@ -56,4 +56,52 @@ test_expect_success 'grep outside repository' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'imap-send outside repository' '\n+\ttest_config_global imap.host imaps://localhost &&\n+\ttest_config_global imap.folder Drafts &&\n+\n+\techo nothing to send >expect &&\n+\ttest_must_fail git imap-send -v </dev/null 2>actual &&\n+\ttest_cmp expect actual &&\n+\n+\t(\n+\t\tcd non-repo &&\n+\t\ttest_must_fail git imap-send -v </dev/null 2>../actual\n+\t) &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'check-ref-format outside repository' '\n+\tgit check-ref-format --branch refs/heads/xyzzy >expect &&\n+\tnongit git check-ref-format --branch refs/heads/xyzzy >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'diff outside repository' '\n+\techo one >one &&\n+\techo two >two &&\n+\ttest_must_fail git diff --no-index one two >expect &&\n+\t(\n+\t\tcd non-repo &&\n+\t\tcp ../one . &&\n+\t\tcp ../two . &&\n+\t\ttest_must_fail git diff one two >../actual\n+\t) &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'stripspace outside repository' '\n+\tnongit git stripspace -s </dev/null\n+'\n+\n+test_expect_success 'remote-http outside repository' '\n+\ttest_must_fail git remote-http 2>actual &&\n+\ttest_grep \"^error: remote-curl\" actual &&\n+\t(\n+\t\tcd non-repo &&\n+\t\ttest_must_fail git remote-http 2>../actual\n+\t) &&\n+\ttest_grep \"^error: remote-curl\" actual\n+'\n+\n test_done\n"},{"id":"495981","messageId":"xmqqwmnajrrk.fsf@gitster.g","threadId":"61566","inReplyTo":"xmqqbk4np77d.fsf@gitster.g","subject":"[PATCH v2] t1517: more coverage for commands that work without repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-31T08:43:27Z","receivedAt":"2024-05-31T08:43:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"While most of the commands in Git suite are designed to do useful\nthings in Git repositories, some commands are also usable outside\nany repository.  Building on top of an earlier work abece6e9 (t1517:\ntest commands that are designed to be run outside repository,\n2024-05-20) that adds tests for such commands, let's give coverage\nto some more commands.\n\nThis patch covers commands whose code has hits for\n\n    $ git grep setup_git_directory_gently\n\nand passes a pointer to nongit_ok variable it uses to allow it to\nrun outside a Git repository, but mostly they are tested only to see\nthat they start up (as opposed to dying with \"not in a git\nrepository\" complaint).  We may want to update them to actually do\nsomething useful later, but this would at least help us catch\nregressions by mistake.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n * The previous iteration was buggy when the repository was using\n   sha256, as the nongit invocation of \"git diff\" will use sha1.\n\n t/t1517-outside-repo.sh | 52 +++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 52 insertions(+)\n\ndiff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh\nindex 557808ffa7..990a036582 100755\n--- a/t/t1517-outside-repo.sh\n+++ b/t/t1517-outside-repo.sh\n@@ -56,4 +56,56 @@ test_expect_success 'grep outside repository' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'imap-send outside repository' '\n+\ttest_config_global imap.host imaps://localhost &&\n+\ttest_config_global imap.folder Drafts &&\n+\n+\techo nothing to send >expect &&\n+\ttest_must_fail git imap-send -v </dev/null 2>actual &&\n+\ttest_cmp expect actual &&\n+\n+\t(\n+\t\tcd non-repo &&\n+\t\ttest_must_fail git imap-send -v </dev/null 2>../actual\n+\t) &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'check-ref-format outside repository' '\n+\tgit check-ref-format --branch refs/heads/xyzzy >expect &&\n+\tnongit git check-ref-format --branch refs/heads/xyzzy >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'diff outside repository' '\n+\techo one >one &&\n+\techo two >two &&\n+\ttest_must_fail git diff --no-index one two >expect.raw &&\n+\t(\n+\t\tcd non-repo &&\n+\t\tcp ../one . &&\n+\t\tcp ../two . &&\n+\t\ttest_must_fail git diff one two >../actual.raw\n+\t) &&\n+\t# outside repository diff falls back to SHA-1 but\n+\t# GIT_DEFAULT_HASH may be set to sha256 on the in-repo side.\n+\tsed -e \"/^index /d\" expect.raw >expect &&\n+\tsed -e \"/^index /d\" actual.raw >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'stripspace outside repository' '\n+\tnongit git stripspace -s </dev/null\n+'\n+\n+test_expect_success 'remote-http outside repository' '\n+\ttest_must_fail git remote-http 2>actual &&\n+\ttest_grep \"^error: remote-curl\" actual &&\n+\t(\n+\t\tcd non-repo &&\n+\t\ttest_must_fail git remote-http 2>../actual\n+\t) &&\n+\ttest_grep \"^error: remote-curl\" actual\n+'\n+\n test_done\n\nInterdiff against v1:\n  diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh\n  index b77017ac5f..990a036582 100755\n  --- a/t/t1517-outside-repo.sh\n  +++ b/t/t1517-outside-repo.sh\n  @@ -80,13 +80,17 @@ test_expect_success 'check-ref-format outside repository' '\n   test_expect_success 'diff outside repository' '\n   \techo one >one &&\n   \techo two >two &&\n  -\ttest_must_fail git diff --no-index one two >expect &&\n  +\ttest_must_fail git diff --no-index one two >expect.raw &&\n   \t(\n   \t\tcd non-repo &&\n   \t\tcp ../one . &&\n   \t\tcp ../two . &&\n  -\t\ttest_must_fail git diff one two >../actual\n  +\t\ttest_must_fail git diff one two >../actual.raw\n   \t) &&\n  +\t# outside repository diff falls back to SHA-1 but\n  +\t# GIT_DEFAULT_HASH may be set to sha256 on the in-repo side.\n  +\tsed -e \"/^index /d\" expect.raw >expect &&\n  +\tsed -e \"/^index /d\" actual.raw >actual &&\n   \ttest_cmp expect actual\n   '\n   \n-- \n2.45.2-584-g20241e85ff\n\n"},{"id":"495989","messageId":"Zlmz9Edyv_gehMVr@tanuki","threadId":"61566","inReplyTo":"xmqqbk4np77d.fsf@gitster.g","subject":"Re: [PATCH] t1517: more coverage for commands that work without repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-05-31T11:26:44Z","receivedAt":"2024-05-31T11:26:49Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, May 30, 2024 at 09:58:46AM -0700, Junio C Hamano wrote:\n[snip]\n> +test_expect_success 'stripspace outside repository' '\n> +\tnongit git stripspace -s </dev/null\n> +'\n\nI was wondering whether we also want to verify that it does the correct\nthing here as it's comparatively easy:\n\n\ttest_expect_success 'stripspace outside repository' '\n\t\tcat >input <<-EOF &&\n\t\t# foo\n\t\tbar\n\t\tEOF\n\t\tcat >expect <<-EOF &&\n\t\tbar\n\t\tEOF\n\n\t\tgit stripspace -s <input >actual &&\n\t\ttest_cmp expect actual &&\n\t\tnongit git stripspace -s <input >actual &&\n\t\ttest_cmp expect actual\n\t'\n\nFor the other tests it's a bit more involved. And given that these are\nall designed as smoke tests, I think it's fine overall.\n\nThanks!\n\nPatrick\n"},{"id":"496012","messageId":"xmqqplt2hvv8.fsf@gitster.g","threadId":"61566","inReplyTo":"Zlmz9Edyv_gehMVr@tanuki","subject":"Re: [PATCH] t1517: more coverage for commands that work without repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-31T14:57:47Z","receivedAt":"2024-05-31T14:57:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Thu, May 30, 2024 at 09:58:46AM -0700, Junio C Hamano wrote:\n> [snip]\n>> +test_expect_success 'stripspace outside repository' '\n>> +\tnongit git stripspace -s </dev/null\n>> +'\n>\n> I was wondering whether we also want to verify that it does the correct\n> thing here as it's comparatively easy:\n> ...\n> For the other tests it's a bit more involved. And given that these are\n> all designed as smoke tests, I think it's fine overall.\n\nYup, as I said in the proposed log message, we may want to update\nthem to actually do something useful later, but this would at least\nhelp us catch regressions by mistake.\n\n"}]}