@matheusbsbs / matheus-bagliano / commits / 9d0524d42f
Fork 0

Update send-pack pipeline documentation.

The pipeline was much more complex and needed documentation, but now it is trivial and straightforward. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jan 1, 2007 at 12:07 UTC 9d0524d42f340fc49f9e175d966afb7dce3854bb
1 file changed +16 -65
Documentation/technical/send-pack-pipeline.txt
+16 -65
@@ -27,86 +27,37 @@ Overall operation
27 Pack_objects pipeline
28 ---------------------
29
30 -This function gets one file descriptor (`out`) which is either a
30 +This function gets one file descriptor (`fd`) which is either a
31 socket (over the network) or a pipe (local). What's written to
32 this fd goes to git-receive-pack to be unpacked.
33
34 send-pack ---> fd ---> receive-pack
35
36 -It somehow forks once, but does not wait for it. I am not sure
37 -why.
38 -
39 -The forked child calls rev_list_generate() with that file
40 -descriptor (while the parent closes `out` -- the child will be
41 -the one that writes the packfile to the other end).
42 -
43 - send-pack
44 - |
45 - rev-list-generate ---> fd ---> receive-pack
46 -
47 -
48 -Then rev-list-generate forks after creates a pipe; the child
49 -will become a pipeline "rev-list --stdin | pack-objects", which
50 -is the rev_list() function, while the parent feeds that pipeline
51 -the list of refs.
36 +The function pack_objects creates a pipe and then forks. The
37 +forked child execs pack-objects with --revs to receive revision
38 +parameters from its standard input. This process will write the
39 +packfile to the other end.
40
41 send-pack
42 |
55 - rev-list-generate ---> fd ---> receive-pack
43 + pack_objects() ---> fd ---> receive-pack
44 | ^ (pipe)
45 v |
58 - rev-list
46 + (child)
47
60 -The child process, before calling rev-list, rearranges the file
61 -descriptors:
62 -
63 -. what it reads from rev-list-generate via pipe becomes the
64 - stdin; this is to feed the upstream of the pipeline which will
65 - be git-rev-list process.
66 -
67 -. what it writes to its stdout goes to the fd connected to
68 - receive-pack.
69 -
70 -On the other hand, the parent process, before starting to feed
71 -the child pipeline, closes the reading side of the pipe and fd
72 -to receive-pack.
48 +The child dup2's to arrange its standard output to go back to
49 +the other end, and read its standard input to come from the
50 +pipe. After that it exec's pack-objects. On the other hand,
51 +the parent process, before starting to feed the child pipeline,
52 +closes the reading side of the pipe and fd to receive-pack.
53
54 send-pack
55 |
76 - rev-list-generate
56 + pack_objects(parent)
57 |
58 v [0]
79 - rev-list [1] ---> receive-pack
80 -
81 -The parent then writes to the pipe and later closes it. There
82 -is a commented out waitpid to wait for the rev-list side before
83 -it exits, I again do not understand why.
84 -
85 -The rev-list function further sets up a pipe and forks to run
86 -git-rev-list piped to git-pack-objects. The child side, before
87 -exec'ing git-pack-objects, rearranges the file descriptors:
88 -
89 -. what it reads from the pipe becomes the stdin; this gets the
90 - list of objects from the git-rev-list process.
91 -
92 -. its stdout is already connected to receive-pack, so what it
93 - generates goes there.
94 -
95 -The parent process arranges its file descriptors before exec'ing
96 -git-rev-list:
97 -
98 -. its stdout is sent to the pipe to feed git-pack-objects.
99 -
100 -. its stdin is already connected to rev-list-generate and will
101 - read the set of refs from it.
102 -
103 -
104 - send-pack
105 - |
106 - rev-list-generate
107 - |
108 - v [0]
109 - git-rev-list [1] ---> [0] git-pack-objects [1] ---> receive-pack
110 -
59 + pack-objects [0] ---> receive-pack
60
61
62 +[jc: the pipeline was much more complex and needed documentation before
63 + I understood an earlier bug, but now it is trivial and straightforward.]