2 aeabcaee 2018-03-09 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
4 aeabcaee 2018-03-09 stsp * Permission to use, copy, modify, and distribute this software for any
5 aeabcaee 2018-03-09 stsp * purpose with or without fee is hereby granted, provided that the above
6 aeabcaee 2018-03-09 stsp * copyright notice and this permission notice appear in all copies.
8 aeabcaee 2018-03-09 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 aeabcaee 2018-03-09 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 aeabcaee 2018-03-09 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 aeabcaee 2018-03-09 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 aeabcaee 2018-03-09 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 aeabcaee 2018-03-09 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 aeabcaee 2018-03-09 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 aeabcaee 2018-03-09 stsp * State information for a tracked file in a work tree.
19 aeabcaee 2018-03-09 stsp * When written to disk, multi-byte fields are written in big-endian.
20 aeabcaee 2018-03-09 stsp * Some fields are based on results from stat(2). These are only used in
21 aeabcaee 2018-03-09 stsp * order to detect modifications made to on-disk files, they are never
22 aeabcaee 2018-03-09 stsp * applied back to the filesystem.
24 aeabcaee 2018-03-09 stsp struct got_file_index_entry {
25 aeabcaee 2018-03-09 stsp uint64_t ctime_sec;
26 aeabcaee 2018-03-09 stsp uint64_t ctime_nsec;
27 aeabcaee 2018-03-09 stsp uint64_t mtime_sec;
28 aeabcaee 2018-03-09 stsp uint64_t mtime_nsec;
29 aeabcaee 2018-03-09 stsp uint32_t uid;
30 aeabcaee 2018-03-09 stsp uint32_t gid;
32 aeabcaee 2018-03-09 stsp * On-disk size is truncated to the lower 32 bits.
33 aeabcaee 2018-03-09 stsp * The value is only used to check for modifications anyway.
35 aeabcaee 2018-03-09 stsp uint32_t size;
36 aeabcaee 2018-03-09 stsp uint16_t mode;
37 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_MODE_OBJ_TYPE 0x000f
38 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_MODE_PERMS 0xff10
40 aeabcaee 2018-03-09 stsp /* SHA1 of corresponding blob in repository. */
41 aeabcaee 2018-03-09 stsp uint8_t blob_sha1[SHA1_DIGEST_LENGTH];
43 aeabcaee 2018-03-09 stsp uint32_t flags;
44 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_PATH_LEN 0x00000fff
45 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_STAGE 0x00003000
46 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_EXTENDED 0x00004000
47 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_ASSUME_VALID 0x00008000
50 aeabcaee 2018-03-09 stsp * UNIX-style path, relative to work tree root.
51 aeabcaee 2018-03-09 stsp * Variable length and NUL-padded to a multiple of 8.
53 aeabcaee 2018-03-09 stsp const char *path;
56 aeabcaee 2018-03-09 stsp /* "Stages" of a file which is afflicted by a 3-way merge conflict. */
57 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_MERGED 0
58 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_ANCESTOR 1
59 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_OURS 2
60 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_THEIRS 3
62 aeabcaee 2018-03-09 stsp /* On-disk file index header structure. */
63 aeabcaee 2018-03-09 stsp struct got_file_index_hdr {
64 aeabcaee 2018-03-09 stsp uint32_t signature; /* big-endian on disk */
65 aeabcaee 2018-03-09 stsp uint32_t version; /* big-endian on disk */
66 aeabcaee 2018-03-09 stsp uint32_t nentries; /* big-endian on disk */
67 aeabcaee 2018-03-09 stsp struct got_index_entry *entries; /* big-endian on disk */
68 aeabcaee 2018-03-09 stsp uint8_t sha1[SHA1_DIGEST_LENGTH]; /* checksum of above data */