From: Junio C Hamano <gitster@pobox.com>
To: "Matěj Cepl" <mcepl@cepl.eu>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Documentation/git-update-index.txt: add an example of use
Date: Mon, 02 Dec 2024 12:01:25 +0900 [thread overview]
Message-ID: <xmqq1pyqkcu2.fsf@gitster.g> (raw)
In-Reply-To: <20241201222531.1478338-1-mcepl@cepl.eu> ("Matěj Cepl"'s message of "Sun, 1 Dec 2024 23:25:23 +0100")
Matěj Cepl <mcepl@cepl.eu> writes:
> I met this command in the wild and I spent a lot of time to
> understand what it is good for.
> ---
Missing sign-off.
> Documentation/git-update-index.txt | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
> index 7128aed540..da11cbc418 100644
> --- a/Documentation/git-update-index.txt
> +++ b/Documentation/git-update-index.txt
> @@ -399,6 +399,15 @@ M foo.c
> <8> you can tell about the change after the fact.
> <9> now it checks with lstat(2) and finds it has been changed.
>
> +To speed up other Git commands that rely on the index, such as git status
> +or git commit, user can refresh the index and avoid having to re-check
> +the status of every file in the working directory. This command
> +doesn't modify any committed data in your repository.
> ++
> +----------------
> +$ git update-index -q --refresh || true
> +----------------
> +
Two comments.
* The example before the new one is for a rather esoteric corner
case of running Git on an inefficient filesystem. Perhaps this
new one more commonly happens, in which case, it probably sits
better earlier in the list of examples.
* Because most (if not all) Porcelain commands like "git commit" or
"git status" automatically refreshes the index, it is of dubious
value to manually refresh, like your example does, before running
them. You pay the price either way, and the only difference may
be the time (and brain cycle) you spend to manually issue the
"update-index --refresh" command.
The benefit of refreshing the index manually beforehand mostly comes
when you are running two or more plumbing commands that do not
refresh the index by themselves. We used to implement an equivlent
of today's "git status" using "git diff-files" and "git diff-cache"
(yes, we literally ran these two commands in a row to show their
results in the output, one for "changes to be committed" and the
other for "changes left in the working tree"), and before running
these two, the scripted implementation of "git status" ran "git
update-index --refresh".
Thanks.
next prev parent reply other threads:[~2024-12-02 3:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-01 22:25 [PATCH] Documentation/git-update-index.txt: add an example of use Matěj Cepl
2024-12-02 3:01 ` Junio C Hamano [this message]
2024-12-02 6:56 ` Matěj Cepl
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=xmqq1pyqkcu2.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mcepl@cepl.eu \
/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