@@ -157,12 +157,11 @@ static int remove_available_paths(struct string_list_item *item, void *cb_data)
157157
158158 available = string_list_lookup (available_paths , item -> string );
159159 if (available )
160- available -> util = ( void * ) item -> string ;
160+ available -> util = item -> util ;
161161 return !available ;
162162}
163163
164- int finish_delayed_checkout (struct checkout * state , int * nr_checkouts ,
165- int show_progress )
164+ int finish_delayed_checkout (struct checkout * state , int show_progress )
166165{
167166 int errs = 0 ;
168167 unsigned processed_paths = 0 ;
@@ -227,7 +226,7 @@ int finish_delayed_checkout(struct checkout *state, int *nr_checkouts,
227226 strlen (path -> string ), 0 );
228227 if (ce ) {
229228 display_progress (progress , ++ processed_paths );
230- errs |= checkout_entry (ce , state , NULL , nr_checkouts );
229+ errs |= checkout_entry (ce , state , NULL , path -> util );
231230 filtered_bytes += ce -> ce_stat_data .sd_size ;
232231 display_throughput (progress , filtered_bytes );
233232 } else
@@ -266,7 +265,8 @@ void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
266265
267266/* Note: ca is used (and required) iff the entry refers to a regular file. */
268267static int write_entry (struct cache_entry * ce , char * path , struct conv_attrs * ca ,
269- const struct checkout * state , int to_tempfile )
268+ const struct checkout * state , int to_tempfile ,
269+ int * nr_checkouts )
270270{
271271 unsigned int ce_mode_s_ifmt = ce -> ce_mode & S_IFMT ;
272272 struct delayed_checkout * dco = state -> delayed_checkout ;
@@ -279,6 +279,7 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
279279 struct stat st ;
280280 const struct submodule * sub ;
281281 struct checkout_metadata meta ;
282+ static int scratch_nr_checkouts ;
282283
283284 clone_checkout_metadata (& meta , & state -> meta , & ce -> oid );
284285
@@ -333,9 +334,15 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
333334 ret = async_convert_to_working_tree_ca (ca , ce -> name ,
334335 new_blob , size ,
335336 & buf , & meta , dco );
336- if (ret && string_list_has_string (& dco -> paths , ce -> name )) {
337- free (new_blob );
338- goto delayed ;
337+ if (ret ) {
338+ struct string_list_item * item =
339+ string_list_lookup (& dco -> paths , ce -> name );
340+ if (item ) {
341+ item -> util = nr_checkouts ? nr_checkouts
342+ : & scratch_nr_checkouts ;
343+ free (new_blob );
344+ goto delayed ;
345+ }
339346 }
340347 } else {
341348 ret = convert_to_working_tree_ca (ca , ce -> name , new_blob ,
@@ -392,6 +399,8 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
392399 ce -> name );
393400 update_ce_after_write (state , ce , & st );
394401 }
402+ if (nr_checkouts )
403+ (* nr_checkouts )++ ;
395404delayed :
396405 return 0 ;
397406}
@@ -476,7 +485,7 @@ int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca,
476485 convert_attrs (state -> istate , & ca_buf , ce -> name );
477486 ca = & ca_buf ;
478487 }
479- return write_entry (ce , topath , ca , state , 1 );
488+ return write_entry (ce , topath , ca , state , 1 , nr_checkouts );
480489 }
481490
482491 strbuf_reset (& path );
@@ -540,18 +549,15 @@ int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca,
540549
541550 create_directories (path .buf , path .len , state );
542551
543- if (nr_checkouts )
544- (* nr_checkouts )++ ;
545-
546552 if (S_ISREG (ce -> ce_mode ) && !ca ) {
547553 convert_attrs (state -> istate , & ca_buf , ce -> name );
548554 ca = & ca_buf ;
549555 }
550556
551- if (!enqueue_checkout (ce , ca ))
557+ if (!enqueue_checkout (ce , ca , nr_checkouts ))
552558 return 0 ;
553559
554- return write_entry (ce , path .buf , ca , state , 0 );
560+ return write_entry (ce , path .buf , ca , state , 0 , nr_checkouts );
555561}
556562
557563void unlink_entry (const struct cache_entry * ce )
0 commit comments