Merge branch 'kw/commit-keep-index-when-pre-commit-is-not-run'
"git commit" used to discard the index and re-read from the filesystem just in case the pre-commit hook has updated it in the middle; this has been optimized out when we know we do not run the pre-commit hook. * kw/commit-keep-index-when-pre-commit-is-not-run: commit: skip discarding the index if there is no pre-commit hook
This commit is contained in:
commit
c3e034f0f0
@ -940,13 +940,16 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-read the index as pre-commit hook could have updated it,
|
||||
* and write it out as a tree. We must do this before we invoke
|
||||
* the editor and after we invoke run_status above.
|
||||
*/
|
||||
discard_cache();
|
||||
if (!no_verify && find_hook("pre-commit")) {
|
||||
/*
|
||||
* Re-read the index as pre-commit hook could have updated it,
|
||||
* and write it out as a tree. We must do this before we invoke
|
||||
* the editor and after we invoke run_status above.
|
||||
*/
|
||||
discard_cache();
|
||||
}
|
||||
read_cache_from(index_file);
|
||||
|
||||
if (update_main_cache_tree(0)) {
|
||||
error(_("Error building trees"));
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user