do not leak gotwebd sockets memory at shutdown time
[got-portable.git] / include / got_worktree.h
blobc3fa46bbe00087fcbd8a9b114bedd1cabed012d6
1 /*
2 * Copyright (c) 2018, 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
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"
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 specifies 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.
56 const struct got_error *got_worktree_init(const char *, struct got_reference *,
57 const char *, const char *, struct got_repository *);
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().
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 *);
73 * Get the path to the root directory of a worktree.
75 const char *got_worktree_get_root_path(struct got_worktree *);
78 * Get the path to the repository associated with a worktree.
80 const char *got_worktree_get_repo_path(struct got_worktree *);
83 * Get the path prefix associated with a worktree.
85 const char *got_worktree_get_path_prefix(struct got_worktree *);
88 * Get the UUID of a work tree as a string.
89 * The caller must dispose of the returned UUID string with free(3).
91 const struct got_error *got_worktree_get_uuid(char **, struct got_worktree *);
94 * Get the work tree's format version number.
96 int got_worktree_get_format_version(struct got_worktree *);
99 * Check if a user-provided path prefix matches that of the worktree.
101 const struct got_error *got_worktree_match_path_prefix(int *,
102 struct got_worktree *, const char *);
105 * Prefix for references pointing at base commit of backout/cherrypick commits.
106 * Reference path takes the form: PREFIX-WORKTREE_UUID-COMMIT_ID
108 #define GOT_WORKTREE_CHERRYPICK_REF_PREFIX "refs/got/worktree/cherrypick"
109 #define GOT_WORKTREE_BACKOUT_REF_PREFIX "refs/got/worktree/backout"
111 #define GOT_WORKTREE_CHERRYPICK_REF_PREFIX_LEN \
112 sizeof(GOT_WORKTREE_CHERRYPICK_REF_PREFIX) - 1
113 #define GOT_WORKTREE_BACKOUT_REF_PREFIX_LEN \
114 sizeof(GOT_WORKTREE_BACKOUT_REF_PREFIX) - 1
115 #define GOT_WORKTREE_UUID_STRLEN 36
117 const struct got_error *got_worktree_get_logmsg_ref_name(char **,
118 struct got_worktree *, const char *);
120 * Get the name of a work tree's HEAD reference.
122 const char *got_worktree_get_head_ref_name(struct got_worktree *);
125 * Set the branch head reference of the work tree.
127 const struct got_error *got_worktree_set_head_ref(struct got_worktree *,
128 struct got_reference *);
131 * Get the current base commit ID of a worktree.
133 struct got_object_id *got_worktree_get_base_commit_id(struct got_worktree *);
136 * Set the base commit Id of a worktree.
138 const struct got_error *got_worktree_set_base_commit_id(struct got_worktree *,
139 struct got_repository *, struct got_object_id *);
142 * Get the state of the work tree. If the work tree's global base commit is
143 * the tip of the work tree's current branch, and each file in the index is
144 * based on this same commit, the char out parameter will be
145 * GOT_WORKTREE_STATE_UPTODATE, else it will be GOT_WORKTREE_STATE_OUTOFDATE.
147 const struct got_error *got_worktree_get_state(char *,
148 struct got_repository *, struct got_worktree *,
149 got_cancel_cb, void *);
151 #define GOT_WORKTREE_STATE_UNKNOWN ' '
152 #define GOT_WORKTREE_STATE_UPTODATE '*'
153 #define GOT_WORKTREE_STATE_OUTOFDATE '~'
156 * Obtain a parsed representation of this worktree's got.conf file.
157 * Return NULL if this configuration file could not be read.
159 const struct got_gotconfig *got_worktree_get_gotconfig(struct got_worktree *);
161 /* A callback function which is invoked when a path is checked out. */
162 typedef const struct got_error *(*got_worktree_checkout_cb)(void *,
163 unsigned char, const char *);
165 /* A callback function which is invoked when a path is removed. */
166 typedef const struct got_error *(*got_worktree_delete_cb)(void *,
167 unsigned char, unsigned char, const char *);
170 * Attempt to check out files into a work tree from its associated repository
171 * and path prefix, and update the work tree's file index accordingly.
172 * File content is obtained from blobs within the work tree's path prefix
173 * inside the tree corresponding to the work tree's base commit.
174 * The checkout progress callback will be invoked with the provided
175 * void * argument, and the path of each checked out file.
177 * It is possible to restrict the checkout operation to specific paths in
178 * the work tree, in which case all files outside those paths will remain at
179 * their currently recorded base commit. Inconsistent base commits can be
180 * repaired later by running another update operation across the entire work
181 * tree. Inconsistent base-commits may also occur if this function runs into
182 * an error or if the checkout operation is cancelled by the cancel callback.
183 * Allspecified paths are relative to the work tree's root. Pass a pathlist
184 * with a single empty path "" to check out files across the entire work tree.
186 * Some operations may refuse to run while the work tree contains files from
187 * multiple base commits.
189 const struct got_error *got_worktree_checkout_files(struct got_worktree *,
190 struct got_pathlist_head *, struct got_repository *,
191 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
193 /* Merge the differences between two commits into a work tree. */
194 const struct got_error *
195 got_worktree_merge_files(struct got_worktree *,
196 struct got_object_id *, struct got_object_id *,
197 struct got_repository *, got_worktree_checkout_cb, void *,
198 got_cancel_cb, void *);
201 * A callback function which is invoked to report a file's status.
203 * If a valid directory file descriptor and a directory entry name are passed,
204 * these should be used to open the file instead of opening the file by path.
205 * This prevents race conditions if the filesystem is modified concurrently.
206 * If the directory descriptor is not available then its value will be -1.
208 typedef const struct got_error *(*got_worktree_status_cb)(void *,
209 unsigned char, unsigned char, const char *, struct got_object_id *,
210 struct got_object_id *, struct got_object_id *, int, const char *);
213 * Report the status of paths in the work tree.
214 * The status callback will be invoked with the provided void * argument,
215 * a path, and a corresponding status code.
217 const struct got_error *got_worktree_status(struct got_worktree *,
218 struct got_pathlist_head *, struct got_repository *, int no_ignores,
219 got_worktree_status_cb, void *, got_cancel_cb cancel_cb, void *);
222 * Try to resolve a user-provided path to an on-disk path in the work tree.
223 * The caller must dispose of the resolved path with free(3).
225 const struct got_error *got_worktree_resolve_path(char **,
226 struct got_worktree *, const char *);
228 /* Schedule files at on-disk paths for addition in the next commit. */
229 const struct got_error *got_worktree_schedule_add(struct got_worktree *,
230 struct got_pathlist_head *, got_worktree_checkout_cb, void *,
231 struct got_repository *, int);
234 * Remove files from disk and schedule them to be deleted in the next commit.
235 * Don't allow deleting files with uncommitted modifications, unless the
236 * parameter 'delete_local_mods' is set.
238 const struct got_error *
239 got_worktree_schedule_delete(struct got_worktree *,
240 struct got_pathlist_head *, int, const char *,
241 got_worktree_delete_cb, void *, struct got_repository *, int, int);
243 /* A callback function which is used to select or reject a patch. */
244 typedef const struct got_error *(*got_worktree_patch_cb)(int *, void *,
245 unsigned char, const char *, FILE *, int, int);
247 /* Values for result output parameter of got_wortree_patch_cb. */
248 #define GOT_PATCH_CHOICE_NONE 0
249 #define GOT_PATCH_CHOICE_YES 1
250 #define GOT_PATCH_CHOICE_NO 2
251 #define GOT_PATCH_CHOICE_QUIT 3
254 * Revert a file at the specified path such that it matches its
255 * original state in the worktree's base commit.
256 * If the patch callback is not NULL, call it to select patch hunks to
257 * revert. Otherwise, revert the whole file found at each path.
259 const struct got_error *got_worktree_revert(struct got_worktree *,
260 struct got_pathlist_head *, got_worktree_checkout_cb, void *,
261 got_worktree_patch_cb patch_cb, void *patch_arg,
262 struct got_repository *);
265 * A callback function which is invoked when a commit message is requested.
266 * Passes a pathlist with a struct got_commitable * in the data pointer of
267 * each element, the path to a file which contains a diff of changes to be
268 * committed (may be NULL), and a pointer to the log message that must be
269 * set by the callback and will be freed after committing, and an argument
270 * passed through to the callback.
272 typedef const struct got_error *(*got_worktree_commit_msg_cb)(
273 struct got_pathlist_head *, const char *, char **, void *);
276 * Create a new commit from changes in the work tree.
277 * Return the ID of the newly created commit.
278 * The worktree's base commit will be set to this new commit.
279 * Files unaffected by this commit operation will retain their
280 * current base commit.
281 * An author and a non-empty log message must be specified.
282 * The name of the committer is optional (may be NULL).
283 * If a path to be committed contains a symlink which points outside
284 * of the path space under version control, raise an error unless
285 * committing of such paths is being forced by the caller.
287 const struct got_error *got_worktree_commit(struct got_object_id **,
288 struct got_worktree *, struct got_pathlist_head *, const char *,
289 const char *, int, int, int, got_worktree_commit_msg_cb, void *,
290 got_worktree_status_cb, void *, struct got_repository *);
292 /* Get the path of a committable worktree item. */
293 const char *got_commitable_get_path(struct got_commitable *);
295 /* Get the status of a committable worktree item. */
296 unsigned int got_commitable_get_status(struct got_commitable *);
299 * Prepare for rebasing a branch onto the work tree's current branch.
300 * This function creates references to a temporary branch, the branch
301 * being rebased, and the work tree's current branch, under the
302 * "got/worktree/rebase/" namespace. These references are used to
303 * keep track of rebase operation state and are used as input and/or
304 * output arguments with other rebase-related functions.
305 * The function also returns a pointer to a fileindex which must be
306 * passed back to other rebase-related functions.
308 const struct got_error *got_worktree_rebase_prepare(struct got_reference **,
309 struct got_reference **, struct got_fileindex **, struct got_worktree *,
310 struct got_reference *, struct got_repository *);
313 * Continue an interrupted rebase operation.
314 * This function returns existing references created when rebase was prepared,
315 * and the ID of the commit currently being rebased. This should be called
316 * before either resuming or aborting a rebase operation.
317 * The function also returns a pointer to a fileindex which must be
318 * passed back to other rebase-related functions.
320 const struct got_error *got_worktree_rebase_continue(struct got_object_id **,
321 struct got_reference **, struct got_reference **, struct got_reference **,
322 struct got_fileindex **, struct got_worktree *, struct got_repository *);
324 /* Check whether a, potentially interrupted, rebase operation is in progress. */
325 const struct got_error *got_worktree_rebase_in_progress(int *,
326 struct got_worktree *);
327 /* Return information about an in-progress rebase operation. */
328 const struct got_error *got_worktree_rebase_info(char **new_base_branch_name,
329 char **branch_name, struct got_worktree *, struct got_repository *);
332 * Merge changes from the commit currently being rebased into the work tree.
333 * Report affected files, including merge conflicts, via the specified
334 * progress callback. Also populate a list of affected paths which should
335 * be passed to got_worktree_rebase_commit() after a conflict-free merge.
336 * This list must be initialized with TAILQ_INIT() and disposed of with
337 * got_pathlist_free(list, GOT_PATHLIST_FREE_PATH).
339 const struct got_error *got_worktree_rebase_merge_files(
340 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
341 struct got_object_id *, struct got_object_id *, struct got_repository *,
342 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
345 * Commit changes merged by got_worktree_rebase_merge_files() to a temporary
346 * branch and return the ID of the newly created commit. An optional list of
347 * merged paths can be provided; otherwise this function will perform a status
348 * crawl across the entire work tree to find paths to commit.
350 const struct got_error *got_worktree_rebase_commit(struct got_object_id **,
351 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
352 struct got_reference *, const char *, struct got_commit_object *,
353 struct got_object_id *, int, struct got_repository *);
355 /* Postpone the rebase operation. Should be called after a merge conflict. */
356 const struct got_error *got_worktree_rebase_postpone(struct got_worktree *,
357 struct got_fileindex *);
360 * Complete the current rebase operation. This should be called once all
361 * commits have been rebased successfully.
362 * The create_backup parameter controls whether the rebased branch will
363 * be backed up via a reference in refs/got/backup/rebase/.
365 const struct got_error *got_worktree_rebase_complete(struct got_worktree *,
366 struct got_fileindex *, struct got_reference *, struct got_reference *,
367 struct got_repository *, int create_backup);
370 * Abort the current rebase operation.
371 * Report reverted files via the specified progress callback.
373 const struct got_error *got_worktree_rebase_abort(struct got_worktree *,
374 struct got_fileindex *, struct got_repository *, struct got_reference *,
375 got_worktree_checkout_cb, void *);
378 * Prepare for editing the history of the work tree's current branch.
379 * This function creates references to a temporary branch, and the
380 * work tree's current branch, under the "got/worktree/histedit/" namespace.
381 * These references are used to keep track of histedit operation state and
382 * are used as input and/or output arguments with other histedit-related
383 * functions.
385 const struct got_error *got_worktree_histedit_prepare(struct got_reference **,
386 struct got_reference **, struct got_object_id **, struct got_fileindex **,
387 struct got_worktree *, struct got_repository *);
390 * Continue an interrupted histedit operation.
391 * This function returns existing references created when histedit was
392 * prepared and the ID of the commit currently being edited.
393 * It should be called before resuming or aborting a histedit operation.
395 const struct got_error *got_worktree_histedit_continue(struct got_object_id **,
396 struct got_reference **, struct got_reference **, struct got_object_id **,
397 struct got_fileindex **, struct got_worktree *, struct got_repository *);
399 /* Check whether a histedit operation is in progress. */
400 const struct got_error *got_worktree_histedit_in_progress(int *,
401 struct got_worktree *);
402 /* Return information about an in-progress histedit operation. */
403 const struct got_error *got_worktree_histedit_info(
404 char **branch_nane, struct got_worktree *,
405 struct got_repository *);
408 * Merge changes from the commit currently being edited into the work tree.
409 * Report affected files, including merge conflicts, via the specified
410 * progress callback. Also populate a list of affected paths which should
411 * be passed to got_worktree_histedit_commit() after a conflict-free merge.
412 * This list must be initialized with TAILQ_INIT() and disposed of with
413 * got_pathlist_free(list, GOT_PATHLIST_FREE_PATH).
415 const struct got_error *got_worktree_histedit_merge_files(
416 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
417 struct got_object_id *, struct got_object_id *, struct got_repository *,
418 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
421 * Commit changes merged by got_worktree_histedit_merge_files() to a temporary
422 * branch and return the ID of the newly created commit. An optional list of
423 * merged paths can be provided; otherwise this function will perform a status
424 * crawl across the entire work tree to find paths to commit.
425 * An optional log message can be provided which will be used instead of the
426 * commit's original message.
428 const struct got_error *got_worktree_histedit_commit(struct got_object_id **,
429 struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
430 struct got_reference *, const char *, struct got_commit_object *,
431 struct got_object_id *, const char *, int, struct got_repository *);
434 * Record the specified commit as skipped during histedit.
435 * This should be called for commits which get dropped or get folded into
436 * a subsequent commit.
438 const struct got_error *got_worktree_histedit_skip_commit(struct got_worktree *,
439 struct got_object_id *, struct got_repository *);
441 /* Postpone the histedit operation. */
442 const struct got_error *got_worktree_histedit_postpone(struct got_worktree *,
443 struct got_fileindex *);
446 * Complete the current histedit operation. This should be called once all
447 * commits have been edited successfully.
449 const struct got_error *got_worktree_histedit_complete(struct got_worktree *,
450 struct got_fileindex *, struct got_reference *, struct got_reference *,
451 struct got_repository *);
454 * Abort the current histedit operation.
455 * Report reverted files via the specified progress callback.
457 const struct got_error *got_worktree_histedit_abort(struct got_worktree *,
458 struct got_fileindex *, struct got_repository *, struct got_reference *,
459 struct got_object_id *, got_worktree_checkout_cb, void *);
461 /* Get the path to this work tree's histedit script file. */
462 const struct got_error *got_worktree_get_histedit_script_path(char **,
463 struct got_worktree *);
466 * Prepare a work tree for integrating a branch.
467 * Return pointers to a fileindex and locked references which must be
468 * passed back to other integrate-related functions.
470 const struct got_error *
471 got_worktree_integrate_prepare(struct got_fileindex **,
472 struct got_reference **, struct got_reference **,
473 struct got_worktree *, const char *, struct got_repository *);
476 * Carry out a prepared branch integration operation.
477 * Report affected files via the specified progress callback.
479 const struct got_error *got_worktree_integrate_continue(
480 struct got_worktree *, struct got_fileindex *, struct got_repository *,
481 struct got_reference *, struct got_reference *,
482 got_worktree_checkout_cb, void *, got_cancel_cb, void *);
484 /* Abort a prepared branch integration operation. */
485 const struct got_error *got_worktree_integrate_abort(struct got_worktree *,
486 struct got_fileindex *, struct got_repository *,
487 struct got_reference *, struct got_reference *);
489 /* Postpone the merge operation. Should be called after a merge conflict. */
490 const struct got_error *got_worktree_merge_postpone(struct got_worktree *,
491 struct got_fileindex *);
493 /* Merge changes from the merge source branch into the worktree. */
494 const struct got_error *
495 got_worktree_merge_branch(struct got_worktree *worktree,
496 struct got_fileindex *fileindex,
497 struct got_object_id *yca_commit_id,
498 struct got_object_id *branch_tip,
499 struct got_repository *repo, got_worktree_checkout_cb progress_cb,
500 void *progress_arg, got_cancel_cb cancel_cb, void *cancel_arg);
502 /* Attempt to commit merged changes. */
503 const struct got_error *
504 got_worktree_merge_commit(struct got_object_id **new_commit_id,
505 struct got_worktree *worktree, struct got_fileindex *fileindex,
506 const char *author, const char *committer, int allow_bad_symlinks,
507 struct got_object_id *branch_tip, const char *branch_name,
508 int allow_conflict, struct got_repository *repo,
509 got_worktree_status_cb status_cb, void *status_arg);
512 * Complete the merge operation.
513 * This should be called once changes have been successfully committed.
515 const struct got_error *got_worktree_merge_complete(
516 struct got_worktree *worktree, struct got_fileindex *fileindex,
517 struct got_repository *repo);
519 /* Check whether a merge operation is in progress. */
520 const struct got_error *got_worktree_merge_in_progress(int *,
521 struct got_worktree *, struct got_repository *);
522 /* Return information about an in-progress merge operation. */
523 const struct got_error *
524 got_worktree_merge_info(char **branch_name, struct got_worktree *,
525 struct got_repository *);
528 * Prepare for merging a branch into the work tree's current branch: lock the
529 * worktree and check that preconditions are satisfied. The function also
530 * returns a pointer to a fileindex which must be passed back to other
531 * merge-related functions.
533 const struct got_error *got_worktree_merge_prepare(struct got_fileindex **,
534 struct got_worktree *, struct got_repository *);
537 * This function creates a reference to the branch being merged, and to
538 * this branch's current tip commit, in the "got/worktree/merge/" namespace.
539 * These references are used to keep track of merge operation state and are
540 * used as input and/or output arguments with other merge-related functions.
542 const struct got_error *got_worktree_merge_write_refs(struct got_worktree *,
543 struct got_reference *, struct got_repository *);
546 * Continue an interrupted merge operation.
547 * This function returns name of the branch being merged, and the ID of the
548 * tip commit being merged.
549 * This function should be called before either resuming or aborting a
550 * merge operation.
551 * The function also returns a pointer to a fileindex which must be
552 * passed back to other merge-related functions.
554 const struct got_error *got_worktree_merge_continue(char **,
555 struct got_object_id **, struct got_fileindex **,
556 struct got_worktree *, struct got_repository *);
559 * Abort the current rebase operation.
560 * Report reverted files via the specified progress callback.
562 const struct got_error *got_worktree_merge_abort(struct got_worktree *,
563 struct got_fileindex *, struct got_repository *,
564 got_worktree_checkout_cb, void *);
567 * Stage the specified paths for commit.
568 * If the patch callback is not NULL, call it to select patch hunks for
569 * staging. Otherwise, stage the full file content found at each path.
570 * If a path being staged contains a symlink which points outside
571 * of the path space under version control, raise an error unless
572 * staging of such paths is being forced by the caller.
574 const struct got_error *got_worktree_stage(struct got_worktree *,
575 struct got_pathlist_head *, got_worktree_status_cb, void *,
576 got_worktree_patch_cb, void *, int, struct got_repository *);
579 * Merge staged changes for the specified paths back into the work tree
580 * and mark the paths as non-staged again.
582 const struct got_error *got_worktree_unstage(struct got_worktree *,
583 struct got_pathlist_head *, got_worktree_checkout_cb, void *,
584 got_worktree_patch_cb, void *, struct got_repository *);
587 * Prepare for getting meta data for paths in the work tree. This
588 * function also returns a pointer to a fileindex which must be passed
589 * back to other path_info-related functions and *_version() functions.
591 const struct got_error *
592 got_worktree_path_info_prepare(struct got_fileindex **,
593 struct got_worktree *, struct got_repository *);
596 * Get the file-index version.
598 uint32_t
599 got_worktree_get_fileindex_version(struct got_fileindex *);
601 /* A callback function which is invoked with per-path info. */
602 typedef const struct got_error *(*got_worktree_path_info_cb)(void *,
603 const char *path, mode_t mode, time_t mtime,
604 struct got_object_id *blob_id, struct got_object_id *staged_blob_id,
605 struct got_object_id *commit_id);
608 * Report work-tree meta data for paths in the work tree.
609 * The info callback will be invoked with the provided void * argument,
610 * a path, and meta-data arguments (see got_worktree_path_info_cb).
612 const struct got_error *
613 got_worktree_path_info(struct got_worktree *, struct got_fileindex *,
614 struct got_pathlist_head *, got_worktree_path_info_cb, void *,
615 got_cancel_cb , void *);
618 * Complete the current path_info operation.
620 const struct got_error *
621 got_worktree_path_info_complete(struct got_fileindex *, struct got_worktree *);
623 /* References pointing at pre-rebase commit backups. */
624 #define GOT_WORKTREE_REBASE_BACKUP_REF_PREFIX "refs/got/backup/rebase"
626 /* References pointing at pre-histedit commit backups. */
627 #define GOT_WORKTREE_HISTEDIT_BACKUP_REF_PREFIX "refs/got/backup/histedit"
630 * Prepare for applying a patch.
632 const struct got_error *
633 got_worktree_patch_prepare(struct got_fileindex **, char **,
634 struct got_worktree *, struct got_repository *);
637 * Lookup paths for the "old" and "new" file before patching and check their
638 * status.
640 const struct got_error *
641 got_worktree_patch_check_path(const char *, const char *, char **, char **,
642 struct got_worktree *, struct got_repository *, struct got_fileindex *);
644 const struct got_error *
645 got_worktree_patch_schedule_add(const char *, struct got_repository *,
646 struct got_worktree *, struct got_fileindex *, got_worktree_checkout_cb,
647 void *);
649 const struct got_error *
650 got_worktree_patch_schedule_rm(const char *, struct got_repository *,
651 struct got_worktree *, struct got_fileindex *, got_worktree_delete_cb,
652 void *);
654 /* Complete the patch operation. */
655 const struct got_error *
656 got_worktree_patch_complete(struct got_worktree *, struct got_fileindex *,
657 const char *);