Blob


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