@@ -356,13 +356,14 @@ static void scan_windows(struct packed_git *p,
356356
357357static int unuse_one_window (struct packed_git * current )
358358{
359- struct packed_git * p , * lru_p = NULL ;
359+ struct packfile_list_entry * e ;
360+ struct packed_git * lru_p = NULL ;
360361 struct pack_window * lru_w = NULL , * lru_l = NULL ;
361362
362363 if (current )
363364 scan_windows (current , & lru_p , & lru_w , & lru_l );
364- for (p = current -> repo -> objects -> packfiles -> packs ; p ; p = p -> next )
365- scan_windows (p , & lru_p , & lru_w , & lru_l );
365+ for (e = current -> repo -> objects -> packfiles -> packs . head ; e ; e = e -> next )
366+ scan_windows (e -> pack , & lru_p , & lru_w , & lru_l );
366367 if (lru_p ) {
367368 munmap (lru_w -> base , lru_w -> len );
368369 pack_mapped -= lru_w -> len ;
@@ -542,14 +543,15 @@ static void find_lru_pack(struct packed_git *p, struct packed_git **lru_p, struc
542543
543544static int close_one_pack (struct repository * r )
544545{
545- struct packed_git * p , * lru_p = NULL ;
546+ struct packfile_list_entry * e ;
547+ struct packed_git * lru_p = NULL ;
546548 struct pack_window * mru_w = NULL ;
547549 int accept_windows_inuse = 1 ;
548550
549- for (p = r -> objects -> packfiles -> packs ; p ; p = p -> next ) {
550- if (p -> pack_fd == -1 )
551+ for (e = r -> objects -> packfiles -> packs . head ; e ; e = e -> next ) {
552+ if (e -> pack -> pack_fd == -1 )
551553 continue ;
552- find_lru_pack (p , & lru_p , & mru_w , & accept_windows_inuse );
554+ find_lru_pack (e -> pack , & lru_p , & mru_w , & accept_windows_inuse );
553555 }
554556
555557 if (lru_p )
@@ -868,8 +870,7 @@ void packfile_store_add_pack(struct packfile_store *store,
868870 if (pack -> pack_fd != -1 )
869871 pack_open_fds ++ ;
870872
871- pack -> next = store -> packs ;
872- store -> packs = pack ;
873+ packfile_list_prepend (& store -> packs , pack );
873874
874875 strmap_put (& store -> packs_by_path , pack -> pack_name , pack );
875876}
@@ -1046,9 +1047,10 @@ static void prepare_packed_git_one(struct odb_source *source)
10461047 string_list_clear (data .garbage , 0 );
10471048}
10481049
1049- DEFINE_LIST_SORT (static , sort_packs , struct packed_git , next );
1050+ DEFINE_LIST_SORT (static , sort_packs , struct packfile_list_entry , next );
10501051
1051- static int sort_pack (const struct packed_git * a , const struct packed_git * b )
1052+ static int sort_pack (const struct packfile_list_entry * a ,
1053+ const struct packfile_list_entry * b )
10521054{
10531055 int st ;
10541056
@@ -1058,7 +1060,7 @@ static int sort_pack(const struct packed_git *a, const struct packed_git *b)
10581060 * remote ones could be on a network mounted filesystem.
10591061 * Favor local ones for these reasons.
10601062 */
1061- st = a -> pack_local - b -> pack_local ;
1063+ st = a -> pack -> pack_local - b -> pack -> pack_local ;
10621064 if (st )
10631065 return - st ;
10641066
@@ -1067,21 +1069,19 @@ static int sort_pack(const struct packed_git *a, const struct packed_git *b)
10671069 * and more recent objects tend to get accessed more
10681070 * often.
10691071 */
1070- if (a -> mtime < b -> mtime )
1072+ if (a -> pack -> mtime < b -> pack -> mtime )
10711073 return 1 ;
1072- else if (a -> mtime == b -> mtime )
1074+ else if (a -> pack -> mtime == b -> pack -> mtime )
10731075 return 0 ;
10741076 return -1 ;
10751077}
10761078
10771079static void packfile_store_prepare_mru (struct packfile_store * store )
10781080{
1079- struct packed_git * p ;
1080-
10811081 packfile_list_clear (& store -> mru );
10821082
1083- for (p = store -> packs ; p ; p = p -> next )
1084- packfile_list_append (& store -> mru , p );
1083+ for (struct packfile_list_entry * e = store -> packs . head ; e ; e = e -> next )
1084+ packfile_list_append (& store -> mru , e -> pack );
10851085}
10861086
10871087void packfile_store_prepare (struct packfile_store * store )
@@ -1096,7 +1096,11 @@ void packfile_store_prepare(struct packfile_store *store)
10961096 prepare_multi_pack_index_one (source );
10971097 prepare_packed_git_one (source );
10981098 }
1099- sort_packs (& store -> packs , sort_pack );
1099+
1100+ sort_packs (& store -> packs .head , sort_pack );
1101+ for (struct packfile_list_entry * e = store -> packs .head ; e ; e = e -> next )
1102+ if (!e -> next )
1103+ store -> packs .tail = e ;
11001104
11011105 packfile_store_prepare_mru (store );
11021106 store -> initialized = true;
@@ -1108,7 +1112,7 @@ void packfile_store_reprepare(struct packfile_store *store)
11081112 packfile_store_prepare (store );
11091113}
11101114
1111- struct packed_git * packfile_store_get_packs (struct packfile_store * store )
1115+ struct packfile_list_entry * packfile_store_get_packs (struct packfile_store * store )
11121116{
11131117 packfile_store_prepare (store );
11141118
@@ -1120,7 +1124,7 @@ struct packed_git *packfile_store_get_packs(struct packfile_store *store)
11201124 prepare_midx_pack (m , i );
11211125 }
11221126
1123- return store -> packs ;
1127+ return store -> packs . head ;
11241128}
11251129
11261130struct packfile_list_entry * packfile_store_get_packs_mru (struct packfile_store * store )
@@ -1276,11 +1280,11 @@ void mark_bad_packed_object(struct packed_git *p, const struct object_id *oid)
12761280const struct packed_git * has_packed_and_bad (struct repository * r ,
12771281 const struct object_id * oid )
12781282{
1279- struct packed_git * p ;
1283+ struct packfile_list_entry * e ;
12801284
1281- for (p = r -> objects -> packfiles -> packs ; p ; p = p -> next )
1282- if (oidset_contains (& p -> bad_objects , oid ))
1283- return p ;
1285+ for (e = r -> objects -> packfiles -> packs . head ; e ; e = e -> next )
1286+ if (oidset_contains (& e -> pack -> bad_objects , oid ))
1287+ return e -> pack ;
12841288 return NULL ;
12851289}
12861290
@@ -2088,19 +2092,6 @@ int is_pack_valid(struct packed_git *p)
20882092 return !open_packed_git (p );
20892093}
20902094
2091- struct packed_git * find_oid_pack (const struct object_id * oid ,
2092- struct packed_git * packs )
2093- {
2094- struct packed_git * p ;
2095-
2096- for (p = packs ; p ; p = p -> next ) {
2097- if (find_pack_entry_one (oid , p ))
2098- return p ;
2099- }
2100- return NULL ;
2101-
2102- }
2103-
21042095static int fill_pack_entry (const struct object_id * oid ,
21052096 struct pack_entry * e ,
21062097 struct packed_git * p )
@@ -2139,7 +2130,7 @@ int find_pack_entry(struct repository *r, const struct object_id *oid, struct pa
21392130 if (source -> midx && fill_midx_entry (source -> midx , oid , e ))
21402131 return 1 ;
21412132
2142- if (!r -> objects -> packfiles -> packs )
2133+ if (!r -> objects -> packfiles -> packs . head )
21432134 return 0 ;
21442135
21452136 for (l = r -> objects -> packfiles -> mru .head ; l ; l = l -> next ) {
@@ -2404,19 +2395,19 @@ struct packfile_store *packfile_store_new(struct object_database *odb)
24042395
24052396void packfile_store_free (struct packfile_store * store )
24062397{
2407- for (struct packed_git * p = store -> packs , * next ; p ; p = next ) {
2408- next = p -> next ;
2409- free ( p );
2410- }
2398+ for (struct packfile_list_entry * e = store -> packs . head ; e ; e = e -> next )
2399+ free ( e -> pack ) ;
2400+ packfile_list_clear ( & store -> packs );
2401+
24112402 strmap_clear (& store -> packs_by_path , 0 );
24122403 free (store );
24132404}
24142405
24152406void packfile_store_close (struct packfile_store * store )
24162407{
2417- for (struct packed_git * p = store -> packs ; p ; p = p -> next ) {
2418- if (p -> do_not_close )
2408+ for (struct packfile_list_entry * e = store -> packs . head ; e ; e = e -> next ) {
2409+ if (e -> pack -> do_not_close )
24192410 BUG ("want to close pack marked 'do-not-close'" );
2420- close_pack (p );
2411+ close_pack (e -> pack );
24212412 }
24222413}
0 commit comments