Documentation / technical / shallow.txton commit t3504: use test_commit (6f0e577)
   1Shallow commits
   2===============
   3
   4.Definition
   5*********************************************************
   6Shallow commits do have parents, but not in the shallow
   7repo, and therefore grafts are introduced pretending that
   8these commits have no parents.
   9*********************************************************
  10
  11The basic idea is to write the SHA-1s of shallow commits into
  12$GIT_DIR/shallow, and handle its contents like the contents
  13of $GIT_DIR/info/grafts (with the difference that shallow
  14cannot contain parent information).
  15
  16This information is stored in a new file instead of grafts, or
  17even the config, since the user should not touch that file
  18at all (even throughout development of the shallow clone, it
  19was never manually edited!).
  20
  21Each line contains exactly one SHA-1. When read, a commit_graft
  22will be constructed, which has nr_parent < 0 to make it easier
  23to discern from user provided grafts.
  24
  25Since fsck-objects relies on the library to read the objects,
  26it honours shallow commits automatically.
  27
  28There are some unfinished ends of the whole shallow business:
  29
  30- maybe we have to force non-thin packs when fetching into a
  31  shallow repo (ATM they are forced non-thin).
  32
  33- A special handling of a shallow upstream is needed. At some
  34  stage, upload-pack has to check if it sends a shallow commit,
  35  and it should send that information early (or fail, if the
  36  client does not support shallow repositories). There is no
  37  support at all for this in this patch series.
  38
  39- Instead of locking $GIT_DIR/shallow at the start, just
  40  the timestamp of it is noted, and when it comes to writing it,
  41  a check is performed if the mtime is still the same, dying if
  42  it is not.
  43
  44- It is unclear how "push into/from a shallow repo" should behave.
  45
  46- If you deepen a history, you'd want to get the tags of the
  47  newly stored (but older!) commits. This does not work right now.
  48
  49To make a shallow clone, you can call "git-clone --depth 20 repo".
  50The result contains only commit chains with a length of at most 20.
  51It also writes an appropriate $GIT_DIR/shallow.
  52
  53You can deepen a shallow repository with "git-fetch --depth 20
  54repo branch", which will fetch branch from repo, but stop at depth
  5520, updating $GIT_DIR/shallow.
  56
  57The special depth 2147483647 (or 0x7fffffff, the largest positive
  58number a signed 32-bit integer can contain) means infinite depth.