git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] Added tests for git reset -

From
Torsten Bögershausen <tboegi@web.de>
Date
Mar 10, 2015, 05:48 UTC
Message-ID
<54FE8599.7000403@web.de>
In-Reply-To
<1425934010-8780-2-git-send-email-dyoucme@gmail.com>
On 03/09/2015 09:46 PM, Sundararajan R wrote:
Show 66 quoted lines
> 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 &&
If the shell changes the directory, this should be done in a subshell
+	git init new --quiet &&
+	(
		cd new &&
                # All the stuff
             )
+'
+cd ..

And the the .. should be removed (Same problem further down)

Previous: Sundararajan RNext: Eric Sunshine
Message 3 of 7 in “Adding - shorthand for @{-1} in RESET command”
  1. 1/2 Adding - shorthand for @{-1} in RESET commandSundararajan R, Mar 9, 2015
  2. 2/2 Added tests for git reset -Sundararajan R, Mar 9, 2015
  3. Torsten BögershausenMar 10, 2015
  4. Eric SunshineMar 10, 2015
  5. Junio C HamanoMar 10, 2015
  6. Eric SunshineMar 10, 2015
  7. Junio C HamanoMar 10, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.