git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kenny Lee Sin Cheong <kenny.lee28@gmail.com>
To: Kenny Lee Sin Cheong <kenny.lee28@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [v3 PATCH 1/2] reset: add '-' shorthand for '@{-1}'
Date: Wed, 18 Mar 2015 15:17:20 -0400	[thread overview]
Message-ID: <87egomm7y7.fsf@gmail.com> (raw)
In-Reply-To: <87iodym82z.fsf@gmail.com> (Kenny Lee Sin Cheong's message of "Wed, 18 Mar 2015 15:14:28 -0400")

On Wed, Mar 18 2015 at 04:29:44 AM, Sundararajan R <dyoucme@gmail.com> wrote:
> 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"

> 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

      parent reply	other threads:[~2015-03-18 19:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18  8:29 [v3 PATCH 1/2] reset: add '-' shorthand for '@{-1}' Sundararajan R
     [not found] ` <87iodym82z.fsf@gmail.com>
2015-03-18 19:17   ` Kenny Lee Sin Cheong [this message]

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=87egomm7y7.fsf@gmail.com \
    --to=kenny.lee28@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).