From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Teng Long <dyroneteng@gmail.com>,
git@vger.kernel.org, tenglong.tl@alibaba-inc.com
Subject: Re: [RFC PATCH v1 0/1] ls-remote: inconsistency from the order of args and opts
Date: Fri, 14 Jan 2022 21:57:33 +0100 [thread overview]
Message-ID: <220114.86y23iqbbk.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <xmqqbl0eaw2e.fsf@gitster.g>
nOn Fri, Jan 14 2022, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> We have multiple commands that are in GNU-fashion loose about whether
>> you provide options first before no-option args, or after. E.g. we
>> accept both of:
>>
>> git push --dry-run <remote> <ref>
>>
>> And:
>>
>> git push <remote> <ref> --dry-run
>
> Yes, but I consider that a bug that we cannot fix due to backward
> compatibility issues.
>
> That is why my preference is to encourage users to stick to the
> POSIX way in gltcli, just like we recommend "stuck" form of options
> its parameter.
>
>> But when GNU came around its option parser was generally happy to accept
>> options and args in either order. E.g. these both work with GNU
>> coreutils, but the latter will fail on FreeBSD and various other
>> capital-U UNIX-es:
>>
>> touch foo; rm -v foo
>> touch foo; rm foo -v
This is only an approximate list, but:
$ git grep -C3 'parse_options' -- 'builtin/*.c'|grep -c PARSE_OPT_STOP_AT_NON_OPTION
16
$ git grep -C3 'parse_options' -- 'builtin/*.c'|grep -c -F ', 0);'
101
The GNU-like behavior is far more common in our codebase, and I think
it's less surprising if commands work the same way for consistency.
I manually looked through the PARSE_OPT_STOP_AT_NON_OPTION cases, and I
think this is the only one that's using it for no good reason. The
others (e.g. "git config") would become ambiguous or error out as a
result.
> Yes, among the harm GNU has done on mankind, this is one of the
> biggest ones. We shouldn't waste our engineering time to support
> more of them in our tools.
>
> As long as users stick to the recommended "dashed options first and
> then args, among which revs come first and then pathspecs", they
> will be fine.
I find it quite useful. E.g. if you typo a command or forget/want to remove an option:
git push origin HEAD --dry-run
You can just (under readline) do C-p M-DEL, instead of the equivalent
navigating back a few words, or having to use more advanced readline
features like ^--dry-run^^ or whatever.
Anecdotally, I've been surprised by the amount of regular terminal users
whose readline skills pretty much and at using the arrow keys to make
command corrections. I think this GNU UX decision has probably saved
several accumulated man-lifetimes by now :)
next prev parent reply other threads:[~2022-01-14 21:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 4:24 [RFC PATCH v1 0/1] ls-remote: inconsistency from the order of args and opts Teng Long
2022-01-14 4:24 ` [RFC PATCH v1 1/1] ls-remote: Make the output independent of the order of opts and <remote> Teng Long
2022-01-14 5:47 ` [RFC PATCH v1 0/1] ls-remote: inconsistency from the order of args and opts Junio C Hamano
2022-01-14 6:27 ` Junio C Hamano
2022-01-14 6:42 ` Teng Long
2022-01-15 0:25 ` Junio C Hamano
2022-01-14 19:57 ` Ævar Arnfjörð Bjarmason
2022-01-14 20:42 ` Junio C Hamano
2022-01-14 20:57 ` Ævar Arnfjörð Bjarmason [this message]
2022-01-14 21:52 ` Junio C Hamano
2022-01-15 0:34 ` Ævar Arnfjörð Bjarmason
2022-01-15 1:01 ` Junio C Hamano
2022-01-14 21:12 ` brian m. carlson
2022-01-15 0:13 ` Ævar Arnfjörð Bjarmason
2022-01-15 0:50 ` Junio C Hamano
2022-01-15 1:02 ` Ævar Arnfjörð Bjarmason
2022-01-15 1:19 ` Junio C Hamano
2022-01-17 6:27 ` Teng Long
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=220114.86y23iqbbk.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=dyroneteng@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tenglong.tl@alibaba-inc.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).