{"thread":{"id":"62581","subject":"[PATCH] Documentation/git-update-index.txt: add an example of use","startedAt":"2024-12-01T22:25:44Z","lastAt":"2024-12-02T07:01:35Z","messageCount":3,"participants":["Matěj Cepl","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"508398","messageId":"20241201222531.1478338-1-mcepl@cepl.eu","threadId":"62581","inReplyTo":null,"subject":"[PATCH] Documentation/git-update-index.txt: add an example of use","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-12-01T22:25:23Z","receivedAt":"2024-12-01T22:25:44Z","isPatch":true,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"I met this command in the wild and I spent a lot of time to\nunderstand what it is good for.\n---\n Documentation/git-update-index.txt | 9 +++++++++\n 1 file changed, 9 insertions(+)\n\ndiff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt\nindex 7128aed540..da11cbc418 100644\n--- a/Documentation/git-update-index.txt\n+++ b/Documentation/git-update-index.txt\n@@ -399,6 +399,15 @@ M foo.c\n <8> you can tell about the change after the fact.\n <9> now it checks with lstat(2) and finds it has been changed.\n \n+To speed up other Git commands that rely on the index, such as git status\n+or git commit, user can refresh the index and avoid having to re-check\n+the status of every file in the working directory. This command\n+doesn't modify any committed data in your repository.\n++\n+----------------\n+$ git update-index -q --refresh || true\n+----------------\n+\n \n SKIP-WORKTREE BIT\n -----------------\n-- \n2.47.1\n\n"},{"id":"508410","messageId":"xmqq1pyqkcu2.fsf@gitster.g","threadId":"62581","inReplyTo":"20241201222531.1478338-1-mcepl@cepl.eu","subject":"Re: [PATCH] Documentation/git-update-index.txt: add an example of use","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-12-02T03:01:25Z","receivedAt":"2024-12-02T03:01:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matěj Cepl <mcepl@cepl.eu> writes:\n\n> I met this command in the wild and I spent a lot of time to\n> understand what it is good for.\n> ---\n\nMissing sign-off.\n\n>  Documentation/git-update-index.txt | 9 +++++++++\n>  1 file changed, 9 insertions(+)\n>\n> diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt\n> index 7128aed540..da11cbc418 100644\n> --- a/Documentation/git-update-index.txt\n> +++ b/Documentation/git-update-index.txt\n> @@ -399,6 +399,15 @@ M foo.c\n>  <8> you can tell about the change after the fact.\n>  <9> now it checks with lstat(2) and finds it has been changed.\n>  \n> +To speed up other Git commands that rely on the index, such as git status\n> +or git commit, user can refresh the index and avoid having to re-check\n> +the status of every file in the working directory. This command\n> +doesn't modify any committed data in your repository.\n> ++\n> +----------------\n> +$ git update-index -q --refresh || true\n> +----------------\n> +\n\nTwo comments.\n\n * The example before the new one is for a rather esoteric corner\n   case of running Git on an inefficient filesystem.  Perhaps this\n   new one more commonly happens, in which case, it probably sits\n   better earlier in the list of examples.\n\n * Because most (if not all) Porcelain commands like \"git commit\" or\n   \"git status\" automatically refreshes the index, it is of dubious\n   value to manually refresh, like your example does, before running\n   them.  You pay the price either way, and the only difference may\n   be the time (and brain cycle) you spend to manually issue the\n   \"update-index --refresh\" command.\n\nThe benefit of refreshing the index manually beforehand mostly comes\nwhen you are running two or more plumbing commands that do not\nrefresh the index by themselves.  We used to implement an equivlent\nof today's \"git status\" using \"git diff-files\" and \"git diff-cache\"\n(yes, we literally ran these two commands in a row to show their\nresults in the output, one for \"changes to be committed\" and the\nother for \"changes left in the working tree\"), and before running\nthese two, the scripted implementation of \"git status\" ran \"git\nupdate-index --refresh\".\n\nThanks.\n"},{"id":"508414","messageId":"D610OBLUGP4J.3OQTEHZ86D8WH@cepl.eu","threadId":"62581","inReplyTo":"xmqq1pyqkcu2.fsf@gitster.g","subject":"Re: [PATCH] Documentation/git-update-index.txt: add an example of use","fromName":"Matěj Cepl","fromEmail":"mcepl@cepl.eu","sentAt":"2024-12-02T06:56:06Z","receivedAt":"2024-12-02T07:01:35Z","isPatch":true,"sender":{"key":"mcepl@cepl.eu","avatar":"https://avatars.githubusercontent.com/u/198999?v=4"},"body":"On Mon Dec 2, 2024 at 4:01 AM CET, Junio C Hamano wrote:\n> Missing sign-off.\n\nWhoopsie! I am sorry, but given that I am probably withdrawing my\nsubmission anyway, it is not relevant, I guess.\n\n> The benefit of refreshing the index manually beforehand mostly comes\n> when you are running two or more plumbing commands that do not\n> refresh the index by themselves.  We used to implement an equivlent\n> of today's \"git status\" using \"git diff-files\" and \"git diff-cache\"\n> (yes, we literally ran these two commands in a row to show their\n> results in the output, one for \"changes to be committed\" and the\n> other for \"changes left in the working tree\"), and before running\n> these two, the scripted implementation of \"git status\" ran \"git\n> update-index --refresh\".\n\nI’ve got the idea from https://groups.google.com/g/git-mentoring/c/mJnuzbUqyAQ/m/02Pr9uhmAAAJ ,\nso I thought it something one does.\n\nBest,\n\nMatěj\n\n-- \nhttp://matej.ceplovi.cz/blog/, @mcepl@floss.social\nGPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8\n \nAll men's miseries derive from not being able to sit in a quiet\nroom alone.\n  -- Blaise Pascal\n\n"}]}