@@ -496,26 +496,31 @@ static int apply_single_file_filter(const char *path, const char *src, size_t le
496496#define CAP_CLEAN (1u<<0)
497497#define CAP_SMUDGE (1u<<1)
498498
499- struct cmd2process {
499+ struct subprocess_entry {
500500 struct hashmap_entry ent ; /* must be the first member! */
501- unsigned int supported_capabilities ;
502501 const char * cmd ;
503502 struct child_process process ;
504503};
505504
505+ struct cmd2process {
506+ struct subprocess_entry subprocess ; /* must be the first member! */
507+ unsigned int supported_capabilities ;
508+ };
509+
506510static int cmd_process_map_initialized ;
507511static struct hashmap cmd_process_map ;
508512
509- static int cmd2process_cmp (const struct cmd2process * e1 ,
510- const struct cmd2process * e2 ,
513+ static int cmd2process_cmp (const struct subprocess_entry * e1 ,
514+ const struct subprocess_entry * e2 ,
511515 const void * unused )
512516{
513517 return strcmp (e1 -> cmd , e2 -> cmd );
514518}
515519
516- static struct cmd2process * find_multi_file_filter_entry (struct hashmap * hashmap , const char * cmd )
520+ static struct subprocess_entry * find_multi_file_filter_entry (struct hashmap * hashmap , const char * cmd )
517521{
518- struct cmd2process key ;
522+ struct subprocess_entry key ;
523+
519524 hashmap_entry_init (& key , strhash (cmd ));
520525 key .cmd = cmd ;
521526 return hashmap_get (hashmap , & key , NULL );
@@ -541,7 +546,7 @@ static void read_multi_file_filter_status(int fd, struct strbuf *status)
541546 }
542547}
543548
544- static void kill_multi_file_filter (struct hashmap * hashmap , struct cmd2process * entry )
549+ static void kill_multi_file_filter (struct hashmap * hashmap , struct subprocess_entry * entry )
545550{
546551 if (!entry )
547552 return ;
@@ -571,8 +576,8 @@ static int start_multi_file_filter_fn(struct cmd2process *entry)
571576 struct string_list cap_list = STRING_LIST_INIT_NODUP ;
572577 char * cap_buf ;
573578 const char * cap_name ;
574- struct child_process * process = & entry -> process ;
575- const char * cmd = entry -> cmd ;
579+ struct child_process * process = & entry -> subprocess . process ;
580+ const char * cmd = entry -> subprocess . cmd ;
576581
577582 sigchain_push (SIGPIPE , SIG_IGN );
578583
@@ -632,9 +637,9 @@ static struct cmd2process *start_multi_file_filter(struct hashmap *hashmap, cons
632637 const char * argv [] = { cmd , NULL };
633638
634639 entry = xmalloc (sizeof (* entry ));
635- entry -> cmd = cmd ;
640+ entry -> subprocess . cmd = cmd ;
636641 entry -> supported_capabilities = 0 ;
637- process = & entry -> process ;
642+ process = & entry -> subprocess . process ;
638643
639644 child_process_init (process );
640645 process -> argv = argv ;
@@ -654,7 +659,7 @@ static struct cmd2process *start_multi_file_filter(struct hashmap *hashmap, cons
654659 err = start_multi_file_filter_fn (entry );
655660 if (err ) {
656661 error ("initialization for external filter '%s' failed" , cmd );
657- kill_multi_file_filter (hashmap , entry );
662+ kill_multi_file_filter (hashmap , & entry -> subprocess );
658663 return NULL ;
659664 }
660665
@@ -678,7 +683,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
678683 hashmap_init (& cmd_process_map , (hashmap_cmp_fn ) cmd2process_cmp , 0 );
679684 entry = NULL ;
680685 } else {
681- entry = find_multi_file_filter_entry (& cmd_process_map , cmd );
686+ entry = ( struct cmd2process * ) find_multi_file_filter_entry (& cmd_process_map , cmd );
682687 }
683688
684689 fflush (NULL );
@@ -688,7 +693,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
688693 if (!entry )
689694 return 0 ;
690695 }
691- process = & entry -> process ;
696+ process = & entry -> subprocess . process ;
692697
693698 if (!(wanted_capability & entry -> supported_capabilities ))
694699 return 0 ;
@@ -759,7 +764,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
759764 * Force shutdown and restart if another blob requires filtering.
760765 */
761766 error ("external filter '%s' failed" , cmd );
762- kill_multi_file_filter (& cmd_process_map , entry );
767+ kill_multi_file_filter (& cmd_process_map , & entry -> subprocess );
763768 }
764769 } else {
765770 strbuf_swap (dst , & nbuf );
0 commit comments