threads / discuss / 22255

Get rid of refreshing cache after "git commit"?

Subject: Get rid of refreshing cache after "git commit"?

## tl;dr

2 messages between Jan 17, 2010 and Jan 17, 2010.

replies: 1people: 2as markdown or json

Nguyen Thai Ngoc Duy· Jan 17, 2010, 08:16 UTC · lore
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· Jan 17, 2010, 08:27 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: Get rid of refreshing cache after "git commit"?

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.

← back to recent threads