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