From: Sundararajan R <dyoucme@gmail.com>
To: git@vger.kernel.org
Cc: Sundararajan R <dyoucme@gmail.com>
Subject: [PATCH 2/2] Added tests for git reset -
Date: Tue, 10 Mar 2015 02:16:50 +0530 [thread overview]
Message-ID: <1425934010-8780-2-git-send-email-dyoucme@gmail.com> (raw)
In-Reply-To: <1425934010-8780-1-git-send-email-dyoucme@gmail.com>
As you had suggested @Junio, I have added the required tests.
Please let me know if there is something is I should add.
Signed-off-by: Sundararajan R <dyoucme@gmail.com>
Thanks-to: Junio C Hamano
---
I have added 6 tests to check for the following cases:
git reset - with no @{-1}
git reset - with no @{-1} and file named -
git reset - with @{-1} and file named @{-1}
git reset - with @{-1} and file named -
git reset - with @{-1} and file named @{-1} and -
git reset - with @{-1} and no file named - or @{-1}
The 1st test with no previous branch results in the error
The 2nd,3rd,4th and 5th result in the ambiguous argument error
The 6th test has - working like @{-1}
t/t7102-reset.sh | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 107 insertions(+)
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 98bcfe2..a670938 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -568,4 +568,111 @@ test_expect_success 'reset --mixed sets up work tree' '
test_cmp expect actual
'
+test_expect_success 'reset - with no @{-1}' '
+ git init new --quiet &&
+ cd new &&
+ test_must_fail git reset - >actual &&
+ touch expect &&
+ test_cmp expect actual
+'
+
+rm -rf new
+
+cat >expect <<EOF
+fatal: ambiguous argument '-': both revision and filename
+Use ./- for file named -
+Use '--' to separate paths from revisions, like this:
+'git <command> [<revision>...] -- [<file>...]'
+EOF
+
+test_expect_success 'reset - with no @{-1} and file named -' '
+ git init new --quiet &&
+ cd new &&
+ echo "Hello" > - &&
+ git add -
+ test_must_fail git reset - 2>actual &&
+ test_cmp ../expect actual
+'
+
+cd ..
+rm -rf new
+
+cat >expect <<EOF
+fatal: ambiguous argument '@{-1}': both revision and filename
+Use '--' to separate paths from revisions, like this:
+'git <command> [<revision>...] -- [<file>...]'
+EOF
+
+test_expect_success 'reset - with @{-1} and file named @{-1}' '
+ git init new --quiet &&
+ cd new &&
+ echo "Hello" >@{-1} &&
+ git add @{-1} &&
+ git commit -m "first_commit" &&
+ git checkout -b new_branch &&
+ touch @{-1} &&
+ git add @{-1} &&
+ test_must_fail git reset - 2>actual &&
+ test_cmp ../expect actual
+'
+
+cd ..
+rm -rf new
+
+cat >expect <<EOF
+fatal: ambiguous argument '-': both revision and filename
+Use ./- for file named -
+Use '--' to separate paths from revisions, like this:
+'git <command> [<revision>...] -- [<file>...]'
+EOF
+
+test_expect_success 'reset - with @{-1} and file named - ' '
+ git init new --quiet &&
+ cd new &&
+ echo "Hello" > - &&
+ git add - &&
+ git commit -m "first_commit" &&
+ git checkout -b new_branch &&
+ touch - &&
+ git add - &&
+ test_must_fail git reset - 2>actual &&
+ test_cmp ../expect actual
+'
+
+cd ..
+rm -rf new
+
+test_expect_success 'reset - with @{-1} and file named @{-1} and - ' '
+ git init new --quiet &&
+ cd new &&
+ echo "Hello" > - &&
+ git add - &&
+ git commit -m "first_commit" &&
+ git checkout -b new_branch
+ echo "Hello" >@{-1} &&
+ git add @{-1} &&
+ test_must_fail git reset - 2>actual &&
+ test_cmp ../expect actual
+'
+
+cd ..
+rm -rf new
+
+test_expect_success 'reset - with @{-1} and no file named - or @{-1} ' '
+ git init new --quiet &&
+ cd new &&
+ echo "Hello" >new_file &&
+ git add new_file &&
+ git commit -m "first_commit" &&
+ git checkout -b new_branch &&
+ echo "Hey" >new_file &&
+ git add new_file &&
+ git reset - &&
+ git status -uno >file1 &&
+ git add new_file &&
+ git reset @{-1} &&
+ git status -uno >file2 &&
+ test_cmp file1 file2
+'
+
test_done
--
2.1.0
next prev parent reply other threads:[~2015-03-09 20:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 20:46 [PATCH 1/2] Adding - shorthand for @{-1} in RESET command Sundararajan R
2015-03-09 20:46 ` Sundararajan R [this message]
2015-03-10 5:48 ` [PATCH 2/2] Added tests for git reset - Torsten Bögershausen
2015-03-10 7:49 ` Eric Sunshine
2015-03-10 17:36 ` Junio C Hamano
2015-03-10 6:54 ` [PATCH 1/2] Adding - shorthand for @{-1} in RESET command Eric Sunshine
2015-03-10 17:43 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425934010-8780-2-git-send-email-dyoucme@gmail.com \
--to=dyoucme@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).