Re: git commit results in many lstat()s

2 messages, 2 authors, 2017-02-01 · open the first message on its own page

Re: git commit results in many lstat()s

From: Junio C Hamano <hidden>
Date: 2017-02-01 22:11:25

"Gumbel, Matthew K" [off-list ref] writes:
I do not understand why git commit must call lstat() on every file
in the repository, even when I specify the name of the file I want
to commit on the command line.
Assuming the "COPYING" and "README.md" files are already tracked:

    $ >COPYING
    $ >README.md
    $ git commit COPYING

would open an editor, in which you would see list of files under
"Changes to be committed", "Changes not staged for commit", etc.
Among the second class you would see README.md listed.

To figure out what paths are "changed", without having to open all
files and compare their contents with what is recorded in the commit
you are building on top of, we do lstat(2) to see if the timestamp
(and other information in the inode) of the files are the same since
you checked them out of HEAD.

    $ git commit --no-status COPYING

would reduce the number of lstat(2) somewhat, because the codepath
is told that it does not have to make the list to be shown in the
editor.  So would

    $ git commit -m "empty COPYING" COPYING

These two only halve the number of lstat(2), by taking advantage of
the fact that the list of "modified files" does not have to be
built.  There probably are other things that can be optimized.

RE: git commit results in many lstat()s

From: Gumbel, Matthew K <hidden>
Date: 2017-02-01 22:26:12

"Junio C Hamano" [off-list ref] writes:
There probably are other things that can be optimized.
Yes, I think that when the user passes --only flag to git-commit, then git does not
need to call refresh_cache() in prepare_index() in builtin/commit.c.

I may experiment with that. Do you see any downside or negative side-effects?

Matt
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help