Skip to content

Commit f514d7d

Browse files
benpeartgitster
authored andcommitted
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>
1 parent 7ddb9b2 commit f514d7d

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

convert.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ struct cmd2process {
507507
unsigned int supported_capabilities;
508508
};
509509

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;
512512

513513
static int cmd2process_cmp(const struct subprocess_entry *e1,
514514
const struct subprocess_entry *e2,
@@ -517,7 +517,7 @@ static int cmd2process_cmp(const struct subprocess_entry *e1,
517517
return strcmp(e1->cmd, e2->cmd);
518518
}
519519

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)
521521
{
522522
struct subprocess_entry key;
523523

@@ -526,7 +526,7 @@ static struct subprocess_entry *find_multi_file_filter_entry(struct hashmap *has
526526
return hashmap_get(hashmap, &key, NULL);
527527
}
528528

529-
static void read_multi_file_filter_status(int fd, struct strbuf *status)
529+
static void subprocess_read_status(int fd, struct strbuf *status)
530530
{
531531
struct strbuf **pair;
532532
char *line;
@@ -546,7 +546,7 @@ static void read_multi_file_filter_status(int fd, struct strbuf *status)
546546
}
547547
}
548548

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)
550550
{
551551
if (!entry)
552552
return;
@@ -558,10 +558,10 @@ static void kill_multi_file_filter(struct hashmap *hashmap, struct subprocess_en
558558
hashmap_remove(hashmap, entry, NULL);
559559
}
560560

561-
static void stop_multi_file_filter(struct child_process *process)
561+
static void subprocess_exit_handler(struct child_process *process)
562562
{
563563
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. */
565565
close(process->in);
566566
close(process->out);
567567
sigchain_pop(SIGPIPE);
@@ -630,7 +630,7 @@ static int start_multi_file_filter_fn(struct subprocess_entry *subprocess)
630630
}
631631

632632
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,
634634
subprocess_start_fn startfn)
635635
{
636636
int err;
@@ -646,20 +646,20 @@ int start_multi_file_filter(struct hashmap *hashmap, struct subprocess_entry *en
646646
process->in = -1;
647647
process->out = -1;
648648
process->clean_on_exit = 1;
649-
process->clean_on_exit_handler = stop_multi_file_filter;
649+
process->clean_on_exit_handler = subprocess_exit_handler;
650650

651651
err = start_command(process);
652652
if (err) {
653-
error("cannot fork to run external filter '%s'", cmd);
653+
error("cannot fork to run subprocess '%s'", cmd);
654654
return err;
655655
}
656656

657657
hashmap_entry_init(entry, strhash(cmd));
658658

659659
err = startfn(entry);
660660
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);
663663
return err;
664664
}
665665

@@ -678,12 +678,12 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
678678
struct strbuf filter_status = STRBUF_INIT;
679679
const char *filter_type;
680680

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);
684684
entry = NULL;
685685
} else {
686-
entry = (struct cmd2process *)find_multi_file_filter_entry(&cmd_process_map, cmd);
686+
entry = (struct cmd2process *)subprocess_find_entry(&subprocess_map, cmd);
687687
}
688688

689689
fflush(NULL);
@@ -692,7 +692,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
692692
entry = xmalloc(sizeof(*entry));
693693
entry->supported_capabilities = 0;
694694

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)) {
696696
free(entry);
697697
return 0;
698698
}
@@ -737,7 +737,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
737737
if (err)
738738
goto done;
739739

740-
read_multi_file_filter_status(process->out, &filter_status);
740+
subprocess_read_status(process->out, &filter_status);
741741
err = strcmp(filter_status.buf, "success");
742742
if (err)
743743
goto done;
@@ -746,7 +746,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
746746
if (err)
747747
goto done;
748748

749-
read_multi_file_filter_status(process->out, &filter_status);
749+
subprocess_read_status(process->out, &filter_status);
750750
err = strcmp(filter_status.buf, "success");
751751

752752
done:
@@ -768,7 +768,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
768768
* Force shutdown and restart if another blob requires filtering.
769769
*/
770770
error("external filter '%s' failed", cmd);
771-
kill_multi_file_filter(&cmd_process_map, &entry->subprocess);
771+
subprocess_stop(&subprocess_map, &entry->subprocess);
772772
free(entry);
773773
}
774774
} else {

0 commit comments

Comments
 (0)