git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Benjamin Woodruff via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Benjamin Woodruff <github@benjam.info>
Subject: Re: [PATCH 0/2] describe and diff: implement --no-optional-locks
Date: Thu, 06 Mar 2025 08:11:09 -0800	[thread overview]
Message-ID: <xmqqo6yejg0y.fsf@gitster.g> (raw)
In-Reply-To: <pull.1872.git.1741240685.gitgitgadget@gmail.com> (Benjamin Woodruff via GitGitGadget's message of "Thu, 06 Mar 2025 05:58:03 +0000")

"Benjamin Woodruff via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> git describe and git diff may update the index in the background for similar
> performance reasons to git-status.

That is a wrong reasoning that is completely opposite, though.

The commands at the Porcelain level, like "status" and "diff",
refresh the index for the CORRECTNESS purposes.

The commands at the plumbing level, which are designed to be used in
your own scripts, like "diff-files" and "diff-index", do not refresh
the index for the performance purposes.  If your own script wants to
produce correct result, your script IS responsible for refreshing
the index after its last modification to working tree files before
it starts to use the plumbing commands to inspect which ones are
modified and which ones are not.  This is so that your script has
more control over when the index is refreshed.  It does not have to
pay cost to run refresh for each Git command it invokes, if it knows
that it does not make any modification between the two invocations;
it can instead refresh just once and then run these two plumbing
commands.

So, it would be absolute no-no to make the Porcelain commands like
"describe" and "diff" not to refresh the index before they work by
default.  As an optional behaviour, it might be acceptable if there
is no other reasonable solutions (like, using plumbing commands if
the callers are not you typing but your scripts calling them).


  parent reply	other threads:[~2025-03-06 16:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06  5:58 [PATCH 0/2] describe and diff: implement --no-optional-locks Benjamin Woodruff via GitGitGadget
2025-03-06  5:58 ` [PATCH 1/2] describe: " Benjamin Woodruff via GitGitGadget
2025-03-06  5:58 ` [PATCH 2/2] diff: " Benjamin Woodruff via GitGitGadget
2025-03-06 16:11 ` Junio C Hamano [this message]
2025-03-09  3:39   ` [PATCH 0/2] describe and " Jeff King
2025-03-10 12:25     ` Junio C Hamano
2025-03-10 16:08       ` Jeff King
2025-03-10 18:53         ` Junio C Hamano
2025-03-10 20:50           ` Benjamin Woodruff
2025-03-10 23:04             ` Junio C Hamano
2025-03-11  2:10             ` Jeff King

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=xmqqo6yejg0y.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=github@benjam.info \
    /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).