File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1356,13 +1356,8 @@ int cmd_grep(int argc,
13561356 if (recurse_submodules )
13571357 repo_read_gitmodules (the_repository , 1 );
13581358
1359- if (startup_info -> have_repository ) {
1360- struct odb_source * source ;
1361-
1362- odb_prepare_alternates (the_repository -> objects );
1363- for (source = the_repository -> objects -> sources ; source ; source = source -> next )
1364- odb_source_prepare (source , 0 );
1365- }
1359+ if (startup_info -> have_repository )
1360+ odb_prepare (the_repository -> objects , 0 );
13661361
13671362 start_threads (& opt );
13681363 } else {
Original file line number Diff line number Diff line change @@ -1070,7 +1070,7 @@ void odb_free(struct object_database *o)
10701070 free (o );
10711071}
10721072
1073- void odb_reprepare (struct object_database * o )
1073+ void odb_prepare (struct object_database * o , enum odb_prepare_flags flags )
10741074{
10751075 struct odb_source * source ;
10761076
@@ -1082,13 +1082,19 @@ void odb_reprepare(struct object_database *o)
10821082 * the linked list, so existing odbs will continue to exist for
10831083 * the lifetime of the process.
10841084 */
1085- o -> loaded_alternates = 0 ;
1086- odb_prepare_alternates (o );
1085+ if (flags & ODB_PREPARE_FLUSH_CACHES ) {
1086+ o -> loaded_alternates = 0 ;
1087+ o -> object_count_valid = 0 ;
1088+ }
10871089
1090+ odb_prepare_alternates (o );
10881091 for (source = o -> sources ; source ; source = source -> next )
1089- odb_source_prepare (source , ODB_PREPARE_FLUSH_CACHES );
1090-
1091- o -> object_count_valid = 0 ;
1092+ odb_source_prepare (source , flags );
10921093
10931094 obj_read_unlock ();
10941095}
1096+
1097+ void odb_reprepare (struct object_database * o )
1098+ {
1099+ odb_prepare (o , ODB_PREPARE_FLUSH_CACHES );
1100+ }
Original file line number Diff line number Diff line change @@ -133,9 +133,13 @@ enum odb_prepare_flags {
133133};
134134
135135/*
136- * Clear caches, reload alternates and then reload object sources so that new
137- * objects may become accessible.
136+ * Prepare the object database for use. Calling this function is generally not
137+ * needed, but can be useful in case the caller wants to pre-open individual
138+ * sources.
138139 */
140+ void odb_prepare (struct object_database * o , enum odb_prepare_flags flags );
141+
142+ /* Equivalent to `odb_prepare(o, ODB_PREPARE_FLUSH_CACHES)`. */
139143void odb_reprepare (struct object_database * o );
140144
141145/*
You can’t perform that action at this time.
0 commit comments