]> git.ipfire.org Git - thirdparty/git.git/commit
sequencer: try to commit without forking 'git commit'
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Fri, 24 Nov 2017 11:07:57 +0000 (11:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Nov 2017 13:44:18 +0000 (22:44 +0900)
commit356ee4659bb551cd9464b317d691827276752c2d
tree910272c937ce23fbe40a4f0823a51b3d159769e4
parentb36c5908135889bd9c48a8d44d4e07f59bf799ef
sequencer: try to commit without forking 'git commit'

If the commit message does not need to be edited then create the
commit without forking 'git commit'. Taking the best time of ten runs
with a warm cache this reduces the time taken to cherry-pick 10
commits by 27% (from 282ms to 204ms), and the time taken by 'git
rebase --continue' to pick 10 commits by 45% (from 386ms to 212ms) on
my computer running linux. Some of greater saving for rebase is
because it no longer wastes time creating the commit summary just to
throw it away.

The code to create the commit is based on builtin/commit.c. It is
simplified as it doesn't have to deal with merges and modified so that
it does not die but returns an error to make sure the sequencer exits
cleanly, as it would when forking 'git commit'

Even when not forking 'git commit' the commit message is written to a
file and CHERRY_PICK_HEAD is created unnecessarily. This could be
eliminated in future. I hacked up a version that does not write these
files and just passed an strbuf (with the wrong message for fixup and
squash commands) to do_commit() but I couldn't measure any significant
time difference when running cherry-pick or rebase. I think
eliminating the writes properly for rebase would require a bit of
effort as the code would need to be restructured.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c