convert: rename reusable sub-process functions

Do a mechanical rename of the functions that will become the reusable sub-process module. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ben Peart committed May 5, 2017 at 11:28 UTC f514d7d177f7cabbacc3f2cda96ca211266ac2ff
1 file changed +20 -20
convert.c
+20 -20
@@ -507,8 +507,8 @@ struct cmd2process {
507 unsigned int supported_capabilities;
508 };
509
510 -static int cmd_process_map_initialized;
511 -static struct hashmap cmd_process_map;
510 +static int subprocess_map_initialized;
511 +static struct hashmap subprocess_map;
512
513 static int cmd2process_cmp(const struct subprocess_entry *e1,
514 const struct subprocess_entry *e2,
@@ -517,7 +517,7 @@ static int cmd2process_cmp(const struct subprocess_entry *e1,
517 return strcmp(e1->cmd, e2->cmd);
518 }
519
520 -static struct subprocess_entry *find_multi_file_filter_entry(struct hashmap *hashmap, const char *cmd)
520 +static struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd)
521 {
522 struct subprocess_entry key;
523
@@ -526,7 +526,7 @@ static struct subprocess_entry *find_multi_file_filter_entry(struct hashmap *has
526 return hashmap_get(hashmap, &key, NULL);
527 }
528
529 -static void read_multi_file_filter_status(int fd, struct strbuf *status)
529 +static void subprocess_read_status(int fd, struct strbuf *status)
530 {
531 struct strbuf **pair;
532 char *line;
@@ -546,7 +546,7 @@ static void read_multi_file_filter_status(int fd, struct strbuf *status)
546 }
547 }
548
549 -static void kill_multi_file_filter(struct hashmap *hashmap, struct subprocess_entry *entry)
549 +static void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry)
550 {
551 if (!entry)
552 return;
@@ -558,10 +558,10 @@ static void kill_multi_file_filter(struct hashmap *hashmap, struct subprocess_en
558 hashmap_remove(hashmap, entry, NULL);
559 }
560
561 -static void stop_multi_file_filter(struct child_process *process)
561 +static void subprocess_exit_handler(struct child_process *process)
562 {
563 sigchain_push(SIGPIPE, SIG_IGN);
564 - /* Closing the pipe signals the filter to initiate a shutdown. */
564 + /* Closing the pipe signals the subprocess to initiate a shutdown. */
565 close(process->in);
566 close(process->out);
567 sigchain_pop(SIGPIPE);
@@ -630,7 +630,7 @@ done:
630 }
631
632 typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
633 -int start_multi_file_filter(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
633 +int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
634 subprocess_start_fn startfn)
635 {
636 int err;
@@ -646,11 +646,11 @@ int start_multi_file_filter(struct hashmap *hashmap, struct subprocess_entry *en
646 process->in = -1;
647 process->out = -1;
648 process->clean_on_exit = 1;
649 - process->clean_on_exit_handler = stop_multi_file_filter;
649 + process->clean_on_exit_handler = subprocess_exit_handler;
650
651 err = start_command(process);
652 if (err) {
653 - error("cannot fork to run external filter '%s'", cmd);
653 + error("cannot fork to run subprocess '%s'", cmd);
654 return err;
655 }
656
@@ -658,8 +658,8 @@ int start_multi_file_filter(struct hashmap *hashmap, struct subprocess_entry *en
658
659 err = startfn(entry);
660 if (err) {
661 - error("initialization for external filter '%s' failed", cmd);
662 - kill_multi_file_filter(hashmap, entry);
661 + error("initialization for subprocess '%s' failed", cmd);
662 + subprocess_stop(hashmap, entry);
663 return err;
664 }
665
@@ -678,12 +678,12 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
678 struct strbuf filter_status = STRBUF_INIT;
679 const char *filter_type;
680
681 - if (!cmd_process_map_initialized) {
682 - cmd_process_map_initialized = 1;
683 - hashmap_init(&cmd_process_map, (hashmap_cmp_fn) cmd2process_cmp, 0);
681 + if (!subprocess_map_initialized) {
682 + subprocess_map_initialized = 1;
683 + hashmap_init(&subprocess_map, (hashmap_cmp_fn) cmd2process_cmp, 0);
684 entry = NULL;
685 } else {
686 - entry = (struct cmd2process *)find_multi_file_filter_entry(&cmd_process_map, cmd);
686 + entry = (struct cmd2process *)subprocess_find_entry(&subprocess_map, cmd);
687 }
688
689 fflush(NULL);
@@ -692,7 +692,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
692 entry = xmalloc(sizeof(*entry));
693 entry->supported_capabilities = 0;
694
695 - if (start_multi_file_filter(&cmd_process_map, &entry->subprocess, cmd, start_multi_file_filter_fn)) {
695 + if (subprocess_start(&subprocess_map, &entry->subprocess, cmd, start_multi_file_filter_fn)) {
696 free(entry);
697 return 0;
698 }
@@ -737,7 +737,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
737 if (err)
738 goto done;
739
740 - read_multi_file_filter_status(process->out, &filter_status);
740 + subprocess_read_status(process->out, &filter_status);
741 err = strcmp(filter_status.buf, "success");
742 if (err)
743 goto done;
@@ -746,7 +746,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
746 if (err)
747 goto done;
748
749 - read_multi_file_filter_status(process->out, &filter_status);
749 + subprocess_read_status(process->out, &filter_status);
750 err = strcmp(filter_status.buf, "success");
751
752 done:
@@ -768,7 +768,7 @@ done:
768 * Force shutdown and restart if another blob requires filtering.
769 */
770 error("external filter '%s' failed", cmd);
771 - kill_multi_file_filter(&cmd_process_map, &entry->subprocess);
771 + subprocess_stop(&subprocess_map, &entry->subprocess);
772 free(entry);
773 }
774 } else {