/usr/share/doc/git/technical
NameSizeModeActions
api-error-handling.html222590644editdlrm
api-error-handling.txt38180644editdlrm
api-index-skel.txt4320644editdlrm
api-index.html171830644editdlrm
api-index.sh6110644editdlrm
api-index.txt6480644editdlrm
api-merge.html183050644editdlrm
api-merge.txt10900644editdlrm
api-parse-options.html366570644editdlrm
api-parse-options.txt131570644editdlrm
api-simple-ipc.html223880644editdlrm
api-simple-ipc.txt48520644editdlrm
api-trace2.html776190644editdlrm
api-trace2.txt442550644editdlrm
bitmap-format.html304030644editdlrm
bitmap-format.txt88710644editdlrm
bundle-uri.html513870644editdlrm
bundle-uri.txt267870644editdlrm
commit-graph.txt179570644editdlrm
directory-rename-detection.txt51990644editdlrm
hash-function-transition.html645390644editdlrm
hash-function-transition.txt358940644editdlrm
long-running-process-protocol.html189950644editdlrm
long-running-process-protocol.txt19290644editdlrm
multi-pack-index.html224620644editdlrm
multi-pack-index.txt44590644editdlrm
pack-heuristics.html435940644editdlrm
pack-heuristics.txt180400644editdlrm
packfile-uri.txt37480644editdlrm
parallel-checkout.html317150644editdlrm
parallel-checkout.txt123010644editdlrm
partial-clone.html364960644editdlrm
partial-clone.txt149680644editdlrm
racy-git.html279950644editdlrm
racy-git.txt91210644editdlrm
reftable.html737920644editdlrm
reftable.txt375250644editdlrm
remembering-renames.txt303600644editdlrm
repository-version.txt43110644editdlrm
rerere.txt65100644editdlrm
scalar.html204580644editdlrm
scalar.txt29350644editdlrm
send-pack-pipeline.html193150644editdlrm
send-pack-pipeline.txt19690644editdlrm
shallow.html196850644editdlrm
shallow.txt25480644editdlrm
sparse-checkout.txt474990644editdlrm
sparse-index.txt95010644editdlrm
trivial-merge.html222730644editdlrm
trivial-merge.txt42640644editdlrm
Edit: /usr/share/doc/git/technical/send-pack-pipeline.html (19315B)
Git-send-pack internals

Overall operation

  1. Connects to the remote side and invokes git-receive-pack.

  2. Learns what refs the remote has and what commit they point at. Matches them to the refspecs we are pushing.

  3. Checks if there are non-fast-forwards. Unlike fetch-pack, the repository send-pack runs in is supposed to be a superset of the recipient in fast-forward cases, so there is no need for want/have exchanges, and fast-forward check can be done locally. Tell the result to the other end.

  4. Calls pack_objects() which generates a packfile and sends it over to the other end.

  5. If the remote side is new enough (v1.1.0 or later), wait for the unpack and hook status from the other end.

  6. Exit with appropriate error codes.

Pack_objects pipeline

This function gets one file descriptor (fd) which is either a socket (over the network) or a pipe (local). What’s written to this fd goes to git-receive-pack to be unpacked.

send-pack ---> fd ---> receive-pack

The function pack_objects creates a pipe and then forks. The forked child execs pack-objects with --revs to receive revision parameters from its standard input. This process will write the packfile to the other end.

send-pack
   |
   pack_objects() ---> fd ---> receive-pack
      | ^ (pipe)
      v |
     (child)

The child dup2’s to arrange its standard output to go back to the other end, and read its standard input to come from the pipe. After that it exec’s pack-objects. On the other hand, the parent process, before starting to feed the child pipeline, closes the reading side of the pipe and fd to receive-pack.

send-pack
   |
   pack_objects(parent)
      |
      v [0]
     pack-objects [0] ---> receive-pack

[jc: the pipeline was much more complex and needed documentation before I understood an earlier bug, but now it is trivial and straightforward.]