Nguyen Thai Ngoc Duy [off-list ref] writes:
Nowadays almost (all?) porcelain commands silently refresh index
before doing anything relating to worktree, I wonder if this tradition
is still necessary.
Inside "commit", various checks to see if/how worktree files are changed
are attempted by the libified diff-files/diff-index and they must be used
after you refresh the cache entries.
"git commit" (without paths) does not necessarily have to when you can
prove that the user never looks at .git/COMMIT_EDITMSG (e.g. "-F file" is
given without "-e"), but otherwise you need to refresh the index to show
the correct status in the message buffer.
"git commit paths..." must refresh the named paths (not necessarily the
whole index), but again you would need the whole index to show the status
correctly.