{"thread":{"id":"38706","subject":"[PATCH v2 2/2] git-C: Add test to check \"git -C ''\"","startedAt":"2015-03-05T10:57:11Z","lastAt":"2015-03-05T21:39:29Z","messageCount":3,"participants":["Karthik Nayak","karthik nayak","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"257068","messageId":"1425553031-22264-1-git-send-email-karthik.188@gmail.com","threadId":"38706","inReplyTo":null,"subject":"[PATCH v2 2/2] git-C: Add test to check \"git -C ''\"","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-03-05T10:57:11Z","receivedAt":"2015-03-05T10:57:11Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Add a test to check whether \"git -C ''\" works\nwithout giving an error. This is achieved by\nadding a commit and checking the log using\n\"git -C ''\" and comparing the log message with\nthe commit message.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n t/t0056-git-C.sh | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/t/t0056-git-C.sh b/t/t0056-git-C.sh\nindex 99c0377..1cefd4a 100755\n--- a/t/t0056-git-C.sh\n+++ b/t/t0056-git-C.sh\n@@ -1,3 +1,4 @@\n+\n #!/bin/sh\n \n test_description='\"-C <path>\" option and its effects on other path-related options'\n@@ -81,4 +82,13 @@ test_expect_success 'Relative followed by fullpath: \"-C ./here -C /there\" is equ\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'Should not barf when \"git -C \"\" cmd\" is used' '\n+\techo 1 > a.txt &&\n+\tmsg=\"initial a.txt\" &&\n+\t(git add a.txt && git commit -m \"$msg\") &&\n+\techo \"$msg\" >expected &&\n+\tgit -C \"\" log --format=%s >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.3.1.167.g7f4ba4b.dirty\n"},{"id":"257069","messageId":"54F837B4.2060003@gmail.com","threadId":"38706","inReplyTo":"1425553031-22264-1-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v2 2/2] git-C: Add test to check \"git -C ''\"","fromName":"karthik nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-03-05T11:02:12Z","receivedAt":"2015-03-05T11:02:12Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"\nOn 03/05/2015 04:27 PM, Karthik Nayak wrote:\n> Add a test to check whether \"git -C ''\" works\n> without giving an error. This is achieved by\n> adding a commit and checking the log using\n> \"git -C ''\" and comparing the log message with\n> the commit message.\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>   t/t0056-git-C.sh | 10 ++++++++++\n>   1 file changed, 10 insertions(+)\n>\n> diff --git a/t/t0056-git-C.sh b/t/t0056-git-C.sh\n> index 99c0377..1cefd4a 100755\n> --- a/t/t0056-git-C.sh\n> +++ b/t/t0056-git-C.sh\n> @@ -1,3 +1,4 @@\n> +\n>   #!/bin/sh\n>\n>   test_description='\"-C <path>\" option and its effects on other path-related options'\n> @@ -81,4 +82,13 @@ test_expect_success 'Relative followed by fullpath: \"-C ./here -C /there\" is equ\n>       test_cmp expected actual\n>   '\n>\n> +test_expect_success 'Should not barf when \"git -C \"\" cmd\" is used' '\n> +    echo 1 > a.txt &&\n> +    msg=\"initial a.txt\" &&\n> +    (git add a.txt && git commit -m \"$msg\") &&\n> +    echo \"$msg\" >expected &&\n> +    git -C \"\" log --format=%s >actual &&\n> +    test_cmp expected actual\n> +'\n> +\n>   test_done\n>\nIgnore This, Didnt connect it to the first patch!\n"},{"id":"257109","messageId":"xmqq1tl32kfi.fsf@gitster.dls.corp.google.com","threadId":"38706","inReplyTo":"1425553031-22264-1-git-send-email-karthik.188@gmail.com","subject":"Re: [PATCH v2 2/2] git-C: Add test to check \"git -C ''\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-05T21:39:29Z","receivedAt":"2015-03-05T21:39:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> Add a test to check whether \"git -C ''\" works without giving an\n> error. This is achieved by adding a commit and checking the log\n> using \"git -C ''\" and comparing the log message with the commit\n> message.\n\nWhy choose something complex like commit and log, though?\n\nWouldn't something like this match the series of current tests\nbetter?  Also I think a small change with a small test like these\nshould be in a single patch, not two separate ones.\n\nThanks.\n\n t/t0056-git-C.sh | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/t/t0056-git-C.sh b/t/t0056-git-C.sh\nindex 99c0377..551d806 100755\n--- a/t/t0056-git-C.sh\n+++ b/t/t0056-git-C.sh\n@@ -14,6 +14,16 @@ test_expect_success '\"git -C <path>\" runs git from the directory <path>' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success '\"git -C <path>\" with an empty <path> is a no-op' '\n+\t(\n+\t\tmkdir -p dir1/subdir &&\n+\t\tcd dir1/subdir &&\n+\t\tgit -C \"\" rev-parse --show-prefix >actual &&\n+\t\techo subdir/ >expect\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_expect_success 'Multiple -C options: \"-C dir1 -C dir2\" is equivalent to \"-C dir1/dir2\"' '\n \ttest_create_repo dir1/dir2 &&\n \techo 1 >dir1/dir2/b.txt &&\n"}]}