|
| 1 | +Git status serialization format |
| 2 | +=============================== |
| 3 | + |
| 4 | +Git status serialization enables git to dump the results of a status scan |
| 5 | +to a binary file. This file can then be loaded by later status invocations |
| 6 | +to print the cached status results. |
| 7 | + |
| 8 | +The file contains the essential fields from: |
| 9 | +() the index |
| 10 | +() the "struct wt_status" for the overall results |
| 11 | +() the contents of "struct wt_status_change_data" for tracked changed files |
| 12 | +() the list of untracked and ignored files |
| 13 | + |
| 14 | +Version 1 Format: |
| 15 | +================= |
| 16 | + |
| 17 | +The V1 file begins with a required header section followed by optional |
| 18 | +sections for each type of item (changed, untracked, ignored). Individual |
| 19 | +item sections are only present if necessary. Each item section begins |
| 20 | +with an item-type header with the number of items in the section. |
| 21 | + |
| 22 | +Each "line" in the format is encoded using pkt-line with a final LF. |
| 23 | +Flush packets are used to terminate sections. |
| 24 | + |
| 25 | +----------------- |
| 26 | +PKT-LINE("version" SP "1") |
| 27 | +<v1-header-section> |
| 28 | +[<v1-changed-item-section>] |
| 29 | +[<v1-untracked-item-section>] |
| 30 | +[<v1-ignored-item-section>] |
| 31 | +----------------- |
| 32 | + |
| 33 | + |
| 34 | +V1 Header |
| 35 | +--------- |
| 36 | + |
| 37 | +The v1-header-section fields are taken directly from "struct wt_status". |
| 38 | +Each field is printed on a separate pkt-line. Lines for NULL string |
| 39 | +values are omitted. All integers are printed with "%d". OIDs are |
| 40 | +printed in hex. |
| 41 | + |
| 42 | +v1-header-section = <v1-index-headers> |
| 43 | + <v1-wt-status-headers> |
| 44 | + PKT-LINE(<flush>) |
| 45 | + |
| 46 | +v1-index-headers = PKT-LINE("index_mtime" SP <sec> SP <nsec> LF) |
| 47 | + |
| 48 | +v1-wt-status-headers = PKT-LINE("is_initial" SP <integer> LF) |
| 49 | + [ PKT-LINE("branch" SP <branch-name> LF) ] |
| 50 | + [ PKT-LINE("reference" SP <reference-name> LF) ] |
| 51 | + PKT-LINE("show_ignored_files" SP <integer> LF) |
| 52 | + PKT-LINE("show_untracked_files" SP <integer> LF) |
| 53 | + PKT-LINE("show_ignored_directory" SP <integer> LF) |
| 54 | + [ PKT-LINE("ignore_submodule_arg" SP <string> LF) ] |
| 55 | + PKT-LINE("detect_rename" SP <integer> LF) |
| 56 | + PKT-LINE("rename_score" SP <integer> LF) |
| 57 | + PKT-LINE("rename_limit" SP <integer> LF) |
| 58 | + PKT-LINE("detect_break" SP <integer> LF) |
| 59 | + PKT-LINE("sha1_commit" SP <oid> LF) |
| 60 | + PKT-LINE("committable" SP <integer> LF) |
| 61 | + PKT-LINE("workdir_dirty" SP <integer> LF) |
| 62 | + |
| 63 | + |
| 64 | +V1 Changed Items |
| 65 | +---------------- |
| 66 | + |
| 67 | +The v1-changed-item-section lists all of the changed items with one |
| 68 | +item per pkt-line. Each pkt-line contains: a binary block of data |
| 69 | +from "struct wt_status_serialize_data_fixed" in a fixed header where |
| 70 | +integers are in network byte order and OIDs are in raw (non-hex) form. |
| 71 | +This is followed by one or two raw pathnames (not c-quoted) with NUL |
| 72 | +terminators (both NULs are always present even if there is no rename). |
| 73 | + |
| 74 | +v1-changed-item-section = PKT-LINE("changed" SP <count> LF) |
| 75 | + [ PKT-LINE(<changed_item> LF) ]+ |
| 76 | + PKT-LINE(<flush>) |
| 77 | + |
| 78 | +changed_item = <byte[4] worktree_status> |
| 79 | + <byte[4] index_status> |
| 80 | + <byte[4] stagemask> |
| 81 | + <byte[4] score> |
| 82 | + <byte[4] mode_head> |
| 83 | + <byte[4] mode_index> |
| 84 | + <byte[4] mode_worktree> |
| 85 | + <byte[4] dirty_submodule> |
| 86 | + <byte[4] new_submodule_commits> |
| 87 | + <byte[20] oid_head> |
| 88 | + <byte[20] oid_index> |
| 89 | + <byte[*] path> |
| 90 | + NUL |
| 91 | + [ <byte[*] src_path> ] |
| 92 | + NUL |
| 93 | + |
| 94 | + |
| 95 | +V1 Untracked and Ignored Items |
| 96 | +------------------------------ |
| 97 | + |
| 98 | +These sections are simple lists of pathnames. They ARE NOT |
| 99 | +c-quoted. |
| 100 | + |
| 101 | +v1-untracked-item-section = PKT-LINE("untracked" SP <count> LF) |
| 102 | + [ PKT-LINE(<pathname> LF) ]+ |
| 103 | + PKT-LINE(<flush>) |
| 104 | + |
| 105 | +v1-ignored-item-section = PKT-LINE("ignored" SP <count> LF) |
| 106 | + [ PKT-LINE(<pathname> LF) ]+ |
| 107 | + PKT-LINE(<flush>) |
0 commit comments