Blame


1 86c3caaf 2018-03-09 stsp /*
2 5d56da81 2019-01-13 stsp * Copyright (c) 2018, 2019 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 8656d6c4 2019-05-20 stsp struct got_commitable;
19 818c7501 2019-07-11 stsp struct got_commit_object;
20 3e3a69f1 2019-07-25 stsp struct got_fileindex;
21 86c3caaf 2018-03-09 stsp
22 eecfbcd1 2018-12-29 stsp /* status codes */
23 f8d1f275 2019-02-04 stsp #define GOT_STATUS_NO_CHANGE ' '
24 eecfbcd1 2018-12-29 stsp #define GOT_STATUS_ADD 'A'
25 eecfbcd1 2018-12-29 stsp #define GOT_STATUS_EXISTS 'E'
26 507dc3bb 2018-12-29 stsp #define GOT_STATUS_UPDATE 'U'
27 512f0d0e 2019-01-02 stsp #define GOT_STATUS_DELETE 'D'
28 276262e8 2019-02-08 stsp #define GOT_STATUS_MODIFY 'M'
29 1ebedb77 2019-10-19 stsp #define GOT_STATUS_MODE_CHANGE 'm'
30 6353ad76 2019-02-08 stsp #define GOT_STATUS_CONFLICT 'C'
31 6353ad76 2019-02-08 stsp #define GOT_STATUS_MERGE 'G'
32 f8d1f275 2019-02-04 stsp #define GOT_STATUS_MISSING '!'
33 f8d1f275 2019-02-04 stsp #define GOT_STATUS_UNVERSIONED '?'
34 0dbc2271 2019-02-05 stsp #define GOT_STATUS_OBSTRUCTED '~'
35 2a06fe5f 2019-08-24 stsp #define GOT_STATUS_NONEXISTENT 'N'
36 a129376b 2019-03-28 stsp #define GOT_STATUS_REVERT 'R'
37 2b92fad7 2019-06-02 stsp #define GOT_STATUS_CANNOT_DELETE 'd'
38 a484d721 2019-06-10 stsp #define GOT_STATUS_BUMP_BASE 'b'
39 7f47418f 2019-12-20 stsp #define GOT_STATUS_BASE_REF_ERR 'B'
40 5036ab18 2020-04-18 stsp #define GOT_STATUS_CANNOT_UPDATE '#'
41 eecfbcd1 2018-12-29 stsp
42 df6221c7 2023-07-19 stsp /* Also defined in got_lib_worktree.h in case got_worktree.h is not included. */
43 df6221c7 2023-07-19 stsp #define GOT_WORKTREE_GOT_DIR ".got"
44 df6221c7 2023-07-19 stsp #define GOT_WORKTREE_CVG_DIR ".cvg"
45 df6221c7 2023-07-19 stsp
46 0c60ce5a 2018-04-02 stsp /*
47 0c60ce5a 2018-04-02 stsp * Attempt to initialize a new work tree on disk.
48 0c60ce5a 2018-04-02 stsp * The first argument is the path to a directory where the work tree
49 0c60ce5a 2018-04-02 stsp * will be created. The path itself must not yet exist, but the dirname(3)
50 0c60ce5a 2018-04-02 stsp * of the path must already exist.
51 93a30277 2018-12-24 stsp * The reference provided will be used to determine the new worktree's
52 93a30277 2018-12-24 stsp * base commit. The third argument speficies the work tree's path prefix.
53 df6221c7 2023-07-19 stsp * The fourth argument specifies the meta data directory to use, which
54 df6221c7 2023-07-19 stsp * should be either GOT_WORKTREE_GOT_DIR or GOT_WORKTREE_CVG_DIR.
55 0c60ce5a 2018-04-02 stsp */
56 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_init(const char *, struct got_reference *,
57 df6221c7 2023-07-19 stsp const char *, const char *, struct got_repository *);
58 0c60ce5a 2018-04-02 stsp
59 0c60ce5a 2018-04-02 stsp /*
60 df6221c7 2023-07-19 stsp * Attempt to open a worktree at or above the specified path, using
61 df6221c7 2023-07-19 stsp * the specified meta data directory which should be either be NULL
62 df6221c7 2023-07-19 stsp * in which case a meta directory is auto-discovered, or be one of
63 df6221c7 2023-07-19 stsp * GOT_WORKTREE_GOT_DIR and GOT_WORKTREE_CVG_DIR.
64 0c60ce5a 2018-04-02 stsp * The caller must dispose of it with got_worktree_close().
65 0c60ce5a 2018-04-02 stsp */
66 df6221c7 2023-07-19 stsp const struct got_error *got_worktree_open(struct got_worktree **,
67 df6221c7 2023-07-19 stsp const char *path, const char *meta_dir);
68 0c60ce5a 2018-04-02 stsp
69 0c60ce5a 2018-04-02 stsp /* Dispose of an open work tree. */
70 3a6ce05a 2019-02-11 stsp const struct got_error *got_worktree_close(struct got_worktree *);
71 0c60ce5a 2018-04-02 stsp
72 0c60ce5a 2018-04-02 stsp /*
73 c7f4312f 2019-02-05 stsp * Get the path to the root directory of a worktree.
74 c7f4312f 2019-02-05 stsp */
75 c7f4312f 2019-02-05 stsp const char *got_worktree_get_root_path(struct got_worktree *);
76 c7f4312f 2019-02-05 stsp
77 c7f4312f 2019-02-05 stsp /*
78 0c60ce5a 2018-04-02 stsp * Get the path to the repository associated with a worktree.
79 0c60ce5a 2018-04-02 stsp */
80 2fbdb5ae 2018-12-29 stsp const char *got_worktree_get_repo_path(struct got_worktree *);
81 0c60ce5a 2018-04-02 stsp
82 0c60ce5a 2018-04-02 stsp /*
83 49520a32 2018-12-29 stsp * Get the path prefix associated with a worktree.
84 49520a32 2018-12-29 stsp */
85 49520a32 2018-12-29 stsp const char *got_worktree_get_path_prefix(struct got_worktree *);
86 b2118c49 2020-07-28 stsp
87 b2118c49 2020-07-28 stsp /*
88 b2118c49 2020-07-28 stsp * Get the UUID of a work tree as a string.
89 b2118c49 2020-07-28 stsp * The caller must dispose of the returned UUID string with free(3).
90 b2118c49 2020-07-28 stsp */
91 b2118c49 2020-07-28 stsp const struct got_error *got_worktree_get_uuid(char **, struct got_worktree *);
92 49520a32 2018-12-29 stsp
93 49520a32 2018-12-29 stsp /*
94 e5dc7198 2018-12-29 stsp * Check if a user-provided path prefix matches that of the worktree.
95 e5dc7198 2018-12-29 stsp */
96 e5dc7198 2018-12-29 stsp const struct got_error *got_worktree_match_path_prefix(int *,
97 e5dc7198 2018-12-29 stsp struct got_worktree *, const char *);
98 e5dc7198 2018-12-29 stsp
99 e5dc7198 2018-12-29 stsp /*
100 9587e6cc 2023-01-28 mark * Prefix for references pointing at base commit of backout/cherrypick commits.
101 9587e6cc 2023-01-28 mark * Reference path takes the form: PREFIX-WORKTREE_UUID-COMMIT_ID
102 9587e6cc 2023-01-28 mark */
103 9587e6cc 2023-01-28 mark #define GOT_WORKTREE_CHERRYPICK_REF_PREFIX "refs/got/worktree/cherrypick"
104 9587e6cc 2023-01-28 mark #define GOT_WORKTREE_BACKOUT_REF_PREFIX "refs/got/worktree/backout"
105 9587e6cc 2023-01-28 mark
106 9587e6cc 2023-01-28 mark #define GOT_WORKTREE_CHERRYPICK_REF_PREFIX_LEN \
107 9587e6cc 2023-01-28 mark sizeof(GOT_WORKTREE_CHERRYPICK_REF_PREFIX) - 1
108 9587e6cc 2023-01-28 mark #define GOT_WORKTREE_BACKOUT_REF_PREFIX_LEN \
109 9587e6cc 2023-01-28 mark sizeof(GOT_WORKTREE_BACKOUT_REF_PREFIX) - 1
110 9587e6cc 2023-01-28 mark #define GOT_WORKTREE_UUID_STRLEN 36
111 9587e6cc 2023-01-28 mark
112 9587e6cc 2023-01-28 mark const struct got_error *got_worktree_get_logmsg_ref_name(char **,
113 9587e6cc 2023-01-28 mark struct got_worktree *, const char *);
114 9587e6cc 2023-01-28 mark /*
115 0c60ce5a 2018-04-02 stsp * Get the name of a work tree's HEAD reference.
116 0c60ce5a 2018-04-02 stsp */
117 bc70eb79 2019-05-09 stsp const char *got_worktree_get_head_ref_name(struct got_worktree *);
118 0c60ce5a 2018-04-02 stsp
119 507dc3bb 2018-12-29 stsp /*
120 024e9686 2019-05-14 stsp * Set the branch head reference of the work tree.
121 024e9686 2019-05-14 stsp */
122 024e9686 2019-05-14 stsp const struct got_error *got_worktree_set_head_ref(struct got_worktree *,
123 024e9686 2019-05-14 stsp struct got_reference *);
124 024e9686 2019-05-14 stsp
125 024e9686 2019-05-14 stsp /*
126 507dc3bb 2018-12-29 stsp * Get the current base commit ID of a worktree.
127 507dc3bb 2018-12-29 stsp */
128 b72f483a 2019-02-05 stsp struct got_object_id *got_worktree_get_base_commit_id(struct got_worktree *);
129 507dc3bb 2018-12-29 stsp
130 507dc3bb 2018-12-29 stsp /*
131 507dc3bb 2018-12-29 stsp * Set the base commit Id of a worktree.
132 507dc3bb 2018-12-29 stsp */
133 507dc3bb 2018-12-29 stsp const struct got_error *got_worktree_set_base_commit_id(struct got_worktree *,
134 507dc3bb 2018-12-29 stsp struct got_repository *, struct got_object_id *);
135 c935fd51 2023-07-23 mark
136 c935fd51 2023-07-23 mark /*
137 c935fd51 2023-07-23 mark * Get the state of the work tree. If the work tree's global base commit is
138 c935fd51 2023-07-23 mark * the tip of the work tree's current branch, and each file in the index is
139 c935fd51 2023-07-23 mark * based on this same commit, the char out parameter will be
140 99301cec 2023-07-24 stsp * GOT_WORKTREE_STATE_UPTODATE, else it will be GOT_WORKTREE_STATE_OUTOFDATE.
141 c935fd51 2023-07-23 mark */
142 c935fd51 2023-07-23 mark const struct got_error *got_worktree_get_state(char *,
143 cdbfe5d2 2023-07-24 stsp struct got_repository *, struct got_worktree *,
144 cdbfe5d2 2023-07-24 stsp got_cancel_cb, void *);
145 50b0790e 2020-09-11 stsp
146 99301cec 2023-07-24 stsp #define GOT_WORKTREE_STATE_UNKNOWN ' '
147 99301cec 2023-07-24 stsp #define GOT_WORKTREE_STATE_UPTODATE '*'
148 99301cec 2023-07-24 stsp #define GOT_WORKTREE_STATE_OUTOFDATE '~'
149 c935fd51 2023-07-23 mark
150 50b0790e 2020-09-11 stsp /*
151 50b0790e 2020-09-11 stsp * Obtain a parsed representation of this worktree's got.conf file.
152 50b0790e 2020-09-11 stsp * Return NULL if this configuration file could not be read.
153 50b0790e 2020-09-11 stsp */
154 50b0790e 2020-09-11 stsp const struct got_gotconfig *got_worktree_get_gotconfig(struct got_worktree *);
155 507dc3bb 2018-12-29 stsp
156 0c60ce5a 2018-04-02 stsp /* A callback function which is invoked when a path is checked out. */
157 1ee397ad 2019-07-12 stsp typedef const struct got_error *(*got_worktree_checkout_cb)(void *,
158 1ee397ad 2019-07-12 stsp unsigned char, const char *);
159 f2a9dc41 2019-12-13 tracey
160 f2a9dc41 2019-12-13 tracey /* A callback function which is invoked when a path is removed. */
161 f2a9dc41 2019-12-13 tracey typedef const struct got_error *(*got_worktree_delete_cb)(void *,
162 f2a9dc41 2019-12-13 tracey unsigned char, unsigned char, const char *);
163 0c60ce5a 2018-04-02 stsp
164 0c60ce5a 2018-04-02 stsp /*
165 0c60ce5a 2018-04-02 stsp * Attempt to check out files into a work tree from its associated repository
166 0c60ce5a 2018-04-02 stsp * and path prefix, and update the work tree's file index accordingly.
167 0c60ce5a 2018-04-02 stsp * File content is obtained from blobs within the work tree's path prefix
168 93a30277 2018-12-24 stsp * inside the tree corresponding to the work tree's base commit.
169 0c60ce5a 2018-04-02 stsp * The checkout progress callback will be invoked with the provided
170 0c60ce5a 2018-04-02 stsp * void * argument, and the path of each checked out file.
171 c4cdcb68 2019-04-03 stsp *
172 f2ea84fa 2019-07-27 stsp * It is possible to restrict the checkout operation to specific paths in
173 f2ea84fa 2019-07-27 stsp * the work tree, in which case all files outside those paths will remain at
174 c4cdcb68 2019-04-03 stsp * their currently recorded base commit. Inconsistent base commits can be
175 c4cdcb68 2019-04-03 stsp * repaired later by running another update operation across the entire work
176 c4cdcb68 2019-04-03 stsp * tree. Inconsistent base-commits may also occur if this function runs into
177 c4cdcb68 2019-04-03 stsp * an error or if the checkout operation is cancelled by the cancel callback.
178 f2ea84fa 2019-07-27 stsp * Allspecified paths are relative to the work tree's root. Pass a pathlist
179 f2ea84fa 2019-07-27 stsp * with a single empty path "" to check out files across the entire work tree.
180 c4cdcb68 2019-04-03 stsp *
181 c4cdcb68 2019-04-03 stsp * Some operations may refuse to run while the work tree contains files from
182 c4cdcb68 2019-04-03 stsp * multiple base commits.
183 0c60ce5a 2018-04-02 stsp */
184 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_checkout_files(struct got_worktree *,
185 f2ea84fa 2019-07-27 stsp struct got_pathlist_head *, struct got_repository *,
186 e6209546 2019-08-22 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
187 507dc3bb 2018-12-29 stsp
188 234035bc 2019-06-01 stsp /* Merge the differences between two commits into a work tree. */
189 234035bc 2019-06-01 stsp const struct got_error *
190 234035bc 2019-06-01 stsp got_worktree_merge_files(struct got_worktree *,
191 234035bc 2019-06-01 stsp struct got_object_id *, struct got_object_id *,
192 234035bc 2019-06-01 stsp struct got_repository *, got_worktree_checkout_cb, void *,
193 e6209546 2019-08-22 stsp got_cancel_cb, void *);
194 234035bc 2019-06-01 stsp
195 12463d8b 2019-12-13 stsp /*
196 12463d8b 2019-12-13 stsp * A callback function which is invoked to report a file's status.
197 12463d8b 2019-12-13 stsp *
198 12463d8b 2019-12-13 stsp * If a valid directory file descriptor and a directory entry name are passed,
199 12463d8b 2019-12-13 stsp * these should be used to open the file instead of opening the file by path.
200 12463d8b 2019-12-13 stsp * This prevents race conditions if the filesystem is modified concurrently.
201 12463d8b 2019-12-13 stsp * If the directory descriptor is not available then its value will be -1.
202 12463d8b 2019-12-13 stsp */
203 b72f483a 2019-02-05 stsp typedef const struct got_error *(*got_worktree_status_cb)(void *,
204 88d0e355 2019-08-03 stsp unsigned char, unsigned char, const char *, struct got_object_id *,
205 12463d8b 2019-12-13 stsp struct got_object_id *, struct got_object_id *, int, const char *);
206 f8d1f275 2019-02-04 stsp
207 f8d1f275 2019-02-04 stsp /*
208 f8d1f275 2019-02-04 stsp * Report the status of paths in the work tree.
209 f8d1f275 2019-02-04 stsp * The status callback will be invoked with the provided void * argument,
210 f8d1f275 2019-02-04 stsp * a path, and a corresponding status code.
211 f8d1f275 2019-02-04 stsp */
212 6c34b1aa 2019-03-18 stsp const struct got_error *got_worktree_status(struct got_worktree *,
213 f6343036 2021-06-22 stsp struct got_pathlist_head *, struct got_repository *, int no_ignores,
214 e6209546 2019-08-22 stsp got_worktree_status_cb, void *, got_cancel_cb cancel_cb, void *);
215 6c7ab921 2019-03-18 stsp
216 6c7ab921 2019-03-18 stsp /*
217 6c7ab921 2019-03-18 stsp * Try to resolve a user-provided path to an on-disk path in the work tree.
218 6c7ab921 2019-03-18 stsp * The caller must dispose of the resolved path with free(3).
219 6c7ab921 2019-03-18 stsp */
220 6c7ab921 2019-03-18 stsp const struct got_error *got_worktree_resolve_path(char **,
221 6c7ab921 2019-03-18 stsp struct got_worktree *, const char *);
222 d00136be 2019-03-26 stsp
223 1dd54920 2019-05-11 stsp /* Schedule files at on-disk paths for addition in the next commit. */
224 031a5338 2019-03-26 stsp const struct got_error *got_worktree_schedule_add(struct got_worktree *,
225 4e68cba3 2019-11-23 stsp struct got_pathlist_head *, got_worktree_checkout_cb, void *,
226 022fae89 2019-12-06 tracey struct got_repository *, int);
227 2ec1f75b 2019-03-26 stsp
228 2ec1f75b 2019-03-26 stsp /*
229 17ed4618 2019-06-02 stsp * Remove files from disk and schedule them to be deleted in the next commit.
230 2ec1f75b 2019-03-26 stsp * Don't allow deleting files with uncommitted modifications, unless the
231 2ec1f75b 2019-03-26 stsp * parameter 'delete_local_mods' is set.
232 2ec1f75b 2019-03-26 stsp */
233 2ec1f75b 2019-03-26 stsp const struct got_error *
234 17ed4618 2019-06-02 stsp got_worktree_schedule_delete(struct got_worktree *,
235 766841c2 2020-08-13 stsp struct got_pathlist_head *, int, const char *,
236 4e12cd97 2022-01-25 stsp got_worktree_delete_cb, void *, struct got_repository *, int, int);
237 a129376b 2019-03-28 stsp
238 33aa809d 2019-08-08 stsp /* A callback function which is used to select or reject a patch. */
239 33aa809d 2019-08-08 stsp typedef const struct got_error *(*got_worktree_patch_cb)(int *, void *,
240 33aa809d 2019-08-08 stsp unsigned char, const char *, FILE *, int, int);
241 33aa809d 2019-08-08 stsp
242 33aa809d 2019-08-08 stsp /* Values for result output parameter of got_wortree_patch_cb. */
243 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_NONE 0
244 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_YES 1
245 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_NO 2
246 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_QUIT 3
247 33aa809d 2019-08-08 stsp
248 a129376b 2019-03-28 stsp /*
249 a129376b 2019-03-28 stsp * Revert a file at the specified path such that it matches its
250 a129376b 2019-03-28 stsp * original state in the worktree's base commit.
251 33aa809d 2019-08-08 stsp * If the patch callback is not NULL, call it to select patch hunks to
252 33aa809d 2019-08-08 stsp * revert. Otherwise, revert the whole file found at each path.
253 a129376b 2019-03-28 stsp */
254 a129376b 2019-03-28 stsp const struct got_error *got_worktree_revert(struct got_worktree *,
255 e20a8b6f 2019-06-04 stsp struct got_pathlist_head *, got_worktree_checkout_cb, void *,
256 33aa809d 2019-08-08 stsp got_worktree_patch_cb patch_cb, void *patch_arg,
257 e20a8b6f 2019-06-04 stsp struct got_repository *);
258 c4296144 2019-05-09 stsp
259 c4296144 2019-05-09 stsp /*
260 33ad4cbe 2019-05-12 jcs * A callback function which is invoked when a commit message is requested.
261 8656d6c4 2019-05-20 stsp * Passes a pathlist with a struct got_commitable * in the data pointer of
262 2a47b1e5 2022-11-01 stsp * each element, the path to a file which contains a diff of changes to be
263 2a47b1e5 2022-11-01 stsp * committed (may be NULL), and a pointer to the log message that must be
264 2a47b1e5 2022-11-01 stsp * set by the callback and will be freed after committing, and an argument
265 2a47b1e5 2022-11-01 stsp * passed through to the callback.
266 33ad4cbe 2019-05-12 jcs */
267 33ad4cbe 2019-05-12 jcs typedef const struct got_error *(*got_worktree_commit_msg_cb)(
268 2a47b1e5 2022-11-01 stsp struct got_pathlist_head *, const char *, char **, void *);
269 33ad4cbe 2019-05-12 jcs
270 33ad4cbe 2019-05-12 jcs /*
271 c4296144 2019-05-09 stsp * Create a new commit from changes in the work tree.
272 c4296144 2019-05-09 stsp * Return the ID of the newly created commit.
273 c4296144 2019-05-09 stsp * The worktree's base commit will be set to this new commit.
274 c4296144 2019-05-09 stsp * Files unaffected by this commit operation will retain their
275 c4296144 2019-05-09 stsp * current base commit.
276 de18fc63 2019-05-09 stsp * An author and a non-empty log message must be specified.
277 de18fc63 2019-05-09 stsp * The name of the committer is optional (may be NULL).
278 35213c7c 2020-07-23 stsp * If a path to be committed contains a symlink which points outside
279 35213c7c 2020-07-23 stsp * of the path space under version control, raise an error unless
280 35213c7c 2020-07-23 stsp * committing of such paths is being forced by the caller.
281 c4296144 2019-05-09 stsp */
282 de18fc63 2019-05-09 stsp const struct got_error *got_worktree_commit(struct got_object_id **,
283 5c1e53bc 2019-07-28 stsp struct got_worktree *, struct got_pathlist_head *, const char *,
284 12383673 2023-02-18 mark const char *, int, int, int, got_worktree_commit_msg_cb, void *,
285 33ad4cbe 2019-05-12 jcs got_worktree_status_cb, void *, struct got_repository *);
286 8656d6c4 2019-05-20 stsp
287 8656d6c4 2019-05-20 stsp /* Get the path of a commitable worktree item. */
288 8656d6c4 2019-05-20 stsp const char *got_commitable_get_path(struct got_commitable *);
289 8656d6c4 2019-05-20 stsp
290 8656d6c4 2019-05-20 stsp /* Get the status of a commitable worktree item. */
291 8656d6c4 2019-05-20 stsp unsigned int got_commitable_get_status(struct got_commitable *);
292 818c7501 2019-07-11 stsp
293 818c7501 2019-07-11 stsp /*
294 818c7501 2019-07-11 stsp * Prepare for rebasing a branch onto the work tree's current branch.
295 818c7501 2019-07-11 stsp * This function creates references to a temporary branch, the branch
296 818c7501 2019-07-11 stsp * being rebased, and the work tree's current branch, under the
297 818c7501 2019-07-11 stsp * "got/worktree/rebase/" namespace. These references are used to
298 818c7501 2019-07-11 stsp * keep track of rebase operation state and are used as input and/or
299 818c7501 2019-07-11 stsp * output arguments with other rebase-related functions.
300 3e3a69f1 2019-07-25 stsp * The function also returns a pointer to a fileindex which must be
301 3e3a69f1 2019-07-25 stsp * passed back to other rebase-related functions.
302 818c7501 2019-07-11 stsp */
303 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_prepare(struct got_reference **,
304 3e3a69f1 2019-07-25 stsp struct got_reference **, struct got_fileindex **, struct got_worktree *,
305 3e3a69f1 2019-07-25 stsp struct got_reference *, struct got_repository *);
306 818c7501 2019-07-11 stsp
307 818c7501 2019-07-11 stsp /*
308 818c7501 2019-07-11 stsp * Continue an interrupted rebase operation.
309 818c7501 2019-07-11 stsp * This function returns existing references created when rebase was prepared,
310 818c7501 2019-07-11 stsp * and the ID of the commit currently being rebased. This should be called
311 818c7501 2019-07-11 stsp * before either resuming or aborting a rebase operation.
312 3e3a69f1 2019-07-25 stsp * The function also returns a pointer to a fileindex which must be
313 3e3a69f1 2019-07-25 stsp * passed back to other rebase-related functions.
314 818c7501 2019-07-11 stsp */
315 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_continue(struct got_object_id **,
316 818c7501 2019-07-11 stsp struct got_reference **, struct got_reference **, struct got_reference **,
317 3e3a69f1 2019-07-25 stsp struct got_fileindex **, struct got_worktree *, struct got_repository *);
318 818c7501 2019-07-11 stsp
319 818c7501 2019-07-11 stsp /* Check whether a, potentially interrupted, rebase operation is in progress. */
320 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_in_progress(int *,
321 818c7501 2019-07-11 stsp struct got_worktree *);
322 f4ab0e57 2024-03-28 stsp /* Return information about an in-progress rebase operation. */
323 f4ab0e57 2024-03-28 stsp const struct got_error *got_worktree_rebase_info(char **new_base_branch_name,
324 f4ab0e57 2024-03-28 stsp char **branch_name, struct got_worktree *, struct got_repository *);
325 818c7501 2019-07-11 stsp
326 818c7501 2019-07-11 stsp /*
327 818c7501 2019-07-11 stsp * Merge changes from the commit currently being rebased into the work tree.
328 818c7501 2019-07-11 stsp * Report affected files, including merge conflicts, via the specified
329 01757395 2019-07-12 stsp * progress callback. Also populate a list of affected paths which should
330 01757395 2019-07-12 stsp * be passed to got_worktree_rebase_commit() after a conflict-free merge.
331 01757395 2019-07-12 stsp * This list must be initialized with TAILQ_INIT() and disposed of with
332 d8bacb93 2023-01-10 mark * got_pathlist_free(list, GOT_PATHLIST_FREE_PATH).
333 818c7501 2019-07-11 stsp */
334 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_merge_files(
335 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
336 01757395 2019-07-12 stsp struct got_object_id *, struct got_object_id *, struct got_repository *,
337 e6209546 2019-08-22 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
338 818c7501 2019-07-11 stsp
339 818c7501 2019-07-11 stsp /*
340 01757395 2019-07-12 stsp * Commit changes merged by got_worktree_rebase_merge_files() to a temporary
341 01757395 2019-07-12 stsp * branch and return the ID of the newly created commit. An optional list of
342 01757395 2019-07-12 stsp * merged paths can be provided; otherwise this function will perform a status
343 01757395 2019-07-12 stsp * crawl across the entire work tree to find paths to commit.
344 818c7501 2019-07-11 stsp */
345 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_commit(struct got_object_id **,
346 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
347 598eac43 2022-07-22 stsp struct got_reference *, const char *, struct got_commit_object *,
348 12383673 2023-02-18 mark struct got_object_id *, int, struct got_repository *);
349 818c7501 2019-07-11 stsp
350 818c7501 2019-07-11 stsp /* Postpone the rebase operation. Should be called after a merge conflict. */
351 3e3a69f1 2019-07-25 stsp const struct got_error *got_worktree_rebase_postpone(struct got_worktree *,
352 3e3a69f1 2019-07-25 stsp struct got_fileindex *);
353 818c7501 2019-07-11 stsp
354 818c7501 2019-07-11 stsp /*
355 818c7501 2019-07-11 stsp * Complete the current rebase operation. This should be called once all
356 818c7501 2019-07-11 stsp * commits have been rebased successfully.
357 e600f124 2021-03-21 stsp * The create_backup parameter controls whether the rebased branch will
358 e600f124 2021-03-21 stsp * be backed up via a reference in refs/got/backup/rebase/.
359 818c7501 2019-07-11 stsp */
360 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_complete(struct got_worktree *,
361 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_reference *, struct got_reference *,
362 ef85a376 2023-02-01 mark struct got_repository *, int create_backup);
363 818c7501 2019-07-11 stsp
364 818c7501 2019-07-11 stsp /*
365 818c7501 2019-07-11 stsp * Abort the current rebase operation.
366 818c7501 2019-07-11 stsp * Report reverted files via the specified progress callback.
367 818c7501 2019-07-11 stsp */
368 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_abort(struct got_worktree *,
369 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_repository *, struct got_reference *,
370 0ebf8283 2019-07-24 stsp got_worktree_checkout_cb, void *);
371 0ebf8283 2019-07-24 stsp
372 0ebf8283 2019-07-24 stsp /*
373 0ebf8283 2019-07-24 stsp * Prepare for editing the history of the work tree's current branch.
374 0ebf8283 2019-07-24 stsp * This function creates references to a temporary branch, and the
375 0ebf8283 2019-07-24 stsp * work tree's current branch, under the "got/worktree/histedit/" namespace.
376 0ebf8283 2019-07-24 stsp * These references are used to keep track of histedit operation state and
377 0ebf8283 2019-07-24 stsp * are used as input and/or output arguments with other histedit-related
378 0ebf8283 2019-07-24 stsp * functions.
379 0ebf8283 2019-07-24 stsp */
380 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_prepare(struct got_reference **,
381 3e3a69f1 2019-07-25 stsp struct got_reference **, struct got_object_id **, struct got_fileindex **,
382 3e3a69f1 2019-07-25 stsp struct got_worktree *, struct got_repository *);
383 0ebf8283 2019-07-24 stsp
384 0ebf8283 2019-07-24 stsp /*
385 0ebf8283 2019-07-24 stsp * Continue an interrupted histedit operation.
386 0ebf8283 2019-07-24 stsp * This function returns existing references created when histedit was
387 0ebf8283 2019-07-24 stsp * prepared and the ID of the commit currently being edited.
388 0ebf8283 2019-07-24 stsp * It should be called before resuming or aborting a histedit operation.
389 0ebf8283 2019-07-24 stsp */
390 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_continue(struct got_object_id **,
391 0ebf8283 2019-07-24 stsp struct got_reference **, struct got_reference **, struct got_object_id **,
392 3e3a69f1 2019-07-25 stsp struct got_fileindex **, struct got_worktree *, struct got_repository *);
393 0ebf8283 2019-07-24 stsp
394 0ebf8283 2019-07-24 stsp /* Check whether a histedit operation is in progress. */
395 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_in_progress(int *,
396 0ebf8283 2019-07-24 stsp struct got_worktree *);
397 f4ab0e57 2024-03-28 stsp /* Return information about an in-progress histedit operation. */
398 f4ab0e57 2024-03-28 stsp const struct got_error *got_worktree_histedit_info(
399 f4ab0e57 2024-03-28 stsp char **branch_nane, struct got_worktree *,
400 f4ab0e57 2024-03-28 stsp struct got_repository *);
401 0ebf8283 2019-07-24 stsp
402 0ebf8283 2019-07-24 stsp /*
403 0ebf8283 2019-07-24 stsp * Merge changes from the commit currently being edited into the work tree.
404 0ebf8283 2019-07-24 stsp * Report affected files, including merge conflicts, via the specified
405 0ebf8283 2019-07-24 stsp * progress callback. Also populate a list of affected paths which should
406 0ebf8283 2019-07-24 stsp * be passed to got_worktree_histedit_commit() after a conflict-free merge.
407 0ebf8283 2019-07-24 stsp * This list must be initialized with TAILQ_INIT() and disposed of with
408 d8bacb93 2023-01-10 mark * got_pathlist_free(list, GOT_PATHLIST_FREE_PATH).
409 0ebf8283 2019-07-24 stsp */
410 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_merge_files(
411 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
412 0ebf8283 2019-07-24 stsp struct got_object_id *, struct got_object_id *, struct got_repository *,
413 e6209546 2019-08-22 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
414 0ebf8283 2019-07-24 stsp
415 0ebf8283 2019-07-24 stsp /*
416 0ebf8283 2019-07-24 stsp * Commit changes merged by got_worktree_histedit_merge_files() to a temporary
417 0ebf8283 2019-07-24 stsp * branch and return the ID of the newly created commit. An optional list of
418 0ebf8283 2019-07-24 stsp * merged paths can be provided; otherwise this function will perform a status
419 0ebf8283 2019-07-24 stsp * crawl across the entire work tree to find paths to commit.
420 0ebf8283 2019-07-24 stsp * An optional log message can be provided which will be used instead of the
421 0ebf8283 2019-07-24 stsp * commit's original message.
422 0ebf8283 2019-07-24 stsp */
423 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_commit(struct got_object_id **,
424 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
425 598eac43 2022-07-22 stsp struct got_reference *, const char *, struct got_commit_object *,
426 12383673 2023-02-18 mark struct got_object_id *, const char *, int, struct got_repository *);
427 0ebf8283 2019-07-24 stsp
428 0ebf8283 2019-07-24 stsp /*
429 0ebf8283 2019-07-24 stsp * Record the specified commit as skipped during histedit.
430 0ebf8283 2019-07-24 stsp * This should be called for commits which get dropped or get folded into
431 0ebf8283 2019-07-24 stsp * a subsequent commit.
432 0ebf8283 2019-07-24 stsp */
433 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_skip_commit(struct got_worktree *,
434 0ebf8283 2019-07-24 stsp struct got_object_id *, struct got_repository *);
435 0ebf8283 2019-07-24 stsp
436 0ebf8283 2019-07-24 stsp /* Postpone the histedit operation. */
437 3e3a69f1 2019-07-25 stsp const struct got_error *got_worktree_histedit_postpone(struct got_worktree *,
438 3e3a69f1 2019-07-25 stsp struct got_fileindex *);
439 0ebf8283 2019-07-24 stsp
440 0ebf8283 2019-07-24 stsp /*
441 0ebf8283 2019-07-24 stsp * Complete the current histedit operation. This should be called once all
442 0ebf8283 2019-07-24 stsp * commits have been edited successfully.
443 0ebf8283 2019-07-24 stsp */
444 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_complete(struct got_worktree *,
445 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_reference *, struct got_reference *,
446 3e3a69f1 2019-07-25 stsp struct got_repository *);
447 0ebf8283 2019-07-24 stsp
448 0ebf8283 2019-07-24 stsp /*
449 0ebf8283 2019-07-24 stsp * Abort the current histedit operation.
450 0ebf8283 2019-07-24 stsp * Report reverted files via the specified progress callback.
451 0ebf8283 2019-07-24 stsp */
452 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_abort(struct got_worktree *,
453 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_repository *, struct got_reference *,
454 3e3a69f1 2019-07-25 stsp struct got_object_id *, got_worktree_checkout_cb, void *);
455 0ebf8283 2019-07-24 stsp
456 c3022ba5 2019-07-27 stsp /* Get the path to this work tree's histedit script file. */
457 c3022ba5 2019-07-27 stsp const struct got_error *got_worktree_get_histedit_script_path(char **,
458 0ebf8283 2019-07-24 stsp struct got_worktree *);
459 dc424a06 2019-08-07 stsp
460 2822a352 2019-10-15 stsp /*
461 2822a352 2019-10-15 stsp * Prepare a work tree for integrating a branch.
462 2822a352 2019-10-15 stsp * Return pointers to a fileindex and locked references which must be
463 2822a352 2019-10-15 stsp * passed back to other integrate-related functions.
464 2822a352 2019-10-15 stsp */
465 2822a352 2019-10-15 stsp const struct got_error *
466 2822a352 2019-10-15 stsp got_worktree_integrate_prepare(struct got_fileindex **,
467 abc59930 2021-09-05 naddy struct got_reference **, struct got_reference **,
468 2822a352 2019-10-15 stsp struct got_worktree *, const char *, struct got_repository *);
469 dc424a06 2019-08-07 stsp
470 fdfa9bf2 2019-08-03 stsp /*
471 2822a352 2019-10-15 stsp * Carry out a prepared branch integration operation.
472 2822a352 2019-10-15 stsp * Report affected files via the specified progress callback.
473 2822a352 2019-10-15 stsp */
474 2822a352 2019-10-15 stsp const struct got_error *got_worktree_integrate_continue(
475 2822a352 2019-10-15 stsp struct got_worktree *, struct got_fileindex *, struct got_repository *,
476 2822a352 2019-10-15 stsp struct got_reference *, struct got_reference *,
477 2822a352 2019-10-15 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
478 2822a352 2019-10-15 stsp
479 2822a352 2019-10-15 stsp /* Abort a prepared branch integration operation. */
480 2822a352 2019-10-15 stsp const struct got_error *got_worktree_integrate_abort(struct got_worktree *,
481 2822a352 2019-10-15 stsp struct got_fileindex *, struct got_repository *,
482 2822a352 2019-10-15 stsp struct got_reference *, struct got_reference *);
483 f259c4c1 2021-09-24 stsp
484 f259c4c1 2021-09-24 stsp /* Postpone the merge operation. Should be called after a merge conflict. */
485 f259c4c1 2021-09-24 stsp const struct got_error *got_worktree_merge_postpone(struct got_worktree *,
486 f259c4c1 2021-09-24 stsp struct got_fileindex *);
487 f259c4c1 2021-09-24 stsp
488 f259c4c1 2021-09-24 stsp /* Merge changes from the merge source branch into the worktree. */
489 f259c4c1 2021-09-24 stsp const struct got_error *
490 f259c4c1 2021-09-24 stsp got_worktree_merge_branch(struct got_worktree *worktree,
491 f259c4c1 2021-09-24 stsp struct got_fileindex *fileindex,
492 f259c4c1 2021-09-24 stsp struct got_object_id *yca_commit_id,
493 f259c4c1 2021-09-24 stsp struct got_object_id *branch_tip,
494 f259c4c1 2021-09-24 stsp struct got_repository *repo, got_worktree_checkout_cb progress_cb,
495 f259c4c1 2021-09-24 stsp void *progress_arg, got_cancel_cb cancel_cb, void *cancel_arg);
496 f259c4c1 2021-09-24 stsp
497 f259c4c1 2021-09-24 stsp /* Attempt to commit merged changes. */
498 f259c4c1 2021-09-24 stsp const struct got_error *
499 f259c4c1 2021-09-24 stsp got_worktree_merge_commit(struct got_object_id **new_commit_id,
500 f259c4c1 2021-09-24 stsp struct got_worktree *worktree, struct got_fileindex *fileindex,
501 f259c4c1 2021-09-24 stsp const char *author, const char *committer, int allow_bad_symlinks,
502 f259c4c1 2021-09-24 stsp struct got_object_id *branch_tip, const char *branch_name,
503 12383673 2023-02-18 mark int allow_conflict, struct got_repository *repo,
504 0ff8d236 2021-09-28 stsp got_worktree_status_cb status_cb, void *status_arg);
505 f259c4c1 2021-09-24 stsp
506 f259c4c1 2021-09-24 stsp /*
507 f259c4c1 2021-09-24 stsp * Complete the merge operation.
508 f259c4c1 2021-09-24 stsp * This should be called once changes have been successfully committed.
509 f259c4c1 2021-09-24 stsp */
510 f259c4c1 2021-09-24 stsp const struct got_error *got_worktree_merge_complete(
511 f259c4c1 2021-09-24 stsp struct got_worktree *worktree, struct got_fileindex *fileindex,
512 f259c4c1 2021-09-24 stsp struct got_repository *repo);
513 f259c4c1 2021-09-24 stsp
514 f259c4c1 2021-09-24 stsp /* Check whether a merge operation is in progress. */
515 f259c4c1 2021-09-24 stsp const struct got_error *got_worktree_merge_in_progress(int *,
516 f259c4c1 2021-09-24 stsp struct got_worktree *, struct got_repository *);
517 f4ab0e57 2024-03-28 stsp /* Return information about an in-progress merge operation. */
518 f4ab0e57 2024-03-28 stsp const struct got_error *
519 f4ab0e57 2024-03-28 stsp got_worktree_merge_info(char **branch_name, struct got_worktree *,
520 f4ab0e57 2024-03-28 stsp struct got_repository *);
521 f259c4c1 2021-09-24 stsp
522 f259c4c1 2021-09-24 stsp /*
523 179f9db0 2023-06-20 falsifian * Prepare for merging a branch into the work tree's current branch: lock the
524 179f9db0 2023-06-20 falsifian * worktree and check that preconditions are satisfied. The function also
525 179f9db0 2023-06-20 falsifian * returns a pointer to a fileindex which must be passed back to other
526 179f9db0 2023-06-20 falsifian * merge-related functions.
527 179f9db0 2023-06-20 falsifian */
528 179f9db0 2023-06-20 falsifian const struct got_error *got_worktree_merge_prepare(struct got_fileindex **,
529 179f9db0 2023-06-20 falsifian struct got_worktree *, struct got_repository *);
530 179f9db0 2023-06-20 falsifian
531 179f9db0 2023-06-20 falsifian /*
532 f259c4c1 2021-09-24 stsp * This function creates a reference to the branch being merged, and to
533 f259c4c1 2021-09-24 stsp * this branch's current tip commit, in the "got/worktree/merge/" namespace.
534 f259c4c1 2021-09-24 stsp * These references are used to keep track of merge operation state and are
535 f259c4c1 2021-09-24 stsp * used as input and/or output arguments with other merge-related functions.
536 f259c4c1 2021-09-24 stsp */
537 179f9db0 2023-06-20 falsifian const struct got_error *got_worktree_merge_write_refs(struct got_worktree *,
538 179f9db0 2023-06-20 falsifian struct got_reference *, struct got_repository *);
539 2822a352 2019-10-15 stsp
540 2822a352 2019-10-15 stsp /*
541 f259c4c1 2021-09-24 stsp * Continue an interrupted merge operation.
542 f259c4c1 2021-09-24 stsp * This function returns name of the branch being merged, and the ID of the
543 f259c4c1 2021-09-24 stsp * tip commit being merged.
544 f259c4c1 2021-09-24 stsp * This function should be called before either resuming or aborting a
545 f259c4c1 2021-09-24 stsp * merge operation.
546 f259c4c1 2021-09-24 stsp * The function also returns a pointer to a fileindex which must be
547 f259c4c1 2021-09-24 stsp * passed back to other merge-related functions.
548 f259c4c1 2021-09-24 stsp */
549 f259c4c1 2021-09-24 stsp const struct got_error *got_worktree_merge_continue(char **,
550 f259c4c1 2021-09-24 stsp struct got_object_id **, struct got_fileindex **,
551 f259c4c1 2021-09-24 stsp struct got_worktree *, struct got_repository *);
552 f259c4c1 2021-09-24 stsp
553 f259c4c1 2021-09-24 stsp /*
554 f259c4c1 2021-09-24 stsp * Abort the current rebase operation.
555 f259c4c1 2021-09-24 stsp * Report reverted files via the specified progress callback.
556 f259c4c1 2021-09-24 stsp */
557 f259c4c1 2021-09-24 stsp const struct got_error *got_worktree_merge_abort(struct got_worktree *,
558 f259c4c1 2021-09-24 stsp struct got_fileindex *, struct got_repository *,
559 f259c4c1 2021-09-24 stsp got_worktree_checkout_cb, void *);
560 f259c4c1 2021-09-24 stsp
561 f259c4c1 2021-09-24 stsp /*
562 fdfa9bf2 2019-08-03 stsp * Stage the specified paths for commit.
563 dc424a06 2019-08-07 stsp * If the patch callback is not NULL, call it to select patch hunks for
564 dc424a06 2019-08-07 stsp * staging. Otherwise, stage the full file content found at each path.
565 35213c7c 2020-07-23 stsp * If a path being staged contains a symlink which points outside
566 35213c7c 2020-07-23 stsp * of the path space under version control, raise an error unless
567 35213c7c 2020-07-23 stsp * staging of such paths is being forced by the caller.
568 35213c7c 2020-07-23 stsp */
569 1e71573e 2019-08-03 stsp const struct got_error *got_worktree_stage(struct got_worktree *,
570 1e71573e 2019-08-03 stsp struct got_pathlist_head *, got_worktree_status_cb, void *,
571 35213c7c 2020-07-23 stsp got_worktree_patch_cb, void *, int, struct got_repository *);
572 ad493afc 2019-08-03 stsp
573 ad493afc 2019-08-03 stsp /*
574 ad493afc 2019-08-03 stsp * Merge staged changes for the specified paths back into the work tree
575 ad493afc 2019-08-03 stsp * and mark the paths as non-staged again.
576 ad493afc 2019-08-03 stsp */
577 ad493afc 2019-08-03 stsp const struct got_error *got_worktree_unstage(struct got_worktree *,
578 ad493afc 2019-08-03 stsp struct got_pathlist_head *, got_worktree_checkout_cb, void *,
579 2e1f37b0 2019-08-08 stsp got_worktree_patch_cb, void *, struct got_repository *);
580 b2118c49 2020-07-28 stsp
581 b2118c49 2020-07-28 stsp /* A callback function which is invoked with per-path info. */
582 b2118c49 2020-07-28 stsp typedef const struct got_error *(*got_worktree_path_info_cb)(void *,
583 b2118c49 2020-07-28 stsp const char *path, mode_t mode, time_t mtime,
584 b2118c49 2020-07-28 stsp struct got_object_id *blob_id, struct got_object_id *staged_blob_id,
585 b2118c49 2020-07-28 stsp struct got_object_id *commit_id);
586 b2118c49 2020-07-28 stsp
587 5e91dae4 2022-08-30 stsp /*
588 b2118c49 2020-07-28 stsp * Report work-tree meta data for paths in the work tree.
589 b2118c49 2020-07-28 stsp * The info callback will be invoked with the provided void * argument,
590 b2118c49 2020-07-28 stsp * a path, and meta-data arguments (see got_worktree_path_info_cb).
591 b2118c49 2020-07-28 stsp */
592 b2118c49 2020-07-28 stsp const struct got_error *
593 b2118c49 2020-07-28 stsp got_worktree_path_info(struct got_worktree *, struct got_pathlist_head *,
594 b2118c49 2020-07-28 stsp got_worktree_path_info_cb, void *, got_cancel_cb , void *);
595 e600f124 2021-03-21 stsp
596 e600f124 2021-03-21 stsp /* References pointing at pre-rebase commit backups. */
597 e600f124 2021-03-21 stsp #define GOT_WORKTREE_REBASE_BACKUP_REF_PREFIX "refs/got/backup/rebase"
598 e600f124 2021-03-21 stsp
599 e600f124 2021-03-21 stsp /* References pointing at pre-histedit commit backups. */
600 e600f124 2021-03-21 stsp #define GOT_WORKTREE_HISTEDIT_BACKUP_REF_PREFIX "refs/got/backup/histedit"
601 78f5ac24 2022-03-19 op
602 78f5ac24 2022-03-19 op /*
603 78f5ac24 2022-03-19 op * Prepare for applying a patch.
604 78f5ac24 2022-03-19 op */
605 78f5ac24 2022-03-19 op const struct got_error *
606 f2dd7807 2022-05-17 op got_worktree_patch_prepare(struct got_fileindex **, char **,
607 f2dd7807 2022-05-17 op struct got_worktree *);
608 78f5ac24 2022-03-19 op
609 78f5ac24 2022-03-19 op /*
610 78f5ac24 2022-03-19 op * Lookup paths for the "old" and "new" file before patching and check their
611 78f5ac24 2022-03-19 op * status.
612 78f5ac24 2022-03-19 op */
613 78f5ac24 2022-03-19 op const struct got_error *
614 78f5ac24 2022-03-19 op got_worktree_patch_check_path(const char *, const char *, char **, char **,
615 78f5ac24 2022-03-19 op struct got_worktree *, struct got_repository *, struct got_fileindex *);
616 78f5ac24 2022-03-19 op
617 f2dd7807 2022-05-17 op const struct got_error *
618 f2dd7807 2022-05-17 op got_worktree_patch_schedule_add(const char *, struct got_repository *,
619 f2dd7807 2022-05-17 op struct got_worktree *, struct got_fileindex *, got_worktree_checkout_cb,
620 f2dd7807 2022-05-17 op void *);
621 f2dd7807 2022-05-17 op
622 f2dd7807 2022-05-17 op const struct got_error *
623 f2dd7807 2022-05-17 op got_worktree_patch_schedule_rm(const char *, struct got_repository *,
624 f2dd7807 2022-05-17 op struct got_worktree *, struct got_fileindex *, got_worktree_delete_cb,
625 f2dd7807 2022-05-17 op void *);
626 f2dd7807 2022-05-17 op
627 78f5ac24 2022-03-19 op /* Complete the patch operation. */
628 78f5ac24 2022-03-19 op const struct got_error *
629 4bcdc895 2022-05-17 op got_worktree_patch_complete(struct got_fileindex *, const char *);