@@ -106,100 +106,6 @@ static int repack_config(const char *var, const char *value,
106106 return git_default_config (var , value , ctx , cb );
107107}
108108
109- static void combine_small_cruft_packs (FILE * in , size_t combine_cruft_below_size ,
110- struct existing_packs * existing )
111- {
112- struct packfile_store * packs = existing -> repo -> objects -> packfiles ;
113- struct packed_git * p ;
114- struct strbuf buf = STRBUF_INIT ;
115- size_t i ;
116-
117- for (p = packfile_store_get_all_packs (packs ); p ; p = p -> next ) {
118- if (!(p -> is_cruft && p -> pack_local ))
119- continue ;
120-
121- strbuf_reset (& buf );
122- strbuf_addstr (& buf , pack_basename (p ));
123- strbuf_strip_suffix (& buf , ".pack" );
124-
125- if (!string_list_has_string (& existing -> cruft_packs , buf .buf ))
126- continue ;
127-
128- if (p -> pack_size < combine_cruft_below_size ) {
129- fprintf (in , "-%s\n" , pack_basename (p ));
130- } else {
131- existing_packs_retain_cruft (existing , p );
132- fprintf (in , "%s\n" , pack_basename (p ));
133- }
134- }
135-
136- for (i = 0 ; i < existing -> non_kept_packs .nr ; i ++ )
137- fprintf (in , "-%s.pack\n" ,
138- existing -> non_kept_packs .items [i ].string );
139-
140- strbuf_release (& buf );
141- }
142-
143- static int write_cruft_pack (const struct write_pack_opts * opts ,
144- const char * cruft_expiration ,
145- unsigned long combine_cruft_below_size ,
146- struct string_list * names ,
147- struct existing_packs * existing )
148- {
149- struct child_process cmd = CHILD_PROCESS_INIT ;
150- struct string_list_item * item ;
151- FILE * in ;
152- int ret ;
153- const char * pack_prefix = write_pack_opts_pack_prefix (opts );
154-
155- prepare_pack_objects (& cmd , opts -> po_args , opts -> destination );
156-
157- strvec_push (& cmd .args , "--cruft" );
158- if (cruft_expiration )
159- strvec_pushf (& cmd .args , "--cruft-expiration=%s" ,
160- cruft_expiration );
161-
162- strvec_push (& cmd .args , "--non-empty" );
163-
164- cmd .in = -1 ;
165-
166- ret = start_command (& cmd );
167- if (ret )
168- return ret ;
169-
170- /*
171- * names has a confusing double use: it both provides the list
172- * of just-written new packs, and accepts the name of the cruft
173- * pack we are writing.
174- *
175- * By the time it is read here, it contains only the pack(s)
176- * that were just written, which is exactly the set of packs we
177- * want to consider kept.
178- *
179- * If `--expire-to` is given, the double-use served by `names`
180- * ensures that the pack written to `--expire-to` excludes any
181- * objects contained in the cruft pack.
182- */
183- in = xfdopen (cmd .in , "w" );
184- for_each_string_list_item (item , names )
185- fprintf (in , "%s-%s.pack\n" , pack_prefix , item -> string );
186- if (combine_cruft_below_size && !cruft_expiration ) {
187- combine_small_cruft_packs (in , combine_cruft_below_size ,
188- existing );
189- } else {
190- for_each_string_list_item (item , & existing -> non_kept_packs )
191- fprintf (in , "-%s.pack\n" , item -> string );
192- for_each_string_list_item (item , & existing -> cruft_packs )
193- fprintf (in , "-%s.pack\n" , item -> string );
194- }
195- for_each_string_list_item (item , & existing -> kept_packs )
196- fprintf (in , "%s.pack\n" , item -> string );
197- fclose (in );
198-
199- return finish_pack_objects_cmd (existing -> repo -> hash_algo , opts , & cmd ,
200- names );
201- }
202-
203109int cmd_repack (int argc ,
204110 const char * * argv ,
205111 const char * prefix ,
0 commit comments