# Get rid of refreshing cache after "git commit"?

2 messages from 2010-01-17 to 2010-01-17. Participants: Nguyen Thai Ngoc Duy, Junio C Hamano.
Thread: https://gitlist.dev/t/22255

## Nguyen Thai Ngoc Duy, 2010-01-17 08:16

Subject: Get rid of refreshing cache after "git commit"?
Message-ID: <fcaeb9bf1001170016q5e285201r36f6030579cfa605@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf1001170016q5e285201r36f6030579cfa605%40mail.gmail.com

```
Hi,

The current "git commit" refreshes cache and writes out after a
commit. I dug back in history to see how it was introduced. It looks
like from the very first days of "git commit", which was
git-commit-script at that time, git-update-cache was called on
specified paths, until commit 22cff6a (git-commit: pass explicit path
to git-diff-files. - 2005-08-16) started to do "git-update-cache -q
--refresh" without paths and the tradition keeps going until today.

Nowadays almost (all?) porcelain commands silently refresh index
before doing anything relating to worktree, I wonder if this tradition
is still necessary. On (again) gentoo-x86 repository, taking out the
refresh part could cut down about 1 sec on total 3 secs from "git
commit -m foo".
-- 
Duy

```

## Junio C Hamano, 2010-01-17 08:27

Subject: Re: Get rid of refreshing cache after "git commit"?
Message-ID: <7vljfx87bj.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vljfx87bj.fsf%40alter.siamese.dyndns.org
In-Reply-To: <fcaeb9bf1001170016q5e285201r36f6030579cfa605@mail.gmail.com>

```
Nguyen Thai Ngoc Duy <pclouds@gmail.com> 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.

```
