{"thread":{"id":"38842","subject":"[v3 PATCH 2/2] reset: add tests for git reset -","startedAt":"2015-03-18T08:35:09Z","lastAt":"2015-03-20T20:32:36Z","messageCount":4,"participants":["Sundararajan R","Matthieu Moy","Kevin D"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"257919","messageId":"1426667709-26698-1-git-send-email-dyoucme@gmail.com","threadId":"38842","inReplyTo":null,"subject":"[v3 PATCH 2/2] reset: add tests for git reset -","fromName":"Sundararajan R","fromEmail":"dyoucme@gmail.com","sentAt":"2015-03-18T08:35:09Z","receivedAt":"2015-03-18T08:35:09Z","isPatch":true,"sender":{"key":"dyoucme@gmail.com","avatar":null},"body":"The failure case which occurs on teaching git is taught the '-' shorthand\nis when there exists no branch pointed to by '@{-1}'. But, if there is a file\nnamed - in the working tree, the user can be unambiguously assumed to be \nreferring to it while issuing this command.\n\nThe ambiguous case occurs when the @{-1} branch exists and file named '-' also\nexists in the working tree. This are also treated as a failure case but here \nthe user is given advice as to how he can proceed.\n\nAnother potentially tricky case is when the file '@{-1}' exists. In this case,\nthe command should succeed as the user doesn't mention the file '@{-1}' and can\nbe safely assumed to be referring to the @{-1} branch.\n\nAdd tests to check the handling of these cases.\nAlso add a test to verify that reset - behaves like reset @{-1} when none\nof the above cases are true.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: Eric Sunshine <sunshine@sunshineco.com>\nHelped-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>\nSigned-off-by: Sundararajan R <dyoucme@gmail.com>\n---\nThank you for your feedback Torsten and Eric. I have made modifications suggested \nby you. I have also acted on Matthieu's suggestions on the archive.\nPlease let me know if there is something else I should add.\nI have also removed one irrelevant test from  which we come to know of nothing new.\n\n t/t7102-reset.sh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 75 insertions(+)\n\ndiff --git a/t/t7102-reset.sh b/t/t7102-reset.sh\nindex 98bcfe2..f5a8e76 100755\n--- a/t/t7102-reset.sh\n+++ b/t/t7102-reset.sh\n@@ -568,4 +568,79 @@ test_expect_success 'reset --mixed sets up work tree' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'reset - with no @{-1} branch should fail' '\n+\ttest_when_finished rm -rf new &&\n+\tgit init new &&\n+\t(\n+\t\tcd new &&\n+\t\ttest_must_fail git reset - 2>../actual\n+\t) && \n+\ttest_i18ngrep \"bad flag\" actual \n+'\n+\n+test_expect_success 'reset - with no @{-1} branch and file named - should succeed' '\n+\ttest_when_finished rm -rf new &&\n+\t>expected &&\n+\tgit init new &&\n+\t(\n+\t\tcd new &&\n+\t\techo \"Hello\" >- &&\n+\t\tgit add - &&\n+\t\tgit reset - >../actual \n+\t) &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'reset - with @{-1} branch and file named - should fail' '\n+\ttest_when_finished rm -rf new &&\n+\tgit init new &&\n+\t(\n+\t\tcd new && \n+\t\techo \"Hello\" >- &&\n+\t\tgit add - &&\n+\t\tgit commit -m \"first_commit\" &&\n+\t\tgit checkout -b new_branch &&\n+\t\t>- &&\n+\t\tgit add - &&\n+\t\ttest_must_fail git reset - 2>../actual \n+\t) &&\n+\ttest_i18ngrep \"ambiguous argument\" actual \n+'\n+\n+test_expect_success 'reset - with @{-1} branch and file named @{-1} should succeed' '\n+\ttest_when_finished rm -rf new &&\n+\tgit init new &&\n+\t(\n+\t\tcd new && \n+\t\techo \"Hello\" >@{-1} &&\n+\t\tgit add @{-1} &&\n+\t\tgit commit -m \"first_commit\" &&\n+\t\tgit checkout -b new_branch &&\n+\t\t>@{-1} &&\n+\t\tgit add @{-1} &&\n+\t\tgit reset - >../actual \n+\t) &&\n+\ttest_i18ngrep \"Unstaged\" actual \n+'\n+\n+test_expect_success 'reset - with @{-1} branch and no file named - should succeed' '\n+\ttest_when_finished rm -rf new &&\n+\tgit init new &&\n+\t(\n+\t\tcd new &&\n+\t\techo \"Hey\" >new_file &&\n+\t\tgit add new_file &&\n+\t\tgit commit -m \"first_commit\" &&\n+\t\tgit checkout -b new_branch &&\n+\t\t>new_file &&\n+\t\tgit add new_file &&\n+\t\tgit reset - &&\n+\t\tgit status -uno >actual &&\n+\t\tgit add new_file &&\n+\t\tgit reset @{-1} &&\n+\t\tgit status -uno >expected &&\n+\t\ttest_cmp actual expected \n+\t)\n+'\n+\n test_done\n-- \n2.1.0\n"},{"id":"257965","messageId":"vpqh9ticklj.fsf@anie.imag.fr","threadId":"38842","inReplyTo":"1426667709-26698-1-git-send-email-dyoucme@gmail.com","subject":"Re: [v3 PATCH 2/2] reset: add tests for git reset -","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-03-18T16:54:16Z","receivedAt":"2015-03-18T16:54:16Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Sundararajan R <dyoucme@gmail.com> writes:\n\n> Subject: [v3 PATCH 2/2] reset: add tests for git reset -\n\nThis should be [PATCH v3 2/2].\n\n\"git send-email -v2\" can do this for you.\n\nSundararajan R <dyoucme@gmail.com> writes:\n\n> +test_expect_success 'reset - with no @{-1} branch and file named - should succeed' '\n> +\ttest_when_finished rm -rf new &&\n> +\t>expected &&\n> +\tgit init new &&\n> +\t(\n> +\t\tcd new &&\n> +\t\techo \"Hello\" >- &&\n> +\t\tgit add - &&\n> +\t\tgit reset - >../actual \n> +\t) &&\n> +\ttest_cmp expected actual\n> +'\n\ntest_must_be_empty actual would be easier to read than \">expected ...\ntest_cmp expected\" IMHO.\n\n> +test_expect_success 'reset - with @{-1} branch and no file named - should succeed' '\n> +\ttest_when_finished rm -rf new &&\n> +\tgit init new &&\n> +\t(\n> +\t\tcd new &&\n> +\t\techo \"Hey\" >new_file &&\n> +\t\tgit add new_file &&\n> +\t\tgit commit -m \"first_commit\" &&\n> +\t\tgit checkout -b new_branch &&\n> +\t\t>new_file &&\n> +\t\tgit add new_file &&\n> +\t\tgit reset - &&\n> +\t\tgit status -uno >actual &&\n> +\t\tgit add new_file &&\n> +\t\tgit reset @{-1} &&\n> +\t\tgit status -uno >expected &&\n> +\t\ttest_cmp actual expected \n> +\t)\n> +'\n\nBetter use \"git status --porcelain\" here as its format is meant to be\nstable and unambiguous. The non-porcelain should work two because you're\ncomparing the output on two identical states, but who knows.\n\nWith or without my suggested change, the series looks good to me.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"258071","messageId":"20150319221652.GE11832@vps892.directvps.nl","threadId":"38842","inReplyTo":"1426667709-26698-1-git-send-email-dyoucme@gmail.com","subject":"Re: [v3 PATCH 2/2] reset: add tests for git reset -","fromName":"Kevin D","fromEmail":"me@ikke.info","sentAt":"2015-03-19T22:16:52Z","receivedAt":"2015-03-19T22:16:52Z","isPatch":true,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Wed, Mar 18, 2015 at 02:05:09PM +0530, Sundararajan R wrote:\n> The failure case which occurs on teaching git is taught the '-' shorthand\n> is when there exists no branch pointed to by '@{-1}'. But, if there is a file\n> named - in the working tree, the user can be unambiguously assumed to be \n> referring to it while issuing this command.\n> \n\nThe first line is hard to read. I think the \"is taught\" part is\nredundant.\n"},{"id":"258186","messageId":"20150320203236.GF11832@vps892.directvps.nl","threadId":"38842","inReplyTo":"CAPV5_7+Kfuiy01cmwfjJCGJPo7mO_bzBc7DjPr9JyuV=XSXSrA@mail.gmail.com","subject":"Re: [v3 PATCH 2/2] reset: add tests for git reset -","fromName":"Kevin D","fromEmail":"me@ikke.info","sentAt":"2015-03-20T20:32:36Z","receivedAt":"2015-03-20T20:32:36Z","isPatch":true,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Fri, Mar 20, 2015 at 04:02:38AM +0530, Sundararajan R wrote:\n> Yes. I made a mistake while framing the sentence. I should have proof read\n> the commit message more thoroughly.  Should I submit a new patch with the\n> corrected commit message?\n\nYeah, you can combine that with the comments from Matthieu.\n"}]}