Blob


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