aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/add.c
diff options
context:
space:
mode:
authorNeeraj Singh <neerajsi@microsoft.com>2022-04-04 22:20:11 -0700
committerJunio C Hamano <gitster@pobox.com>2022-04-06 13:13:26 -0700
commitb4a0c6dc9733751788161ce3c181709be89045f9 (patch)
treee452d244465a75073807a0042246e01108f4fa81 /builtin/add.c
parent4d33e2ba6b9db6a28085b2ef7e46d30a981875ab (diff)
downloadgit-b4a0c6dc9733751788161ce3c181709be89045f9.tar.gz
builtin/add: add ODB transaction around add_files_to_cache
The add_files_to_cache function is invoked internally by builtin/commit.c and builtin/checkout.c for their flags that stage modified files before doing the larger operation. These commands can benefit from batched fsyncing. Signed-off-by: Neeraj Singh <neerajsi@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/add.c')
-rw-r--r--builtin/add.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 9bf37ceae8..e39770e474 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -141,7 +141,16 @@ int add_files_to_cache(const char *prefix,
rev.diffopt.format_callback_data = &data;
rev.diffopt.flags.override_submodule_config = 1;
rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
+
+ /*
+ * Use an ODB transaction to optimize adding multiple objects.
+ * This function is invoked from commands other than 'add', which
+ * may not have their own transaction active.
+ */
+ begin_odb_transaction();
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
+ end_odb_transaction();
+
clear_pathspec(&rev.prune_data);
return !!data.add_errors;
}