From: Junio C Hamano <gitster@pobox.com>
To: Danny Lin <danny0838@gmail.com>
Cc: git develop <git@vger.kernel.org>
Subject: Re: Arguments for git update-index --refresh
Date: Fri, 15 Apr 2022 09:48:18 -0700 [thread overview]
Message-ID: <xmqqv8vae1il.fsf@gitster.g> (raw)
In-Reply-To: <CAMbsUu7fqECH1b7-POot0mD4kwmT0pzAMJrXznSPgv9wfv1OwA@mail.gmail.com> (Danny Lin's message of "Fri, 15 Apr 2022 18:21:54 +0800")
Danny Lin <danny0838@gmail.com> writes:
> According to the manual of git-update-index
> (https://git-scm.com/docs/git-update-index), --ignore-submodules must
> be passed before --refresh to take effect. However, a real test shows
> that -q and --ignore-missing also don't take effect when passed after
> --refresh. I wonder if --refresh must be passed after all other
> arguments, and the documentation may need a revision. I also wonder
> what is the reason that --refresh must be passed after, and can't we
> make it more flexible?
For backward compatibility reasons, it is unlikely we can change it,
so it is a moot point to ask why. But anyway.
The "update-index" plumbing subcommand predates the philosophy
behind our modern option parsing infrastructure; it was designed
to process each option as it parse it from left to right. We do not
advertise this in the documentation or help text, but we do even a
strange things like this:
git update-index fileA --add fileB
where "we allow a new path to be added to the index" option ONLY
applies to fileB (in other words, if fileA is not yet added to the
index, the command would barf, but fileB is allowed to be a "new"
file). --remove is also the same way.
With the understanding of "each option is processed as it is parsed
from left to right", you should be able to "explain" [*1*] the
behaviour you observed, better than relying on the description in
the document, e.g. "only respected when passed before" [*2*], which
is not technically wrong but does not tell you the real reason.
[Footnote]
*1* You should be able to explain, but you do not have to agree with
it. Within the context of the modern Git command set, I do not
agree with it, but unfortunately it is too late to change it, as
scripts people wrote over time do agree with and depend on the
behaviour X-<.
*2* Update to remove these haphazard mention of the ordering and to
place more stress on the "processed as it is read" nature of the
options in the documentation may help users.
prev parent reply other threads:[~2022-04-15 16:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 10:21 Arguments for git update-index --refresh Danny Lin
2022-04-15 16:48 ` Junio C Hamano [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=xmqqv8vae1il.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=danny0838@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).