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 * Get the state of the work tree. If the work tree's global base commit is
138 * the tip of the work tree's current branch, and each file in the index is
139 * based on this same commit, the char out parameter will be
140 * GOT_WORKTREE_STATE_UPTODATE, else it will be GOT_WORKTREE_STATE_OUTOFDATE.
141 */
142 const struct got_error *got_worktree_get_state(char *,
143 struct got_repository *, struct got_worktree *,
144 got_cancel_cb, void *);
146 #define GOT_WORKTREE_STATE_UNKNOWN ' '
147 #define GOT_WORKTREE_STATE_UPTODATE '*'
148 #define GOT_WORKTREE_STATE_OUTOFDATE '~'
150 /*
151 * Obtain a parsed representation of this worktree's got.conf file.
152 * Return NULL if this configuration file could not be read.
153 */
154 const struct got_gotconfig *got_worktree_get_gotconfig(struct got_worktree *);
156 /* A callback function which is invoked when a path is checked out. */
157 typedef const struct got_error *(*got_worktree_checkout_cb)(void *,
158 unsigned char, const char *);
160 /* A callback function which is invoked when a path is removed. */
161 typedef const struct got_error *(*got_worktree_delete_cb)(void *,
162 unsigned char, unsigned char, const char *);
164 /*
165 * Attempt to check out files into a work tree from its associated repository
166 * and path prefix, and update the work tree's file index accordingly.
167 * File content is obtained from blobs within the work tree's path prefix
168 * inside the tree corresponding to the work tree's base commit.
169 * The checkout progress callback will be invoked with the provided
170 * void * argument, and the path of each checked out file.
172 * It is possible to restrict the checkout operation to specific paths in
173 * the work tree, in which case all files outside those paths will remain at
174 * their currently recorded base commit. Inconsistent base commits can be
175 * repaired later by running another update operation across the entire work
176 * tree. Inconsistent base-commits may also occur if this function runs into
177 * an error or if the checkout operation is cancelled by the cancel callback.
178 * Allspecified paths are relative to the work tree's root. Pass a pathlist
179 * with a single empty path "" to check out files across the entire work tree.
181 * Some operations may refuse to run while the work tree contains files from
182 * multiple base commits.
183 */
184 const struct got_error *got_worktree_checkout_files(struct got_worktree *,
185 struct got_pathlist_head *, struct got_repository *,
186 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
188 /* Merge the differences between two commits into a work tree. */
189 const struct got_error *
190 got_worktree_merge_files(struct got_worktree *,
191 struct got_object_id *, struct got_object_id *,
192 struct got_repository *, got_worktree_checkout_cb, void *,
193 got_cancel_cb, void *);
195 /*
196 * A callback function which is invoked to report a file's status.
198 * If a valid directory file descriptor and a directory entry name are passed,
199 * these should be used to open the file instead of opening the file by path.
200 * This prevents race conditions if the filesystem is modified concurrently.
201 * If the directory descriptor is not available then its value will be -1.
202 */
203 typedef const struct got_error *(*got_worktree_status_cb)(void *,
204 unsigned char, unsigned char, const char *, struct got_object_id *,
205 struct got_object_id *, struct got_object_id *, int, const char *);
207 /*
208 * Report the status of paths in the work tree.
209 * The status callback will be invoked with the provided void * argument,
210 * a path, and a corresponding status code.
211 */
212 const struct got_error *got_worktree_status(struct got_worktree *,
213 struct got_pathlist_head *, struct got_repository *, int no_ignores,
214 got_worktree_status_cb, void *, got_cancel_cb cancel_cb, void *);
216 /*
217 * Try to resolve a user-provided path to an on-disk path in the work tree.
218 * The caller must dispose of the resolved path with free(3).
219 */
220 const struct got_error *got_worktree_resolve_path(char **,
221 struct got_worktree *, const char *);
223 /* Schedule files at on-disk paths for addition in the next commit. */
224 const struct got_error *got_worktree_schedule_add(struct got_worktree *,
225 struct got_pathlist_head *, got_worktree_checkout_cb, void *,
226 struct got_repository *, int);
228 /*
229 * Remove files from disk and schedule them to be deleted in the next commit.
230 * Don't allow deleting files with uncommitted modifications, unless the
231 * parameter 'delete_local_mods' is set.
232 */
233 const struct got_error *
234 got_worktree_schedule_delete(struct got_worktree *,
235 struct got_pathlist_head *, int, const char *,
236 got_worktree_delete_cb, void *, struct got_repository *, int, int);
238 /* A callback function which is used to select or reject a patch. */
239 typedef const struct got_error *(*got_worktree_patch_cb)(int *, void *,
240 unsigned char, const char *, FILE *, int, int);
242 /* Values for result output parameter of got_wortree_patch_cb. */
243 #define GOT_PATCH_CHOICE_NONE 0
244 #define GOT_PATCH_CHOICE_YES 1
245 #define GOT_PATCH_CHOICE_NO 2
246 #define GOT_PATCH_CHOICE_QUIT 3
248 /*
249 * Revert a file at the specified path such that it matches its
250 * original state in the worktree's base commit.
251 * If the patch callback is not NULL, call it to select patch hunks to
252 * revert. Otherwise, revert the whole file found at each path.
253 */
254 const struct got_error *got_worktree_revert(struct got_worktree *,
255 struct got_pathlist_head *, got_worktree_checkout_cb, void *,
256 got_worktree_patch_cb patch_cb, void *patch_arg,
257 struct got_repository *);
259 /*
260 * A callback function which is invoked when a commit message is requested.
261 * Passes a pathlist with a struct got_commitable * in the data pointer of
262 * each element, the path to a file which contains a diff of changes to be
263 * committed (may be NULL), and a pointer to the log message that must be
264 * set by the callback and will be freed after committing, and an argument
265 * passed through to the callback.
266 */
267 typedef const struct got_error *(*got_worktree_commit_msg_cb)(
268 struct got_pathlist_head *, const char *, char **, void *);
270 /*
271 * Create a new commit from changes in the work tree.
272 * Return the ID of the newly created commit.
273 * The worktree's base commit will be set to this new commit.
274 * Files unaffected by this commit operation will retain their
275 * current base commit.
276 * An author and a non-empty log message must be specified.
277 * The name of the committer is optional (may be NULL).
278 * If a path to be committed contains a symlink which points outside
279 * of the path space under version control, raise an error unless
280 * committing of such paths is being forced by the caller.
281 */
282 const struct got_error *got_worktree_commit(struct got_object_id **,
283 struct got_worktree *, struct got_pathlist_head *, const char *,
284 const char *, int, int, int, got_worktree_commit_msg_cb, void *,
285 got_worktree_status_cb, void *, struct got_repository *);
287 /* Get the path of a commitable worktree item. */
288 const char *got_commitable_get_path(struct got_commitable *);
290 /* Get the status of a commitable worktree item. */
291 unsigned int got_commitable_get_status(struct got_commitable *);
293 /*
294 * Prepare for rebasing a branch onto the work tree's current branch.
295 * This function creates references to a temporary branch, the branch
296 * being rebased, and the work tree's current branch, under the
297 * "got/worktree/rebase/" namespace. These references are used to
298 * keep track of rebase operation state and are used as input and/or
299 * output arguments with other rebase-related functions.
300 * The function also returns a pointer to a fileindex which must be
301 * passed back to other rebase-related functions.
302 */
303 const struct got_error *got_worktree_rebase_prepare(struct got_reference **,
304 struct got_reference **, struct got_fileindex **, struct got_worktree *,
305 struct got_reference *, struct got_repository *);
307 /*
308 * Continue an interrupted rebase operation.
309 * This function returns existing references created when rebase was prepared,
310 * and the ID of the commit currently being rebased. This should be called
311 * before either resuming or aborting a rebase operation.
312 * The function also returns a pointer to a fileindex which must be
313 * passed back to other rebase-related functions.
314 */
315 const struct got_error *got_worktree_rebase_continue(struct got_object_id **,
316 struct got_reference **, struct got_reference **, struct got_reference **,
317 struct got_fileindex **, struct got_worktree *, struct got_repository *);
319 /* Check whether a, potentially interrupted, rebase operation is in progress. */
320 const struct got_error *got_worktree_rebase_in_progress(int *,
321 struct got_worktree *);
323 /*
324 * Merge changes from the commit currently being rebased into the work tree.
325 * Report affected files, including merge conflicts, via the specified
326 * progress callback. Also populate a list of affected paths which should
327 * be passed to got_worktree_rebase_commit() after a conflict-free merge.
328 * This list must be initialized with TAILQ_INIT() and disposed of with
329 * got_pathlist_free(list, GOT_PATHLIST_FREE_PATH).
330 */
331 const struct got_error *got_worktree_rebase_merge_files(
332 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
333 struct got_object_id *, struct got_object_id *, struct got_repository *,
334 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
336 /*
337 * Commit changes merged by got_worktree_rebase_merge_files() to a temporary
338 * branch and return the ID of the newly created commit. An optional list of
339 * merged paths can be provided; otherwise this function will perform a status
340 * crawl across the entire work tree to find paths to commit.
341 */
342 const struct got_error *got_worktree_rebase_commit(struct got_object_id **,
343 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
344 struct got_reference *, const char *, struct got_commit_object *,
345 struct got_object_id *, int, struct got_repository *);
347 /* Postpone the rebase operation. Should be called after a merge conflict. */
348 const struct got_error *got_worktree_rebase_postpone(struct got_worktree *,
349 struct got_fileindex *);
351 /*
352 * Complete the current rebase operation. This should be called once all
353 * commits have been rebased successfully.
354 * The create_backup parameter controls whether the rebased branch will
355 * be backed up via a reference in refs/got/backup/rebase/.
356 */
357 const struct got_error *got_worktree_rebase_complete(struct got_worktree *,
358 struct got_fileindex *, struct got_reference *, struct got_reference *,
359 struct got_repository *, int create_backup);
361 /*
362 * Abort the current rebase operation.
363 * Report reverted files via the specified progress callback.
364 */
365 const struct got_error *got_worktree_rebase_abort(struct got_worktree *,
366 struct got_fileindex *, struct got_repository *, struct got_reference *,
367 got_worktree_checkout_cb, void *);
369 /*
370 * Prepare for editing the history of the work tree's current branch.
371 * This function creates references to a temporary branch, and the
372 * work tree's current branch, under the "got/worktree/histedit/" namespace.
373 * These references are used to keep track of histedit operation state and
374 * are used as input and/or output arguments with other histedit-related
375 * functions.
376 */
377 const struct got_error *got_worktree_histedit_prepare(struct got_reference **,
378 struct got_reference **, struct got_object_id **, struct got_fileindex **,
379 struct got_worktree *, struct got_repository *);
381 /*
382 * Continue an interrupted histedit operation.
383 * This function returns existing references created when histedit was
384 * prepared and the ID of the commit currently being edited.
385 * It should be called before resuming or aborting a histedit operation.
386 */
387 const struct got_error *got_worktree_histedit_continue(struct got_object_id **,
388 struct got_reference **, struct got_reference **, struct got_object_id **,
389 struct got_fileindex **, struct got_worktree *, struct got_repository *);
391 /* Check whether a histedit operation is in progress. */
392 const struct got_error *got_worktree_histedit_in_progress(int *,
393 struct got_worktree *);
395 /*
396 * Merge changes from the commit currently being edited into the work tree.
397 * Report affected files, including merge conflicts, via the specified
398 * progress callback. Also populate a list of affected paths which should
399 * be passed to got_worktree_histedit_commit() after a conflict-free merge.
400 * This list must be initialized with TAILQ_INIT() and disposed of with
401 * got_pathlist_free(list, GOT_PATHLIST_FREE_PATH).
402 */
403 const struct got_error *got_worktree_histedit_merge_files(
404 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
405 struct got_object_id *, struct got_object_id *, struct got_repository *,
406 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
408 /*
409 * Commit changes merged by got_worktree_histedit_merge_files() to a temporary
410 * branch and return the ID of the newly created commit. An optional list of
411 * merged paths can be provided; otherwise this function will perform a status
412 * crawl across the entire work tree to find paths to commit.
413 * An optional log message can be provided which will be used instead of the
414 * commit's original message.
415 */
416 const struct got_error *got_worktree_histedit_commit(struct got_object_id **,
417 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
418 struct got_reference *, const char *, struct got_commit_object *,
419 struct got_object_id *, const char *, int, struct got_repository *);
421 /*
422 * Record the specified commit as skipped during histedit.
423 * This should be called for commits which get dropped or get folded into
424 * a subsequent commit.
425 */
426 const struct got_error *got_worktree_histedit_skip_commit(struct got_worktree *,
427 struct got_object_id *, struct got_repository *);
429 /* Postpone the histedit operation. */
430 const struct got_error *got_worktree_histedit_postpone(struct got_worktree *,
431 struct got_fileindex *);
433 /*
434 * Complete the current histedit operation. This should be called once all
435 * commits have been edited successfully.
436 */
437 const struct got_error *got_worktree_histedit_complete(struct got_worktree *,
438 struct got_fileindex *, struct got_reference *, struct got_reference *,
439 struct got_repository *);
441 /*
442 * Abort the current histedit operation.
443 * Report reverted files via the specified progress callback.
444 */
445 const struct got_error *got_worktree_histedit_abort(struct got_worktree *,
446 struct got_fileindex *, struct got_repository *, struct got_reference *,
447 struct got_object_id *, got_worktree_checkout_cb, void *);
449 /* Get the path to this work tree's histedit script file. */
450 const struct got_error *got_worktree_get_histedit_script_path(char **,
451 struct got_worktree *);
453 /*
454 * Prepare a work tree for integrating a branch.
455 * Return pointers to a fileindex and locked references which must be
456 * passed back to other integrate-related functions.
457 */
458 const struct got_error *
459 got_worktree_integrate_prepare(struct got_fileindex **,
460 struct got_reference **, struct got_reference **,
461 struct got_worktree *, const char *, struct got_repository *);
463 /*
464 * Carry out a prepared branch integration operation.
465 * Report affected files via the specified progress callback.
466 */
467 const struct got_error *got_worktree_integrate_continue(
468 struct got_worktree *, struct got_fileindex *, struct got_repository *,
469 struct got_reference *, struct got_reference *,
470 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
472 /* Abort a prepared branch integration operation. */
473 const struct got_error *got_worktree_integrate_abort(struct got_worktree *,
474 struct got_fileindex *, struct got_repository *,
475 struct got_reference *, struct got_reference *);
477 /* Postpone the merge operation. Should be called after a merge conflict. */
478 const struct got_error *got_worktree_merge_postpone(struct got_worktree *,
479 struct got_fileindex *);
481 /* Merge changes from the merge source branch into the worktree. */
482 const struct got_error *
483 got_worktree_merge_branch(struct got_worktree *worktree,
484 struct got_fileindex *fileindex,
485 struct got_object_id *yca_commit_id,
486 struct got_object_id *branch_tip,
487 struct got_repository *repo, got_worktree_checkout_cb progress_cb,
488 void *progress_arg, got_cancel_cb cancel_cb, void *cancel_arg);
490 /* Attempt to commit merged changes. */
491 const struct got_error *
492 got_worktree_merge_commit(struct got_object_id **new_commit_id,
493 struct got_worktree *worktree, struct got_fileindex *fileindex,
494 const char *author, const char *committer, int allow_bad_symlinks,
495 struct got_object_id *branch_tip, const char *branch_name,
496 int allow_conflict, struct got_repository *repo,
497 got_worktree_status_cb status_cb, void *status_arg);
499 /*
500 * Complete the merge operation.
501 * This should be called once changes have been successfully committed.
502 */
503 const struct got_error *got_worktree_merge_complete(
504 struct got_worktree *worktree, struct got_fileindex *fileindex,
505 struct got_repository *repo);
507 /* Check whether a merge operation is in progress. */
508 const struct got_error *got_worktree_merge_in_progress(int *,
509 struct got_worktree *, struct got_repository *);
511 /*
512 * Prepare for merging a branch into the work tree's current branch: lock the
513 * worktree and check that preconditions are satisfied. The function also
514 * returns a pointer to a fileindex which must be passed back to other
515 * merge-related functions.
516 */
517 const struct got_error *got_worktree_merge_prepare(struct got_fileindex **,
518 struct got_worktree *, struct got_repository *);
520 /*
521 * This function creates a reference to the branch being merged, and to
522 * this branch's current tip commit, in the "got/worktree/merge/" namespace.
523 * These references are used to keep track of merge operation state and are
524 * used as input and/or output arguments with other merge-related functions.
525 */
526 const struct got_error *got_worktree_merge_write_refs(struct got_worktree *,
527 struct got_reference *, struct got_repository *);
529 /*
530 * Continue an interrupted merge operation.
531 * This function returns name of the branch being merged, and the ID of the
532 * tip commit being merged.
533 * This function should be called before either resuming or aborting a
534 * merge operation.
535 * The function also returns a pointer to a fileindex which must be
536 * passed back to other merge-related functions.
537 */
538 const struct got_error *got_worktree_merge_continue(char **,
539 struct got_object_id **, struct got_fileindex **,
540 struct got_worktree *, struct got_repository *);
542 /*
543 * Abort the current rebase operation.
544 * Report reverted files via the specified progress callback.
545 */
546 const struct got_error *got_worktree_merge_abort(struct got_worktree *,
547 struct got_fileindex *, struct got_repository *,
548 got_worktree_checkout_cb, void *);
550 /*
551 * Stage the specified paths for commit.
552 * If the patch callback is not NULL, call it to select patch hunks for
553 * staging. Otherwise, stage the full file content found at each path.
554 * If a path being staged contains a symlink which points outside
555 * of the path space under version control, raise an error unless
556 * staging of such paths is being forced by the caller.
557 */
558 const struct got_error *got_worktree_stage(struct got_worktree *,
559 struct got_pathlist_head *, got_worktree_status_cb, void *,
560 got_worktree_patch_cb, void *, int, struct got_repository *);
562 /*
563 * Merge staged changes for the specified paths back into the work tree
564 * and mark the paths as non-staged again.
565 */
566 const struct got_error *got_worktree_unstage(struct got_worktree *,
567 struct got_pathlist_head *, got_worktree_checkout_cb, void *,
568 got_worktree_patch_cb, void *, struct got_repository *);
570 /* A callback function which is invoked with per-path info. */
571 typedef const struct got_error *(*got_worktree_path_info_cb)(void *,
572 const char *path, mode_t mode, time_t mtime,
573 struct got_object_id *blob_id, struct got_object_id *staged_blob_id,
574 struct got_object_id *commit_id);
576 /*
577 * Report work-tree meta data for paths in the work tree.
578 * The info callback will be invoked with the provided void * argument,
579 * a path, and meta-data arguments (see got_worktree_path_info_cb).
580 */
581 const struct got_error *
582 got_worktree_path_info(struct got_worktree *, struct got_pathlist_head *,
583 got_worktree_path_info_cb, void *, got_cancel_cb , void *);
585 /* References pointing at pre-rebase commit backups. */
586 #define GOT_WORKTREE_REBASE_BACKUP_REF_PREFIX "refs/got/backup/rebase"
588 /* References pointing at pre-histedit commit backups. */
589 #define GOT_WORKTREE_HISTEDIT_BACKUP_REF_PREFIX "refs/got/backup/histedit"
591 /*
592 * Prepare for applying a patch.
593 */
594 const struct got_error *
595 got_worktree_patch_prepare(struct got_fileindex **, char **,
596 struct got_worktree *);
598 /*
599 * Lookup paths for the "old" and "new" file before patching and check their
600 * status.
601 */
602 const struct got_error *
603 got_worktree_patch_check_path(const char *, const char *, char **, char **,
604 struct got_worktree *, struct got_repository *, struct got_fileindex *);
606 const struct got_error *
607 got_worktree_patch_schedule_add(const char *, struct got_repository *,
608 struct got_worktree *, struct got_fileindex *, got_worktree_checkout_cb,
609 void *);
611 const struct got_error *
612 got_worktree_patch_schedule_rm(const char *, struct got_repository *,
613 struct got_worktree *, struct got_fileindex *, got_worktree_delete_cb,
614 void *);
616 /* Complete the patch operation. */
617 const struct got_error *
618 got_worktree_patch_complete(struct got_fileindex *, const char *);