Skip to content

Commit 7e2e1bb

Browse files
jonathantanmygitster
authored andcommitted
Documentation: migrate sub-process docs to header
Move the documentation for the sub-process API from a separate txt file to its header file. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 487fe1f commit 7e2e1bb

File tree

2 files changed

+23
-61
lines changed

2 files changed

+23
-61
lines changed

Documentation/technical/api-sub-process.txt

Lines changed: 0 additions & 59 deletions
This file was deleted.

sub-process.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@
66
#include "run-command.h"
77

88
/*
9-
* Generic implementation of background process infrastructure.
10-
* See: Documentation/technical/api-sub-process.txt
9+
* The sub-process API makes it possible to run background sub-processes
10+
* for the entire lifetime of a Git invocation. If Git needs to communicate
11+
* with an external process multiple times, then this can reduces the process
12+
* invocation overhead. Git and the sub-process communicate through stdin and
13+
* stdout.
14+
*
15+
* The sub-processes are kept in a hashmap by command name and looked up
16+
* via the subprocess_find_entry function. If an existing instance can not
17+
* be found then a new process should be created and started. When the
18+
* parent git command terminates, all sub-processes are also terminated.
19+
*
20+
* This API is based on the run-command API.
1121
*/
1222

1323
/* data structures */
1424

25+
/* Members should not be accessed directly. */
1526
struct subprocess_entry {
1627
struct hashmap_entry ent; /* must be the first member! */
1728
const char *cmd;
@@ -20,21 +31,31 @@ struct subprocess_entry {
2031

2132
/* subprocess functions */
2233

34+
/* Function to test two subprocess hashmap entries for equality. */
2335
extern int cmd2process_cmp(const void *unused_cmp_data,
2436
const struct subprocess_entry *e1,
2537
const struct subprocess_entry *e2,
2638
const void *unused_keydata);
2739

40+
/*
41+
* User-supplied function to initialize the sub-process. This is
42+
* typically used to negotiate the interface version and capabilities.
43+
*/
2844
typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
45+
46+
/* Start a subprocess and add it to the subprocess hashmap. */
2947
int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
3048
subprocess_start_fn startfn);
3149

50+
/* Kill a subprocess and remove it from the subprocess hashmap. */
3251
void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
3352

53+
/* Find a subprocess in the subprocess hashmap. */
3454
struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
3555

3656
/* subprocess helper functions */
3757

58+
/* Get the underlying `struct child_process` from a subprocess. */
3859
static inline struct child_process *subprocess_get_child_process(
3960
struct subprocess_entry *entry)
4061
{

0 commit comments

Comments
 (0)