On Tue, Mar 10, 2015 at 6:52 AM, Sudhanshu Shekhar <sudshekhar02@xxxxxxxxx> wrote: > Added tests for reset - Mention the area of the project you are changing, followed by a colon, followed by a short summary of the change. Drop capitalization. Write in imperative mood. t7102: add 'reset -' tests > Added the following test cases: Imperative mood: "Add test cases:" > 1) Confirm error message when git reset is used with no previous branch > 2) Confirm git reset - works like git reset @{-1} > 3) Confirm "-" is always treated as a commit unless the -- file option > is specified > 4) Confirm "git reset -" works normally even when a file named @{-1} is > present > > Helped-by: David Aguilar <davvid@xxxxxxxxx> > Signed-off-by: Sudhanshu Shekhar <sudshekhar02@xxxxxxxxx> > --- > diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh > index 98bcfe2..0faf241 100755 > --- a/t/t7102-reset.sh > +++ b/t/t7102-reset.sh > @@ -568,4 +568,143 @@ test_expect_success 'reset --mixed sets up work tree' ' > test_cmp expect actual > ' > > +test_expect_success 'reset - in the presence of file named - with previous branch' ' > + echo "Unstaged changes after reset:" >expect && > + echo "M -" >>expect && > + echo "M 1" >>expect && Mentioned by Matthieu: Use "cat <<-\EOF". > + git init no_previous && > + ( > + cd no_previous && > + >./- && Unnecessarily complex ">./-" when ">-" will suffice. > + >1 && > + git add 1 - && > + git commit -m "add base files" && > + git checkout -b new_branch && > + echo "random" >./- && > + echo "wow" >1 && > + git add 1 - && > + git reset - >../output Since you will be comparing this output with "expected" output, it is customary to name this file "actual". > + ) && > + rm -rf no_previous && Mentioned by Matthieu: Use test_when_finished(). You want this cleanup action invoked even if any part of the test fails, so register it as early as possible for it to be effective; either just before or after git-init. > + test_cmp output expect When test_cmp() detects a difference in the expected and actual output, it dumps the difference (in 'diff' format) as debugging output. It's easier to read 'diff' output, and matches our expectations more closely, if 'expect' is mentioned before 'actual', so: test_cmp expect actual > +' > +test_expect_success 'reset - in the presence of file named - with -- file option' ' > + echo "Unstaged changes after reset:" >expect && > + echo "M -" >>expect && > + git init no_previous && > + ( > + cd no_previous && > + >./- && > + >1 && > + git add 1 - && > + git commit -m "add base files" && > + git checkout -b new_branch && > + echo "random" >./- && > + echo "wow" >1 && > + git add 1 - && > + git reset -- - >../output > + ) && > + rm -rf no_previous Broken &&-chain. > + test_cmp output expect > +' > +test_expect_success 'reset - in the presence of file named - with both pre and post -- option' ' > + echo "Unstaged changes after reset:" >expect && > + echo "M -" >>expect && > + git init no_previous && > + ( > + cd no_previous && > + >./- && > + >1 && > + git add 1 - && > + git commit -m "add base files" && > + git checkout -b new_branch && > + echo "random" >./- && > + echo "wow" >1 && > + git add 1 - && > + git reset - -- - >../output > + ) && > + rm -rf no_previous Broken &&-chain. > + test_cmp output expect > +' > + > +test_expect_success 'reset - works same as reset @{-1}' ' > + git init no_previous && > + ( > + cd no_previous && > + echo "random" >random && > + git add random && > + git commit -m "base commit" && > + git checkout -b temp && > + echo new-file >new-file && > + git add new-file && > + git commit -m "added new-file" && > + git reset - && > + git status --porcelain >../first && > + git add new-file && > + git commit -m "added new-file" && > + git reset @{-1} && > + git status --porcelain >../second > + ) && In other tests, you performed "rm -rf no_previous &&" cleanup at this point, but it's missing here. > + test_cmp first second > +' > + > +test_expect_success 'reset - with file named @{-1}' ' > + echo "Unstaged changes after reset:" >expect && > + echo "M @{-1}" >>expect && > + git init no_previous && > + ( > + cd no_previous && > + echo "random" >./@{-1} && > + git add ./@{-1} && > + git commit -m "base commit" && > + git checkout -b new_branch && > + echo "additional stuff" >>./@{-1} && > + git add ./@{-1} && > + git reset - >../output > + ) && > + rm -rf no_previous && > + test_cmp output expect > +' > + > test_done > -- > 2.3.1.279.gd534259 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html