@@ -15,7 +15,7 @@ static int find_pack_entry(struct odb_source_packed *store,
1515{
1616 struct packfile_list_entry * l ;
1717
18- odb_source_packed_prepare ( store );
18+ odb_source_prepare ( & store -> base , 0 );
1919 if (store -> midx && fill_midx_entry (store -> midx , oid , e ))
2020 return 1 ;
2121
@@ -47,7 +47,7 @@ static int odb_source_packed_read_object_info(struct odb_source *source,
4747 * been added since the last time we have prepared the packfile store.
4848 */
4949 if (flags & OBJECT_INFO_SECOND_READ )
50- odb_source_reprepare (source );
50+ odb_source_prepare (source , ODB_PREPARE_FLUSH_CACHES );
5151
5252 if (!find_pack_entry (packed , oid , & e ))
5353 return 1 ;
@@ -692,27 +692,25 @@ static int sort_pack(const struct packfile_list_entry *a,
692692 return -1 ;
693693}
694694
695- void odb_source_packed_prepare (struct odb_source_packed * source )
695+ static void odb_source_packed_prepare (struct odb_source * source ,
696+ enum odb_prepare_flags flags )
696697{
697- if (source -> initialized )
698+ struct odb_source_packed * packed = odb_source_packed_downcast (source );
699+
700+ if (flags & ODB_PREPARE_FLUSH_CACHES )
701+ packed -> initialized = false;
702+ if (packed -> initialized )
698703 return ;
699704
700- prepare_multi_pack_index_one (source );
701- prepare_packed_git_one (source );
705+ prepare_multi_pack_index_one (packed );
706+ prepare_packed_git_one (packed );
702707
703- sort_packs (& source -> packs .head , sort_pack );
704- for (struct packfile_list_entry * e = source -> packs .head ; e ; e = e -> next )
708+ sort_packs (& packed -> packs .head , sort_pack );
709+ for (struct packfile_list_entry * e = packed -> packs .head ; e ; e = e -> next )
705710 if (!e -> next )
706- source -> packs .tail = e ;
711+ packed -> packs .tail = e ;
707712
708- source -> initialized = true;
709- }
710-
711- static void odb_source_packed_reprepare (struct odb_source * source )
712- {
713- struct odb_source_packed * packed = odb_source_packed_downcast (source );
714- packed -> initialized = false;
715- odb_source_packed_prepare (packed );
713+ packed -> initialized = true;
716714}
717715
718716static void odb_source_packed_reparent (const char * name UNUSED ,
@@ -768,7 +766,7 @@ struct odb_source_packed *odb_source_packed_new(struct object_database *odb,
768766
769767 packed -> base .free = odb_source_packed_free ;
770768 packed -> base .close = odb_source_packed_close ;
771- packed -> base .reprepare = odb_source_packed_reprepare ;
769+ packed -> base .prepare = odb_source_packed_prepare ;
772770 packed -> base .read_object_info = odb_source_packed_read_object_info ;
773771 packed -> base .read_object_stream = odb_source_packed_read_object_stream ;
774772 packed -> base .for_each_object = odb_source_packed_for_each_object ;
0 commit comments