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