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 50b0790e 2020-09-11 stsp
37 50b0790e 2020-09-11 stsp /* Absolute path to worktree's got.conf file. */
38 50b0790e 2020-09-11 stsp char *gotconfig_path;
39 50b0790e 2020-09-11 stsp
40 50b0790e 2020-09-11 stsp /* Settings read from got.conf. */
41 50b0790e 2020-09-11 stsp struct got_gotconfig *gotconfig;
42 718b3ab0 2018-03-17 stsp };
43 718b3ab0 2018-03-17 stsp
44 8656d6c4 2019-05-20 stsp struct got_commitable {
45 8656d6c4 2019-05-20 stsp char *path;
46 8656d6c4 2019-05-20 stsp char *in_repo_path;
47 8656d6c4 2019-05-20 stsp char *ondisk_path;
48 8656d6c4 2019-05-20 stsp unsigned char status;
49 f0b75401 2019-08-03 stsp unsigned char staged_status;
50 8656d6c4 2019-05-20 stsp struct got_object_id *blob_id;
51 8656d6c4 2019-05-20 stsp struct got_object_id *base_blob_id;
52 f0b75401 2019-08-03 stsp struct got_object_id *staged_blob_id;
53 8656d6c4 2019-05-20 stsp struct got_object_id *base_commit_id;
54 8656d6c4 2019-05-20 stsp mode_t mode;
55 8656d6c4 2019-05-20 stsp int flags;
56 8656d6c4 2019-05-20 stsp #define GOT_COMMITABLE_ADDED 0x01
57 8656d6c4 2019-05-20 stsp };
58 8656d6c4 2019-05-20 stsp
59 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_GOT_DIR ".got"
60 0f92850e 2018-12-25 stsp #define GOT_WORKTREE_FILE_INDEX "file-index"
61 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_REPOSITORY "repository"
62 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_PATH_PREFIX "path-prefix"
63 0f92850e 2018-12-25 stsp #define GOT_WORKTREE_HEAD_REF "head-ref"
64 0f92850e 2018-12-25 stsp #define GOT_WORKTREE_BASE_COMMIT "base-commit"
65 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_LOCK "lock"
66 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_FORMAT "format"
67 ec22038e 2019-03-10 stsp #define GOT_WORKTREE_UUID "uuid"
68 c3022ba5 2019-07-27 stsp #define GOT_WORKTREE_HISTEDIT_SCRIPT "histedit-script"
69 718b3ab0 2018-03-17 stsp
70 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_FORMAT_VERSION 1
71 718b3ab0 2018-03-17 stsp #define GOT_WORKTREE_INVALID_COMMIT_ID GOT_SHA1_STRING_ZERO
72 0cd1c46a 2019-03-11 stsp
73 1ab61ced 2019-07-10 stsp #define GOT_WORKTREE_BASE_REF_PREFIX "refs/got/worktree/base"
74 517bab73 2019-03-11 stsp
75 517bab73 2019-03-11 stsp const struct got_error *got_worktree_get_base_ref_name(char **,
76 517bab73 2019-03-11 stsp struct got_worktree *worktree);
77 818c7501 2019-07-11 stsp
78 818c7501 2019-07-11 stsp /* Temporary branch which accumulates commits during a rebase operation. */
79 818c7501 2019-07-11 stsp #define GOT_WORKTREE_REBASE_TMP_REF_PREFIX "refs/got/worktree/rebase/tmp"
80 818c7501 2019-07-11 stsp
81 818c7501 2019-07-11 stsp /* Symbolic reference pointing at the name of the new base branch. */
82 818c7501 2019-07-11 stsp #define GOT_WORKTREE_NEWBASE_REF_PREFIX "refs/got/worktree/rebase/newbase"
83 818c7501 2019-07-11 stsp
84 818c7501 2019-07-11 stsp /* Symbolic reference pointing at the name of the branch being rebased. */
85 818c7501 2019-07-11 stsp #define GOT_WORKTREE_REBASE_BRANCH_REF_PREFIX "refs/got/worktree/rebase/branch"
86 818c7501 2019-07-11 stsp
87 818c7501 2019-07-11 stsp /* Reference pointing at the ID of the current commit being rebased. */
88 818c7501 2019-07-11 stsp #define GOT_WORKTREE_REBASE_COMMIT_REF_PREFIX "refs/got/worktree/rebase/commit"
89 0ebf8283 2019-07-24 stsp
90 0ebf8283 2019-07-24 stsp /* Temporary branch which accumulates commits during a histedit operation. */
91 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_TMP_REF_PREFIX "refs/got/worktree/histedit/tmp"
92 0ebf8283 2019-07-24 stsp
93 0ebf8283 2019-07-24 stsp /* Symbolic reference pointing at the name of the branch being edited. */
94 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_BRANCH_REF_PREFIX \
95 0ebf8283 2019-07-24 stsp "refs/got/worktree/histedit/branch"
96 0ebf8283 2019-07-24 stsp
97 0ebf8283 2019-07-24 stsp /* Reference pointing at the ID of the work tree's pre-edit base commit. */
98 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_BASE_COMMIT_REF_PREFIX \
99 0ebf8283 2019-07-24 stsp "refs/got/worktree/histedit/base-commit"
100 0ebf8283 2019-07-24 stsp
101 0ebf8283 2019-07-24 stsp /* Reference pointing at the ID of the current commit being edited. */
102 0ebf8283 2019-07-24 stsp #define GOT_WORKTREE_HISTEDIT_COMMIT_REF_PREFIX \
103 0ebf8283 2019-07-24 stsp "refs/got/worktree/histedit/commit"