Blame


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