Blame


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