Blame


1 718b3ab0 2018-03-17 stsp /*
2 718b3ab0 2018-03-17 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 718b3ab0 2018-03-17 stsp *
4 718b3ab0 2018-03-17 stsp * Permission to use, copy, modify, and distribute this software for any
5 718b3ab0 2018-03-17 stsp * purpose with or without fee is hereby granted, provided that the above
6 718b3ab0 2018-03-17 stsp * copyright notice and this permission notice appear in all copies.
7 718b3ab0 2018-03-17 stsp *
8 718b3ab0 2018-03-17 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 718b3ab0 2018-03-17 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 718b3ab0 2018-03-17 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 718b3ab0 2018-03-17 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 718b3ab0 2018-03-17 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 718b3ab0 2018-03-17 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 718b3ab0 2018-03-17 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 718b3ab0 2018-03-17 stsp */
16 718b3ab0 2018-03-17 stsp
17 718b3ab0 2018-03-17 stsp struct got_worktree {
18 718b3ab0 2018-03-17 stsp char *root_path;
19 718b3ab0 2018-03-17 stsp char *repo_path;
20 718b3ab0 2018-03-17 stsp char *path_prefix;
21 eaccb85f 2018-12-25 stsp struct got_object_id *base_commit_id;
22 36a38700 2019-05-10 stsp char *head_ref_name;
23 c442a90d 2019-03-10 stsp uuid_t uuid;
24 718b3ab0 2018-03-17 stsp
25 718b3ab0 2018-03-17 stsp /*
26 718b3ab0 2018-03-17 stsp * File descriptor for the lock file, open while a work tree is open.
27 718b3ab0 2018-03-17 stsp * When a work tree is opened, a shared lock on the lock file is
28 718b3ab0 2018-03-17 stsp * acquired with flock(2). This shared lock is held until the work
29 718b3ab0 2018-03-17 stsp * tree is closed, i.e. throughout the lifetime of any operation
30 718b3ab0 2018-03-17 stsp * which uses a work tree.
31 718b3ab0 2018-03-17 stsp * Before any modifications are made to the on-disk state of work
32 718b3ab0 2018-03-17 stsp * tree meta data, tracked files, or directory tree structure, this
33 718b3ab0 2018-03-17 stsp * shared lock must be upgraded to an exclusive lock.
34 718b3ab0 2018-03-17 stsp */
35 718b3ab0 2018-03-17 stsp int lockfd;
36 718b3ab0 2018-03-17 stsp };
37 718b3ab0 2018-03-17 stsp
38 8656d6c4 2019-05-20 stsp struct got_commitable {
39 8656d6c4 2019-05-20 stsp char *path;
40 8656d6c4 2019-05-20 stsp char *in_repo_path;
41 8656d6c4 2019-05-20 stsp char *ondisk_path;
42 8656d6c4 2019-05-20 stsp unsigned char status;
43 8656d6c4 2019-05-20 stsp struct got_object_id *blob_id;
44 8656d6c4 2019-05-20 stsp struct got_object_id *base_blob_id;
45 8656d6c4 2019-05-20 stsp struct got_object_id *base_commit_id;
46 8656d6c4 2019-05-20 stsp mode_t mode;
47 8656d6c4 2019-05-20 stsp int flags;
48 8656d6c4 2019-05-20 stsp #define GOT_COMMITABLE_ADDED 0x01
49 8656d6c4 2019-05-20 stsp };
50 8656d6c4 2019-05-20 stsp
51 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_GOT_DIR ".got"
52 0f92850e 2018-12-25 stsp #define GOT_WORKTREE_FILE_INDEX "file-index"
53 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_REPOSITORY "repository"
54 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_PATH_PREFIX "path-prefix"
55 0f92850e 2018-12-25 stsp #define GOT_WORKTREE_HEAD_REF "head-ref"
56 0f92850e 2018-12-25 stsp #define GOT_WORKTREE_BASE_COMMIT "base-commit"
57 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_LOCK "lock"
58 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_FORMAT "format"
59 ec22038e 2019-03-10 stsp #define GOT_WORKTREE_UUID "uuid"
60 c3022ba5 2019-07-27 stsp #define GOT_WORKTREE_HISTEDIT_SCRIPT "histedit-script"
61 718b3ab0 2018-03-17 stsp
62 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_FORMAT_VERSION 1
63 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_INVALID_COMMIT_ID GOT_SHA1_STRING_ZERO
64 0cd1c46a 2019-03-11 stsp
65 1ab61ced 2019-07-10 stsp #define GOT_WORKTREE_BASE_REF_PREFIX "refs/got/worktree/base"
66 517bab73 2019-03-11 stsp
67 517bab73 2019-03-11 stsp const struct got_error *got_worktree_get_base_ref_name(char **,
68 517bab73 2019-03-11 stsp struct got_worktree *worktree);
69 818c7501 2019-07-11 stsp
70 818c7501 2019-07-11 stsp /* Temporary branch which accumulates commits during a rebase operation. */
71 818c7501 2019-07-11 stsp #define GOT_WORKTREE_REBASE_TMP_REF_PREFIX "refs/got/worktree/rebase/tmp"
72 818c7501 2019-07-11 stsp
73 818c7501 2019-07-11 stsp /* Symbolic reference pointing at the name of the new base branch. */
74 818c7501 2019-07-11 stsp #define GOT_WORKTREE_NEWBASE_REF_PREFIX "refs/got/worktree/rebase/newbase"
75 818c7501 2019-07-11 stsp
76 818c7501 2019-07-11 stsp /* Symbolic reference pointing at the name of the branch being rebased. */
77 818c7501 2019-07-11 stsp #define GOT_WORKTREE_REBASE_BRANCH_REF_PREFIX "refs/got/worktree/rebase/branch"
78 818c7501 2019-07-11 stsp
79 818c7501 2019-07-11 stsp /* Reference pointing at the ID of the current commit being rebased. */
80 818c7501 2019-07-11 stsp #define GOT_WORKTREE_REBASE_COMMIT_REF_PREFIX "refs/got/worktree/rebase/commit"
81 0ebf8283 2019-07-24 stsp
82 0ebf8283 2019-07-24 stsp /* Temporary branch which accumulates commits during a histedit operation. */
83 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_TMP_REF_PREFIX "refs/got/worktree/histedit/tmp"
84 0ebf8283 2019-07-24 stsp
85 0ebf8283 2019-07-24 stsp /* Symbolic reference pointing at the name of the branch being edited. */
86 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_BRANCH_REF_PREFIX \
87 0ebf8283 2019-07-24 stsp "refs/got/worktree/histedit/branch"
88 0ebf8283 2019-07-24 stsp
89 0ebf8283 2019-07-24 stsp /* Reference pointing at the ID of the work tree's pre-edit base commit. */
90 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_BASE_COMMIT_REF_PREFIX \
91 0ebf8283 2019-07-24 stsp "refs/got/worktree/histedit/base-commit"
92 0ebf8283 2019-07-24 stsp
93 0ebf8283 2019-07-24 stsp /* Reference pointing at the ID of the current commit being edited. */
94 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_COMMIT_REF_PREFIX \
95 0ebf8283 2019-07-24 stsp "refs/got/worktree/histedit/commit"