* [PATCH] Documentation/git-update-index.txt: add an example of use
@ 2024-12-01 22:25 Matěj Cepl
2024-12-02 3:01 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Matěj Cepl @ 2024-12-01 22:25 UTC (permalink / raw)
To: git; +Cc: Matěj Cepl
I met this command in the wild and I spent a lot of time to
understand what it is good for.
---
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
+----------------
+
SKIP-WORKTREE BIT
-----------------
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Documentation/git-update-index.txt: add an example of use
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
2024-12-02 6:56 ` Matěj Cepl
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2024-12-02 3:01 UTC (permalink / raw)
To: Matěj Cepl; +Cc: git
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Documentation/git-update-index.txt: add an example of use
2024-12-02 3:01 ` Junio C Hamano
@ 2024-12-02 6:56 ` Matěj Cepl
0 siblings, 0 replies; 3+ messages in thread
From: Matěj Cepl @ 2024-12-02 6:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
[-- Attachment #1.1.1: Type: text/plain, Size: 1162 bytes --]
On Mon Dec 2, 2024 at 4:01 AM CET, Junio C Hamano wrote:
> Missing sign-off.
Whoopsie! I am sorry, but given that I am probably withdrawing my
submission anyway, it is not relevant, I guess.
> 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".
I’ve got the idea from https://groups.google.com/g/git-mentoring/c/mJnuzbUqyAQ/m/02Pr9uhmAAAJ ,
so I thought it something one does.
Best,
Matěj
--
http://matej.ceplovi.cz/blog/, @mcepl@floss.social
GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8
All men's miseries derive from not being able to sit in a quiet
room alone.
-- Blaise Pascal
[-- Attachment #1.2: E09FEF25D96484AC.asc --]
[-- Type: application/pgp-keys, Size: 3102 bytes --]
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGiBD2g5T0RBACZdnG/9T4JS2mlxsHeFbex1KWweKPuYTpnbu8Fe7rNYMWZ/AKc
9Vm+RuoVErm4HGsb0pL5ZPnncA+m80W8EzQm2rs8PD2mHNsUhDOGnk+0fm+25WSU
6YLzd8lttxPia75A5OqBEAmJlyJUSmoWKjAK/q1Tj5HW3+/7XqWYYCJzAwCgjR2D
irw8QP8GCoUUXxeNpIOTqzMD/j66VTln+rxYT12U4jxLlsOs5Y0LVQfUbpDFEYy9
mkWX8iNTUZsx+m6uhylamm3EkN/dW0b2sQ4D3ocZekriLPDR/X0P1XPUdcy28a6o
WZoVAKN26X+PwxSq3JCiQEJgPJeKxiLiExh3lDitNyAS0WUD/xQOqryEFb9ksGxL
R9UCA/9WUQMwgQvEUhuVB7qSnREo3+ks34Kltp71uUjuMjLk3ykSptyn8oV+XZgx
rxPAD+WOJn51yFxbo+OPNdH6wG2ZaXFj47rX6GQ9W6wI7K0QhdyQTps8KNlsJuDQ
pz7XME98ob8SszsvkPPm/gX0oWdOIqHipHnMlL684jRHCWHVjrQdTWF0ZWogQ2Vw
bCA8bWF0ZWpAY2VwbG92aS5jej6IYAQTEQIAIAIeAQIXgAIZAQUCRSoWAgYLCQgH
AwIEFQIIAwQWAgMBAAoJEOCf7yXZZISsr5sAoIAqsNcs1Sl9jrmqv7vJzL4QG68V
AJ9+30NmBClQwpmqnA26nCa4+WS5abQbTWF0ZWogQ2VwbCA8Y2VwbC5tQG5ldS5l
ZHU+iGAEExECACACGwMCHgECF4AFAkUqFgkGCwkIBwMCBBUCCAMEFgIDAQAKCRDg
n+8l2WSErAULA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C6kR0
wwCdEnRlCGlvnO78R0FgKXlt3RyzGuE=
=sxoW
-----END PGP PUBLIC KEY BLOCK-----
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 216 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-02 7:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-12-02 6:56 ` Matěj Cepl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox