summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-08-23 14:13:11 -0700
committerJunio C Hamano <gitster@pobox.com>2017-08-23 14:13:11 -0700
commitc3e034f0f0753126494285d1098e1084ec05d2c4 (patch)
tree9dc1354338380723e493c472242e8ad6ac25911f /builtin/commit.c
parent3830759c1c91726a97adb2e97e2de08aec60f25a (diff)
parent680ee550d72150f27cdb3235462eee355a20038b (diff)
downloadgit-c3e034f0f0753126494285d1098e1084ec05d2c4.tar.gz
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
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index e7a2cb6285..b79bcfd5b9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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;