diff options
author | Martin von Zweigbergk <martinvonz@gmail.com> | 2013-01-14 21:47:41 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-15 09:38:07 -0800 |
commit | b7099a06e8ffe61a06d3e32632e832e59f23bd4d (patch) | |
tree | 2b9e45c3cb0877af2a167b785279429108ba7416 /generate-cmdlist.sh | |
parent | reset.c: share call to die_if_unmerged_cache() (diff) | |
download | tgif-b7099a06e8ffe61a06d3e32632e832e59f23bd4d.tar.xz |
reset --keep: only write index file once
"git reset --keep" calls reset_index_file() twice, first doing a
two-way merge to the target revision, updating the index and worktree,
and then resetting the index. After each call, we write the index
file.
In the unlikely event that the second call to reset_index_file()
fails, the index will have been merged to the target revision, but
HEAD will not be updated, leaving the user with a dirty index.
By moving the locking, writing and committing out of
reset_index_file() and into the caller, we can avoid writing the index
twice, thereby making the sure we don't end up in the half-way reset
state. As a bonus, we speed up "git reset --keep" a little on the
linux-2.6 repo (best of five, warm cache):
Before After
real 0m0.315s 0m0.296s
user 0m0.290s 0m0.280s
sys 0m0.020s 0m0.010s
Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'generate-cmdlist.sh')
0 files changed, 0 insertions, 0 deletions