Blame


1 aeabcaee 2018-03-09 stsp /*
2 aeabcaee 2018-03-09 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 aeabcaee 2018-03-09 stsp *
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.
7 aeabcaee 2018-03-09 stsp *
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.
15 aeabcaee 2018-03-09 stsp */
16 aeabcaee 2018-03-09 stsp
17 aeabcaee 2018-03-09 stsp /*
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.
23 aeabcaee 2018-03-09 stsp */
24 aeabcaee 2018-03-09 stsp struct got_file_index_entry {
25 c8988c68 2018-03-09 stsp TAILQ_ENTRY(, got_file_index_entry) entry;
26 aeabcaee 2018-03-09 stsp uint64_t ctime_sec;
27 aeabcaee 2018-03-09 stsp uint64_t ctime_nsec;
28 aeabcaee 2018-03-09 stsp uint64_t mtime_sec;
29 aeabcaee 2018-03-09 stsp uint64_t mtime_nsec;
30 aeabcaee 2018-03-09 stsp uint32_t uid;
31 aeabcaee 2018-03-09 stsp uint32_t gid;
32 aeabcaee 2018-03-09 stsp /*
33 aeabcaee 2018-03-09 stsp * On-disk size is truncated to the lower 32 bits.
34 aeabcaee 2018-03-09 stsp * The value is only used to check for modifications anyway.
35 aeabcaee 2018-03-09 stsp */
36 aeabcaee 2018-03-09 stsp uint32_t size;
37 aeabcaee 2018-03-09 stsp uint16_t mode;
38 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_MODE_OBJ_TYPE 0x000f
39 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_MODE_PERMS 0xff10
40 aeabcaee 2018-03-09 stsp
41 aeabcaee 2018-03-09 stsp /* SHA1 of corresponding blob in repository. */
42 aeabcaee 2018-03-09 stsp uint8_t blob_sha1[SHA1_DIGEST_LENGTH];
43 aeabcaee 2018-03-09 stsp
44 aeabcaee 2018-03-09 stsp uint32_t flags;
45 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_PATH_LEN 0x00000fff
46 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_STAGE 0x00003000
47 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_EXTENDED 0x00004000
48 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_F_ASSUME_VALID 0x00008000
49 aeabcaee 2018-03-09 stsp
50 aeabcaee 2018-03-09 stsp /*
51 aeabcaee 2018-03-09 stsp * UNIX-style path, relative to work tree root.
52 422a2f50 2018-03-09 stsp * Variable length, and NUL-padded to a multiple of 8 on disk.
53 aeabcaee 2018-03-09 stsp */
54 aeabcaee 2018-03-09 stsp const char *path;
55 aeabcaee 2018-03-09 stsp };
56 aeabcaee 2018-03-09 stsp
57 d0b44960 2018-03-09 stsp /* "Stages" of a file afflicted by a 3-way merge conflict. */
58 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_MERGED 0
59 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_ANCESTOR 1
60 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_OURS 2
61 aeabcaee 2018-03-09 stsp #define GOT_INDEX_ENTRY_STAGE_THEIRS 3
62 aeabcaee 2018-03-09 stsp
63 aeabcaee 2018-03-09 stsp /* On-disk file index header structure. */
64 aeabcaee 2018-03-09 stsp struct got_file_index_hdr {
65 aeabcaee 2018-03-09 stsp uint32_t signature; /* big-endian on disk */
66 aeabcaee 2018-03-09 stsp uint32_t version; /* big-endian on disk */
67 aeabcaee 2018-03-09 stsp uint32_t nentries; /* big-endian on disk */
68 c8988c68 2018-03-09 stsp TAILQ_HEAD(, got_file_index_entry) entries;
69 6bb30d9a 2018-03-09 stsp uint8_t sha1[SHA1_DIGEST_LENGTH]; /* checksum of above on-disk data */
70 aeabcaee 2018-03-09 stsp };