Blame


1 86c3caaf 2018-03-09 stsp /*
2 86c3caaf 2018-03-09 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 86c3caaf 2018-03-09 stsp *
4 86c3caaf 2018-03-09 stsp * Permission to use, copy, modify, and distribute this software for any
5 86c3caaf 2018-03-09 stsp * purpose with or without fee is hereby granted, provided that the above
6 86c3caaf 2018-03-09 stsp * copyright notice and this permission notice appear in all copies.
7 86c3caaf 2018-03-09 stsp *
8 86c3caaf 2018-03-09 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 86c3caaf 2018-03-09 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 86c3caaf 2018-03-09 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 86c3caaf 2018-03-09 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 86c3caaf 2018-03-09 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 86c3caaf 2018-03-09 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 86c3caaf 2018-03-09 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 86c3caaf 2018-03-09 stsp */
16 86c3caaf 2018-03-09 stsp
17 86c3caaf 2018-03-09 stsp struct got_worktree {
18 86c3caaf 2018-03-09 stsp char *path_worktree_root;
19 86c3caaf 2018-03-09 stsp char *path_repo;
20 577ec78f 2018-03-11 stsp char *path_prefix;
21 f5baf295 2018-03-11 stsp char *base_commit;
22 6d9d28c3 2018-03-11 stsp
23 6d9d28c3 2018-03-11 stsp /*
24 056e7441 2018-03-11 stsp * File descriptor for the lock file, open while a work tree is open.
25 056e7441 2018-03-11 stsp * When a work tree is opened, a shared lock on the lock file is
26 58ecc593 2018-03-11 stsp * acquired with flock(2). This shared lock is held until the work
27 58ecc593 2018-03-11 stsp * tree is closed, i.e. throughout the lifetime of any operation
28 58ecc593 2018-03-11 stsp * which uses a work tree.
29 056e7441 2018-03-11 stsp * Before any modifications are made to the on-disk state of work
30 056e7441 2018-03-11 stsp * tree meta data, tracked files, or directory tree structure, this
31 056e7441 2018-03-11 stsp * shared lock must be upgraded to an exclusive lock.
32 6d9d28c3 2018-03-11 stsp */
33 056e7441 2018-03-11 stsp int lockfd;
34 86c3caaf 2018-03-09 stsp };
35 86c3caaf 2018-03-09 stsp
36 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_GOT_DIR ".got"
37 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_FILE_INDEX "fileindex"
38 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_REPOSITORY "repository"
39 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_PATH_PREFIX "path-prefix"
40 e350ead3 2018-03-11 stsp #define GOT_WORKTREE_BASE_COMMIT "base-commit"
41 fdf001a7 2018-03-11 stsp #define GOT_WORKTREE_HEAD "head"
42 056e7441 2018-03-11 stsp #define GOT_WORKTREE_LOCK "lock"
43 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_FORMAT "format"
44 1451e70d 2018-03-10 stsp
45 1451e70d 2018-03-10 stsp #define GOT_WORKTREE_FORMAT_VERSION 1
46 65e3b818 2018-03-11 stsp #define GOT_WORKTREE_INVALID_COMMIT_ID GOT_SHA1_STRING_ZERO