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

Re: [v3 PATCH 1/2] reset: add '-' shorthand for '@{-1}'

From
KCKenny Lee Sin Cheong <kenny.lee28@gmail.com>
Date
Mar 18, 2015, 19:17 UTC
Message-ID
<87egomm7y7.fsf@gmail.com>
In-Reply-To
<87iodym82z.fsf@gmail.com>
On Wed, Mar 18 2015 at 04:29:44 AM, Sundararajan R <dyoucme@gmail.com> wrote:
Show 12 quoted lines
> Teaching reset the - shorthand involves checking if any file named '-' exists.
> check_filename() is used to perform this check.
>
> When the @{-1} branch does not exist then it can be safely assumed that the
> user is referring to the file '-',if any. If this file exists then it is reset or else
> a bad flag error is shown.
>
> But if the @{-1} branch exists then it becomes ambiguous without the explicit 
> '--' disambiguation as to whether the user wants to reset the file '-' or if 
> he wants to reset the working tree to the previous branch. Hence the program dies
> with a message about the ambiguous argument.
>

I might be wrong but I think any pathspec that begins with "-" needs to be preceded by either a "--" marker or be specified as "./-filename", else verify_filename just die. Therefore you would need to do something like git reset ./- if you wanted to reset a file. I don't know if given simply "-" as filename is desired since options starts with "-".

I don't know if you saw but Junio posted a while ago about about allowing "-" as a stand-in everywhere a revision was allowed. He updated a version on pu : "d40f108d"

Show 16 quoted lines
> On Tue, Mar 17 2015 at 02:49:48 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>> 	if (try to see if it is a revision or regvision range) {
>>         	/* if failed ... */
>> 		if (starts with '-') {
>>                 	do the option thing;
>>                         continue;
>> 		}
>> 		/* args must be pathspecs from here on */
>>                 check the  '--' disambiguation;
>>                 add pathspec to prune-data;
>> 	} else {
>> 		got_rev_arg = 1;
>> 	}
>>
See $gmane/265672
Previous: Sundararajan R
Message 2 of 2 in “reset: add '-' shorthand for '@{-1}'”
  1. 1/2 reset: add '-' shorthand for '@{-1}'Sundararajan R, Mar 18, 2015
  2. Kenny Lee Sin CheongMar 18, 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.