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 c88eb298 2018-03-11 stsp char *root_path;
19 cde76477 2018-03-11 stsp char *repo_path;
20 577ec78f 2018-03-11 stsp char *path_prefix;
21 f5baf295 2018-03-11 stsp char *base_commit;
22 e8f36958 2018-03-11 stsp char *head_ref;
23 6d9d28c3 2018-03-11 stsp
24 6d9d28c3 2018-03-11 stsp /*
25 056e7441 2018-03-11 stsp * File descriptor for the lock file, open while a work tree is open.
26 056e7441 2018-03-11 stsp * When a work tree is opened, a shared lock on the lock file is
27 58ecc593 2018-03-11 stsp * acquired with flock(2). This shared lock is held until the work
28 58ecc593 2018-03-11 stsp * tree is closed, i.e. throughout the lifetime of any operation
29 58ecc593 2018-03-11 stsp * which uses a work tree.
30 056e7441 2018-03-11 stsp * Before any modifications are made to the on-disk state of work
31 056e7441 2018-03-11 stsp * tree meta data, tracked files, or directory tree structure, this
32 056e7441 2018-03-11 stsp * shared lock must be upgraded to an exclusive lock.
33 6d9d28c3 2018-03-11 stsp */
34 056e7441 2018-03-11 stsp int lockfd;
35 86c3caaf 2018-03-09 stsp };
36 86c3caaf 2018-03-09 stsp
37 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_GOT_DIR ".got"
38 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_FILE_INDEX "fileindex"
39 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_REPOSITORY "repository"
40 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_PATH_PREFIX "path-prefix"
41 e350ead3 2018-03-11 stsp #define GOT_WORKTREE_BASE_COMMIT "base-commit"
42 fdf001a7 2018-03-11 stsp #define GOT_WORKTREE_HEAD "head"
43 056e7441 2018-03-11 stsp #define GOT_WORKTREE_LOCK "lock"
44 577ec78f 2018-03-11 stsp #define GOT_WORKTREE_FORMAT "format"
45 1451e70d 2018-03-10 stsp
46 1451e70d 2018-03-10 stsp #define GOT_WORKTREE_FORMAT_VERSION 1
47 65e3b818 2018-03-11 stsp #define GOT_WORKTREE_INVALID_COMMIT_ID GOT_SHA1_STRING_ZERO