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

Re: [PATCH 1/2] Adding - shorthand for @{-1} in RESET command

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 10, 2015, 17:43 UTC
Message-ID
<xmqqbnk021eq.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAPig+cRAB-LQctj6UOKUXps-MEh2C_EbSp_3=wfgxtWx6xCbhw@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 14 quoted lines
>> @@ -226,7 +233,14 @@ static void parse_args(struct pathspec *pathspec,
>>                         rev = *argv++;
>>                 } else {
>>                         /* Otherwise we treat this as a filename */
>> -                       verify_filename(prefix, argv[0], 1);
>> +                       if(file_named_minus) {
>> +                               die(_("ambiguous argument '-': both revision and filename\n"
>> +                                       "Use ./- for file named -\n"
>> +                                       "Use '--' to separate paths from revisions, like this:\n"
>> +                                       "'git <command> [<revision>...] -- [<file>...]'"));
>
> This seems odd. If arguments following '--' are unconditionally
> treated as paths, why is it be necessary to tell the user to spell out
> file '-' as './-'? Shouldn't "git reset -- -" be sufficient?
I find that the presense of the if statement itself even odder.
 - verify_filename() and verify_non_filename() are designed to check
   that the string "-" given by the end-user is or is not a filename
   on the filesystem.  Why isn't this caller letting the callee do
   the job it was designed to do and doing that itself instead?
 - we know "-" aka "@{-1}" does not resolve to a committish at this
   point, so it must be a filename.  If "-" exists, then why should
   the user even need to differenciate it as ./- (or with "-- -")?
   After all, if there is no branch whose name is 'foo' and a file
   'foo' exists on the filesystem, the user can say "git reset foo"
   without disambiguation to reset that path, no?
Previous: Eric Sunshine
Message 7 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.