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

Re: [RFC PATCH v1 0/1] ls-remote: inconsistency from the order of args and opts

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 14, 2022, 06:27 UTC
Message-ID
<xmqqy23ide7z.fsf@gitster.g>
In-Reply-To
<xmqqfspqeun5.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Teng Long <dyroneteng@gmail.com> writes:
>
>> +test_must_fail 'Exchange the order of "--heads" and <remote>' '
>> +    git --version &&
>> +    git init "test.git" &&
>> +    test_commit -C "test.git" one &&
>> +    git -C "test.git" ls-remote --heads ./. > result.1 &&
>> +    git -C "test.git" ls-remote ./. --heads > result.2 &&
>
> I would say that this is working exactly as designed.  As with the
> unix tradition, after the command name, first come options
> (e.g. "--heads", "-v", etc. that begin with a dash or two dashes),
> then arguments like "origin", "master", "." that are not dashed
> options/flags.

I failed to say one important thing (I was again fooled by the "it is too obvious to say" that led "gitcli" not to mention this, too).

"dashed-options first and then args" rule means that generally we scan the command line from left to right one by one, and as long as the one we are looking at begins with "-", we try to interpret it as a dashed option, possibly eat the next one as an argument given to the option (e.g. "--abbrev 7"), and keep repeating, until the one we are at right now does not begin with "-". And then everything after that, we do not interpret it as an option. That is how "--heads" on the second example above, since we have seen . and took it as an argument (not a dashed option) is considered as a pattern.

Show 5 quoted lines
> ...
> Apparently, it is not a common knowledge at least for you (and
> probably others).  Perhaps we should add a paragraph to the cli help
> and explicitly mention "options first and then args", before we go
> on to say "among args, revs first and then pathspecs".
Previous: Junio C HamanoNext: Teng Long
Message 4 of 18 in “ls-remote: inconsistency from the order of args and opts”
  1. 0/1 ls-remote: inconsistency from the order of args and optsTeng Long, Jan 14, 2022
  2. 1/1 ls-remote: Make the output independent of the order of opts and <remote>Teng Long, Jan 14, 2022
  3. Junio C HamanoJan 14, 2022
  4. Junio C HamanoJan 14, 2022
  5. Teng LongJan 14, 2022
  6. Junio C HamanoJan 15, 2022
  7. Ævar Arnfjörð BjarmasonJan 14, 2022
  8. Junio C HamanoJan 14, 2022
  9. Ævar Arnfjörð BjarmasonJan 14, 2022
  10. Junio C HamanoJan 14, 2022
  11. Ævar Arnfjörð BjarmasonJan 15, 2022
  12. Junio C HamanoJan 15, 2022
  13. brian m. carlsonJan 14, 2022
  14. Ævar Arnfjörð BjarmasonJan 15, 2022
  15. Junio C HamanoJan 15, 2022
  16. Ævar Arnfjörð BjarmasonJan 15, 2022
  17. Junio C HamanoJan 15, 2022
  18. Teng LongJan 17, 2022

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.