Skip to content

Commit b4a0c6d

Browse files
neerajsi-msftgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d33e2b commit b4a0c6d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

builtin/add.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,16 @@ int add_files_to_cache(const char *prefix,
141141
rev.diffopt.format_callback_data = &data;
142142
rev.diffopt.flags.override_submodule_config = 1;
143143
rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
144+
145+
/*
146+
* Use an ODB transaction to optimize adding multiple objects.
147+
* This function is invoked from commands other than 'add', which
148+
* may not have their own transaction active.
149+
*/
150+
begin_odb_transaction();
144151
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
152+
end_odb_transaction();
153+
145154
clear_pathspec(&rev.prune_data);
146155
return !!data.add_errors;
147156
}

0 commit comments

Comments
 (0)