Blame


1 86c3caaf 2018-03-09 stsp /*
2 5d56da81 2019-01-13 stsp * Copyright (c) 2018, 2019 Stefan Sperling <stsp@openbsd.org>
3 86c3caaf 2018-03-09 stsp *
4 86c3caaf 2018-03-09 stsp * Permission to use, copy, modify, and distribute this software for any
5 86c3caaf 2018-03-09 stsp * purpose with or without fee is hereby granted, provided that the above
6 86c3caaf 2018-03-09 stsp * copyright notice and this permission notice appear in all copies.
7 86c3caaf 2018-03-09 stsp *
8 86c3caaf 2018-03-09 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 86c3caaf 2018-03-09 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 86c3caaf 2018-03-09 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 86c3caaf 2018-03-09 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 86c3caaf 2018-03-09 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 86c3caaf 2018-03-09 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 86c3caaf 2018-03-09 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 86c3caaf 2018-03-09 stsp */
16 86c3caaf 2018-03-09 stsp
17 86c3caaf 2018-03-09 stsp struct got_worktree;
18 8656d6c4 2019-05-20 stsp struct got_commitable;
19 818c7501 2019-07-11 stsp struct got_commit_object;
20 3e3a69f1 2019-07-25 stsp struct got_fileindex;
21 86c3caaf 2018-03-09 stsp
22 eecfbcd1 2018-12-29 stsp /* status codes */
23 f8d1f275 2019-02-04 stsp #define GOT_STATUS_NO_CHANGE ' '
24 eecfbcd1 2018-12-29 stsp #define GOT_STATUS_ADD 'A'
25 eecfbcd1 2018-12-29 stsp #define GOT_STATUS_EXISTS 'E'
26 507dc3bb 2018-12-29 stsp #define GOT_STATUS_UPDATE 'U'
27 512f0d0e 2019-01-02 stsp #define GOT_STATUS_DELETE 'D'
28 276262e8 2019-02-08 stsp #define GOT_STATUS_MODIFY 'M'
29 1ebedb77 2019-10-19 stsp #define GOT_STATUS_MODE_CHANGE 'm'
30 6353ad76 2019-02-08 stsp #define GOT_STATUS_CONFLICT 'C'
31 6353ad76 2019-02-08 stsp #define GOT_STATUS_MERGE 'G'
32 f8d1f275 2019-02-04 stsp #define GOT_STATUS_MISSING '!'
33 f8d1f275 2019-02-04 stsp #define GOT_STATUS_UNVERSIONED '?'
34 0dbc2271 2019-02-05 stsp #define GOT_STATUS_OBSTRUCTED '~'
35 2a06fe5f 2019-08-24 stsp #define GOT_STATUS_NONEXISTENT 'N'
36 a129376b 2019-03-28 stsp #define GOT_STATUS_REVERT 'R'
37 2b92fad7 2019-06-02 stsp #define GOT_STATUS_CANNOT_DELETE 'd'
38 a484d721 2019-06-10 stsp #define GOT_STATUS_BUMP_BASE 'b'
39 eecfbcd1 2018-12-29 stsp
40 0c60ce5a 2018-04-02 stsp /*
41 0c60ce5a 2018-04-02 stsp * Attempt to initialize a new work tree on disk.
42 0c60ce5a 2018-04-02 stsp * The first argument is the path to a directory where the work tree
43 0c60ce5a 2018-04-02 stsp * will be created. The path itself must not yet exist, but the dirname(3)
44 0c60ce5a 2018-04-02 stsp * of the path must already exist.
45 93a30277 2018-12-24 stsp * The reference provided will be used to determine the new worktree's
46 93a30277 2018-12-24 stsp * base commit. The third argument speficies the work tree's path prefix.
47 0c60ce5a 2018-04-02 stsp */
48 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_init(const char *, struct got_reference *,
49 577ec78f 2018-03-11 stsp const char *, struct got_repository *);
50 0c60ce5a 2018-04-02 stsp
51 0c60ce5a 2018-04-02 stsp /*
52 247140b2 2019-02-05 stsp * Attempt to open a worktree at or above the specified path.
53 0c60ce5a 2018-04-02 stsp * The caller must dispose of it with got_worktree_close().
54 0c60ce5a 2018-04-02 stsp */
55 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_open(struct got_worktree **, const char *);
56 0c60ce5a 2018-04-02 stsp
57 0c60ce5a 2018-04-02 stsp /* Dispose of an open work tree. */
58 3a6ce05a 2019-02-11 stsp const struct got_error *got_worktree_close(struct got_worktree *);
59 0c60ce5a 2018-04-02 stsp
60 0c60ce5a 2018-04-02 stsp /*
61 c7f4312f 2019-02-05 stsp * Get the path to the root directory of a worktree.
62 c7f4312f 2019-02-05 stsp */
63 c7f4312f 2019-02-05 stsp const char *got_worktree_get_root_path(struct got_worktree *);
64 c7f4312f 2019-02-05 stsp
65 c7f4312f 2019-02-05 stsp /*
66 0c60ce5a 2018-04-02 stsp * Get the path to the repository associated with a worktree.
67 0c60ce5a 2018-04-02 stsp */
68 2fbdb5ae 2018-12-29 stsp const char *got_worktree_get_repo_path(struct got_worktree *);
69 0c60ce5a 2018-04-02 stsp
70 0c60ce5a 2018-04-02 stsp /*
71 49520a32 2018-12-29 stsp * Get the path prefix associated with a worktree.
72 49520a32 2018-12-29 stsp */
73 49520a32 2018-12-29 stsp const char *got_worktree_get_path_prefix(struct got_worktree *);
74 49520a32 2018-12-29 stsp
75 49520a32 2018-12-29 stsp /*
76 e5dc7198 2018-12-29 stsp * Check if a user-provided path prefix matches that of the worktree.
77 e5dc7198 2018-12-29 stsp */
78 e5dc7198 2018-12-29 stsp const struct got_error *got_worktree_match_path_prefix(int *,
79 e5dc7198 2018-12-29 stsp struct got_worktree *, const char *);
80 e5dc7198 2018-12-29 stsp
81 e5dc7198 2018-12-29 stsp /*
82 0c60ce5a 2018-04-02 stsp * Get the name of a work tree's HEAD reference.
83 0c60ce5a 2018-04-02 stsp */
84 bc70eb79 2019-05-09 stsp const char *got_worktree_get_head_ref_name(struct got_worktree *);
85 0c60ce5a 2018-04-02 stsp
86 507dc3bb 2018-12-29 stsp /*
87 024e9686 2019-05-14 stsp * Set the branch head reference of the work tree.
88 024e9686 2019-05-14 stsp */
89 024e9686 2019-05-14 stsp const struct got_error *got_worktree_set_head_ref(struct got_worktree *,
90 024e9686 2019-05-14 stsp struct got_reference *);
91 024e9686 2019-05-14 stsp
92 024e9686 2019-05-14 stsp /*
93 507dc3bb 2018-12-29 stsp * Get the current base commit ID of a worktree.
94 507dc3bb 2018-12-29 stsp */
95 b72f483a 2019-02-05 stsp struct got_object_id *got_worktree_get_base_commit_id(struct got_worktree *);
96 507dc3bb 2018-12-29 stsp
97 507dc3bb 2018-12-29 stsp /*
98 507dc3bb 2018-12-29 stsp * Set the base commit Id of a worktree.
99 507dc3bb 2018-12-29 stsp */
100 507dc3bb 2018-12-29 stsp const struct got_error *got_worktree_set_base_commit_id(struct got_worktree *,
101 507dc3bb 2018-12-29 stsp struct got_repository *, struct got_object_id *);
102 507dc3bb 2018-12-29 stsp
103 0c60ce5a 2018-04-02 stsp /* A callback function which is invoked when a path is checked out. */
104 1ee397ad 2019-07-12 stsp typedef const struct got_error *(*got_worktree_checkout_cb)(void *,
105 1ee397ad 2019-07-12 stsp unsigned char, const char *);
106 f2a9dc41 2019-12-13 tracey
107 f2a9dc41 2019-12-13 tracey /* A callback function which is invoked when a path is removed. */
108 f2a9dc41 2019-12-13 tracey typedef const struct got_error *(*got_worktree_delete_cb)(void *,
109 f2a9dc41 2019-12-13 tracey unsigned char, unsigned char, const char *);
110 0c60ce5a 2018-04-02 stsp
111 0c60ce5a 2018-04-02 stsp /*
112 0c60ce5a 2018-04-02 stsp * Attempt to check out files into a work tree from its associated repository
113 0c60ce5a 2018-04-02 stsp * and path prefix, and update the work tree's file index accordingly.
114 0c60ce5a 2018-04-02 stsp * File content is obtained from blobs within the work tree's path prefix
115 93a30277 2018-12-24 stsp * inside the tree corresponding to the work tree's base commit.
116 0c60ce5a 2018-04-02 stsp * The checkout progress callback will be invoked with the provided
117 0c60ce5a 2018-04-02 stsp * void * argument, and the path of each checked out file.
118 c4cdcb68 2019-04-03 stsp *
119 f2ea84fa 2019-07-27 stsp * It is possible to restrict the checkout operation to specific paths in
120 f2ea84fa 2019-07-27 stsp * the work tree, in which case all files outside those paths will remain at
121 c4cdcb68 2019-04-03 stsp * their currently recorded base commit. Inconsistent base commits can be
122 c4cdcb68 2019-04-03 stsp * repaired later by running another update operation across the entire work
123 c4cdcb68 2019-04-03 stsp * tree. Inconsistent base-commits may also occur if this function runs into
124 c4cdcb68 2019-04-03 stsp * an error or if the checkout operation is cancelled by the cancel callback.
125 f2ea84fa 2019-07-27 stsp * Allspecified paths are relative to the work tree's root. Pass a pathlist
126 f2ea84fa 2019-07-27 stsp * with a single empty path "" to check out files across the entire work tree.
127 c4cdcb68 2019-04-03 stsp *
128 c4cdcb68 2019-04-03 stsp * Some operations may refuse to run while the work tree contains files from
129 c4cdcb68 2019-04-03 stsp * multiple base commits.
130 0c60ce5a 2018-04-02 stsp */
131 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_checkout_files(struct got_worktree *,
132 f2ea84fa 2019-07-27 stsp struct got_pathlist_head *, struct got_repository *,
133 e6209546 2019-08-22 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
134 507dc3bb 2018-12-29 stsp
135 234035bc 2019-06-01 stsp /* Merge the differences between two commits into a work tree. */
136 234035bc 2019-06-01 stsp const struct got_error *
137 234035bc 2019-06-01 stsp got_worktree_merge_files(struct got_worktree *,
138 234035bc 2019-06-01 stsp struct got_object_id *, struct got_object_id *,
139 234035bc 2019-06-01 stsp struct got_repository *, got_worktree_checkout_cb, void *,
140 e6209546 2019-08-22 stsp got_cancel_cb, void *);
141 234035bc 2019-06-01 stsp
142 12463d8b 2019-12-13 stsp /*
143 12463d8b 2019-12-13 stsp * A callback function which is invoked to report a file's status.
144 12463d8b 2019-12-13 stsp *
145 12463d8b 2019-12-13 stsp * If a valid directory file descriptor and a directory entry name are passed,
146 12463d8b 2019-12-13 stsp * these should be used to open the file instead of opening the file by path.
147 12463d8b 2019-12-13 stsp * This prevents race conditions if the filesystem is modified concurrently.
148 12463d8b 2019-12-13 stsp * If the directory descriptor is not available then its value will be -1.
149 12463d8b 2019-12-13 stsp */
150 b72f483a 2019-02-05 stsp typedef const struct got_error *(*got_worktree_status_cb)(void *,
151 88d0e355 2019-08-03 stsp unsigned char, unsigned char, const char *, struct got_object_id *,
152 12463d8b 2019-12-13 stsp struct got_object_id *, struct got_object_id *, int, const char *);
153 f8d1f275 2019-02-04 stsp
154 f8d1f275 2019-02-04 stsp /*
155 f8d1f275 2019-02-04 stsp * Report the status of paths in the work tree.
156 f8d1f275 2019-02-04 stsp * The status callback will be invoked with the provided void * argument,
157 f8d1f275 2019-02-04 stsp * a path, and a corresponding status code.
158 f8d1f275 2019-02-04 stsp */
159 6c34b1aa 2019-03-18 stsp const struct got_error *got_worktree_status(struct got_worktree *,
160 72ea6654 2019-07-27 stsp struct got_pathlist_head *, struct got_repository *,
161 e6209546 2019-08-22 stsp got_worktree_status_cb, void *, got_cancel_cb cancel_cb, void *);
162 6c7ab921 2019-03-18 stsp
163 6c7ab921 2019-03-18 stsp /*
164 6c7ab921 2019-03-18 stsp * Try to resolve a user-provided path to an on-disk path in the work tree.
165 6c7ab921 2019-03-18 stsp * The caller must dispose of the resolved path with free(3).
166 6c7ab921 2019-03-18 stsp */
167 6c7ab921 2019-03-18 stsp const struct got_error *got_worktree_resolve_path(char **,
168 6c7ab921 2019-03-18 stsp struct got_worktree *, const char *);
169 d00136be 2019-03-26 stsp
170 1dd54920 2019-05-11 stsp /* Schedule files at on-disk paths for addition in the next commit. */
171 031a5338 2019-03-26 stsp const struct got_error *got_worktree_schedule_add(struct got_worktree *,
172 4e68cba3 2019-11-23 stsp struct got_pathlist_head *, got_worktree_checkout_cb, void *,
173 022fae89 2019-12-06 tracey struct got_repository *, int);
174 2ec1f75b 2019-03-26 stsp
175 2ec1f75b 2019-03-26 stsp /*
176 17ed4618 2019-06-02 stsp * Remove files from disk and schedule them to be deleted in the next commit.
177 2ec1f75b 2019-03-26 stsp * Don't allow deleting files with uncommitted modifications, unless the
178 2ec1f75b 2019-03-26 stsp * parameter 'delete_local_mods' is set.
179 2ec1f75b 2019-03-26 stsp */
180 2ec1f75b 2019-03-26 stsp const struct got_error *
181 17ed4618 2019-06-02 stsp got_worktree_schedule_delete(struct got_worktree *,
182 f2a9dc41 2019-12-13 tracey struct got_pathlist_head *, int, got_worktree_delete_cb, void *,
183 17ed4618 2019-06-02 stsp struct got_repository *);
184 a129376b 2019-03-28 stsp
185 33aa809d 2019-08-08 stsp /* A callback function which is used to select or reject a patch. */
186 33aa809d 2019-08-08 stsp typedef const struct got_error *(*got_worktree_patch_cb)(int *, void *,
187 33aa809d 2019-08-08 stsp unsigned char, const char *, FILE *, int, int);
188 33aa809d 2019-08-08 stsp
189 33aa809d 2019-08-08 stsp /* Values for result output parameter of got_wortree_patch_cb. */
190 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_NONE 0
191 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_YES 1
192 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_NO 2
193 33aa809d 2019-08-08 stsp #define GOT_PATCH_CHOICE_QUIT 3
194 33aa809d 2019-08-08 stsp
195 a129376b 2019-03-28 stsp /*
196 a129376b 2019-03-28 stsp * Revert a file at the specified path such that it matches its
197 a129376b 2019-03-28 stsp * original state in the worktree's base commit.
198 33aa809d 2019-08-08 stsp * If the patch callback is not NULL, call it to select patch hunks to
199 33aa809d 2019-08-08 stsp * revert. Otherwise, revert the whole file found at each path.
200 a129376b 2019-03-28 stsp */
201 a129376b 2019-03-28 stsp const struct got_error *got_worktree_revert(struct got_worktree *,
202 e20a8b6f 2019-06-04 stsp struct got_pathlist_head *, got_worktree_checkout_cb, void *,
203 33aa809d 2019-08-08 stsp got_worktree_patch_cb patch_cb, void *patch_arg,
204 e20a8b6f 2019-06-04 stsp struct got_repository *);
205 c4296144 2019-05-09 stsp
206 c4296144 2019-05-09 stsp /*
207 33ad4cbe 2019-05-12 jcs * A callback function which is invoked when a commit message is requested.
208 8656d6c4 2019-05-20 stsp * Passes a pathlist with a struct got_commitable * in the data pointer of
209 8656d6c4 2019-05-20 stsp * each element, a pointer to the log message that must be set by the
210 8656d6c4 2019-05-20 stsp * callback and will be freed after committing, and an argument passed
211 8656d6c4 2019-05-20 stsp * through to the callback.
212 33ad4cbe 2019-05-12 jcs */
213 33ad4cbe 2019-05-12 jcs typedef const struct got_error *(*got_worktree_commit_msg_cb)(
214 33ad4cbe 2019-05-12 jcs struct got_pathlist_head *, char **, void *);
215 33ad4cbe 2019-05-12 jcs
216 33ad4cbe 2019-05-12 jcs /*
217 c4296144 2019-05-09 stsp * Create a new commit from changes in the work tree.
218 c4296144 2019-05-09 stsp * Return the ID of the newly created commit.
219 c4296144 2019-05-09 stsp * The worktree's base commit will be set to this new commit.
220 c4296144 2019-05-09 stsp * Files unaffected by this commit operation will retain their
221 c4296144 2019-05-09 stsp * current base commit.
222 de18fc63 2019-05-09 stsp * An author and a non-empty log message must be specified.
223 de18fc63 2019-05-09 stsp * The name of the committer is optional (may be NULL).
224 c4296144 2019-05-09 stsp */
225 de18fc63 2019-05-09 stsp const struct got_error *got_worktree_commit(struct got_object_id **,
226 5c1e53bc 2019-07-28 stsp struct got_worktree *, struct got_pathlist_head *, const char *,
227 5c1e53bc 2019-07-28 stsp const char *, got_worktree_commit_msg_cb, void *,
228 33ad4cbe 2019-05-12 jcs got_worktree_status_cb, void *, struct got_repository *);
229 8656d6c4 2019-05-20 stsp
230 8656d6c4 2019-05-20 stsp /* Get the path of a commitable worktree item. */
231 8656d6c4 2019-05-20 stsp const char *got_commitable_get_path(struct got_commitable *);
232 8656d6c4 2019-05-20 stsp
233 8656d6c4 2019-05-20 stsp /* Get the status of a commitable worktree item. */
234 8656d6c4 2019-05-20 stsp unsigned int got_commitable_get_status(struct got_commitable *);
235 818c7501 2019-07-11 stsp
236 818c7501 2019-07-11 stsp /*
237 818c7501 2019-07-11 stsp * Prepare for rebasing a branch onto the work tree's current branch.
238 818c7501 2019-07-11 stsp * This function creates references to a temporary branch, the branch
239 818c7501 2019-07-11 stsp * being rebased, and the work tree's current branch, under the
240 818c7501 2019-07-11 stsp * "got/worktree/rebase/" namespace. These references are used to
241 818c7501 2019-07-11 stsp * keep track of rebase operation state and are used as input and/or
242 818c7501 2019-07-11 stsp * output arguments with other rebase-related functions.
243 3e3a69f1 2019-07-25 stsp * The function also returns a pointer to a fileindex which must be
244 3e3a69f1 2019-07-25 stsp * passed back to other rebase-related functions.
245 818c7501 2019-07-11 stsp */
246 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_prepare(struct got_reference **,
247 3e3a69f1 2019-07-25 stsp struct got_reference **, struct got_fileindex **, struct got_worktree *,
248 3e3a69f1 2019-07-25 stsp struct got_reference *, struct got_repository *);
249 818c7501 2019-07-11 stsp
250 818c7501 2019-07-11 stsp /*
251 818c7501 2019-07-11 stsp * Continue an interrupted rebase operation.
252 818c7501 2019-07-11 stsp * This function returns existing references created when rebase was prepared,
253 818c7501 2019-07-11 stsp * and the ID of the commit currently being rebased. This should be called
254 818c7501 2019-07-11 stsp * before either resuming or aborting a rebase operation.
255 3e3a69f1 2019-07-25 stsp * The function also returns a pointer to a fileindex which must be
256 3e3a69f1 2019-07-25 stsp * passed back to other rebase-related functions.
257 818c7501 2019-07-11 stsp */
258 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_continue(struct got_object_id **,
259 818c7501 2019-07-11 stsp struct got_reference **, struct got_reference **, struct got_reference **,
260 3e3a69f1 2019-07-25 stsp struct got_fileindex **, struct got_worktree *, struct got_repository *);
261 818c7501 2019-07-11 stsp
262 818c7501 2019-07-11 stsp /* Check whether a, potentially interrupted, rebase operation is in progress. */
263 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_in_progress(int *,
264 818c7501 2019-07-11 stsp struct got_worktree *);
265 818c7501 2019-07-11 stsp
266 818c7501 2019-07-11 stsp /*
267 818c7501 2019-07-11 stsp * Merge changes from the commit currently being rebased into the work tree.
268 818c7501 2019-07-11 stsp * Report affected files, including merge conflicts, via the specified
269 01757395 2019-07-12 stsp * progress callback. Also populate a list of affected paths which should
270 01757395 2019-07-12 stsp * be passed to got_worktree_rebase_commit() after a conflict-free merge.
271 01757395 2019-07-12 stsp * This list must be initialized with TAILQ_INIT() and disposed of with
272 01757395 2019-07-12 stsp * got_worktree_rebase_pathlist_free().
273 818c7501 2019-07-11 stsp */
274 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_merge_files(
275 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
276 01757395 2019-07-12 stsp struct got_object_id *, struct got_object_id *, struct got_repository *,
277 e6209546 2019-08-22 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
278 818c7501 2019-07-11 stsp
279 818c7501 2019-07-11 stsp /*
280 01757395 2019-07-12 stsp * Commit changes merged by got_worktree_rebase_merge_files() to a temporary
281 01757395 2019-07-12 stsp * branch and return the ID of the newly created commit. An optional list of
282 01757395 2019-07-12 stsp * merged paths can be provided; otherwise this function will perform a status
283 01757395 2019-07-12 stsp * crawl across the entire work tree to find paths to commit.
284 818c7501 2019-07-11 stsp */
285 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_commit(struct got_object_id **,
286 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
287 01757395 2019-07-12 stsp struct got_reference *, struct got_commit_object *,
288 818c7501 2019-07-11 stsp struct got_object_id *, struct got_repository *);
289 818c7501 2019-07-11 stsp
290 01757395 2019-07-12 stsp /* Free a list of merged paths from got_worktree_merge_files. */
291 01757395 2019-07-12 stsp void got_worktree_rebase_pathlist_free(struct got_pathlist_head *);
292 01757395 2019-07-12 stsp
293 818c7501 2019-07-11 stsp /* Postpone the rebase operation. Should be called after a merge conflict. */
294 3e3a69f1 2019-07-25 stsp const struct got_error *got_worktree_rebase_postpone(struct got_worktree *,
295 3e3a69f1 2019-07-25 stsp struct got_fileindex *);
296 818c7501 2019-07-11 stsp
297 818c7501 2019-07-11 stsp /*
298 818c7501 2019-07-11 stsp * Complete the current rebase operation. This should be called once all
299 818c7501 2019-07-11 stsp * commits have been rebased successfully.
300 818c7501 2019-07-11 stsp */
301 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_complete(struct got_worktree *,
302 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_reference *, struct got_reference *,
303 3e3a69f1 2019-07-25 stsp struct got_reference *, struct got_repository *);
304 818c7501 2019-07-11 stsp
305 818c7501 2019-07-11 stsp /*
306 818c7501 2019-07-11 stsp * Abort the current rebase operation.
307 818c7501 2019-07-11 stsp * Report reverted files via the specified progress callback.
308 818c7501 2019-07-11 stsp */
309 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_abort(struct got_worktree *,
310 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_repository *, struct got_reference *,
311 0ebf8283 2019-07-24 stsp got_worktree_checkout_cb, void *);
312 0ebf8283 2019-07-24 stsp
313 0ebf8283 2019-07-24 stsp /*
314 0ebf8283 2019-07-24 stsp * Prepare for editing the history of the work tree's current branch.
315 0ebf8283 2019-07-24 stsp * This function creates references to a temporary branch, and the
316 0ebf8283 2019-07-24 stsp * work tree's current branch, under the "got/worktree/histedit/" namespace.
317 0ebf8283 2019-07-24 stsp * These references are used to keep track of histedit operation state and
318 0ebf8283 2019-07-24 stsp * are used as input and/or output arguments with other histedit-related
319 0ebf8283 2019-07-24 stsp * functions.
320 0ebf8283 2019-07-24 stsp */
321 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_prepare(struct got_reference **,
322 3e3a69f1 2019-07-25 stsp struct got_reference **, struct got_object_id **, struct got_fileindex **,
323 3e3a69f1 2019-07-25 stsp struct got_worktree *, struct got_repository *);
324 0ebf8283 2019-07-24 stsp
325 0ebf8283 2019-07-24 stsp /*
326 0ebf8283 2019-07-24 stsp * Continue an interrupted histedit operation.
327 0ebf8283 2019-07-24 stsp * This function returns existing references created when histedit was
328 0ebf8283 2019-07-24 stsp * prepared and the ID of the commit currently being edited.
329 0ebf8283 2019-07-24 stsp * It should be called before resuming or aborting a histedit operation.
330 0ebf8283 2019-07-24 stsp */
331 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_continue(struct got_object_id **,
332 0ebf8283 2019-07-24 stsp struct got_reference **, struct got_reference **, struct got_object_id **,
333 3e3a69f1 2019-07-25 stsp struct got_fileindex **, struct got_worktree *, struct got_repository *);
334 0ebf8283 2019-07-24 stsp
335 0ebf8283 2019-07-24 stsp /* Check whether a histedit operation is in progress. */
336 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_in_progress(int *,
337 0ebf8283 2019-07-24 stsp struct got_worktree *);
338 0ebf8283 2019-07-24 stsp
339 0ebf8283 2019-07-24 stsp /*
340 0ebf8283 2019-07-24 stsp * Merge changes from the commit currently being edited into the work tree.
341 0ebf8283 2019-07-24 stsp * Report affected files, including merge conflicts, via the specified
342 0ebf8283 2019-07-24 stsp * progress callback. Also populate a list of affected paths which should
343 0ebf8283 2019-07-24 stsp * be passed to got_worktree_histedit_commit() after a conflict-free merge.
344 0ebf8283 2019-07-24 stsp * This list must be initialized with TAILQ_INIT() and disposed of with
345 0ebf8283 2019-07-24 stsp * got_worktree_rebase_pathlist_free().
346 0ebf8283 2019-07-24 stsp */
347 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_merge_files(
348 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
349 0ebf8283 2019-07-24 stsp struct got_object_id *, struct got_object_id *, struct got_repository *,
350 e6209546 2019-08-22 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
351 0ebf8283 2019-07-24 stsp
352 0ebf8283 2019-07-24 stsp /*
353 0ebf8283 2019-07-24 stsp * Commit changes merged by got_worktree_histedit_merge_files() to a temporary
354 0ebf8283 2019-07-24 stsp * branch and return the ID of the newly created commit. An optional list of
355 0ebf8283 2019-07-24 stsp * merged paths can be provided; otherwise this function will perform a status
356 0ebf8283 2019-07-24 stsp * crawl across the entire work tree to find paths to commit.
357 0ebf8283 2019-07-24 stsp * An optional log message can be provided which will be used instead of the
358 0ebf8283 2019-07-24 stsp * commit's original message.
359 0ebf8283 2019-07-24 stsp */
360 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_commit(struct got_object_id **,
361 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
362 0ebf8283 2019-07-24 stsp struct got_reference *, struct got_commit_object *,
363 0ebf8283 2019-07-24 stsp struct got_object_id *, const char *, struct got_repository *);
364 0ebf8283 2019-07-24 stsp
365 0ebf8283 2019-07-24 stsp /*
366 0ebf8283 2019-07-24 stsp * Record the specified commit as skipped during histedit.
367 0ebf8283 2019-07-24 stsp * This should be called for commits which get dropped or get folded into
368 0ebf8283 2019-07-24 stsp * a subsequent commit.
369 0ebf8283 2019-07-24 stsp */
370 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_skip_commit(struct got_worktree *,
371 0ebf8283 2019-07-24 stsp struct got_object_id *, struct got_repository *);
372 0ebf8283 2019-07-24 stsp
373 0ebf8283 2019-07-24 stsp /* Postpone the histedit operation. */
374 3e3a69f1 2019-07-25 stsp const struct got_error *got_worktree_histedit_postpone(struct got_worktree *,
375 3e3a69f1 2019-07-25 stsp struct got_fileindex *);
376 0ebf8283 2019-07-24 stsp
377 0ebf8283 2019-07-24 stsp /*
378 0ebf8283 2019-07-24 stsp * Complete the current histedit operation. This should be called once all
379 0ebf8283 2019-07-24 stsp * commits have been edited successfully.
380 0ebf8283 2019-07-24 stsp */
381 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_complete(struct got_worktree *,
382 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_reference *, struct got_reference *,
383 3e3a69f1 2019-07-25 stsp struct got_repository *);
384 0ebf8283 2019-07-24 stsp
385 0ebf8283 2019-07-24 stsp /*
386 0ebf8283 2019-07-24 stsp * Abort the current histedit operation.
387 0ebf8283 2019-07-24 stsp * Report reverted files via the specified progress callback.
388 0ebf8283 2019-07-24 stsp */
389 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_abort(struct got_worktree *,
390 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_repository *, struct got_reference *,
391 3e3a69f1 2019-07-25 stsp struct got_object_id *, got_worktree_checkout_cb, void *);
392 0ebf8283 2019-07-24 stsp
393 c3022ba5 2019-07-27 stsp /* Get the path to this work tree's histedit script file. */
394 c3022ba5 2019-07-27 stsp const struct got_error *got_worktree_get_histedit_script_path(char **,
395 0ebf8283 2019-07-24 stsp struct got_worktree *);
396 dc424a06 2019-08-07 stsp
397 2822a352 2019-10-15 stsp /*
398 2822a352 2019-10-15 stsp * Prepare a work tree for integrating a branch.
399 2822a352 2019-10-15 stsp * Return pointers to a fileindex and locked references which must be
400 2822a352 2019-10-15 stsp * passed back to other integrate-related functions.
401 2822a352 2019-10-15 stsp */
402 2822a352 2019-10-15 stsp const struct got_error *
403 2822a352 2019-10-15 stsp got_worktree_integrate_prepare(struct got_fileindex **,
404 2822a352 2019-10-15 stsp struct got_reference **, struct got_reference **,
405 2822a352 2019-10-15 stsp struct got_worktree *, const char *, struct got_repository *);
406 dc424a06 2019-08-07 stsp
407 fdfa9bf2 2019-08-03 stsp /*
408 2822a352 2019-10-15 stsp * Carry out a prepared branch integration operation.
409 2822a352 2019-10-15 stsp * Report affected files via the specified progress callback.
410 2822a352 2019-10-15 stsp */
411 2822a352 2019-10-15 stsp const struct got_error *got_worktree_integrate_continue(
412 2822a352 2019-10-15 stsp struct got_worktree *, struct got_fileindex *, struct got_repository *,
413 2822a352 2019-10-15 stsp struct got_reference *, struct got_reference *,
414 2822a352 2019-10-15 stsp got_worktree_checkout_cb, void *, got_cancel_cb, void *);
415 2822a352 2019-10-15 stsp
416 2822a352 2019-10-15 stsp /* Abort a prepared branch integration operation. */
417 2822a352 2019-10-15 stsp const struct got_error *got_worktree_integrate_abort(struct got_worktree *,
418 2822a352 2019-10-15 stsp struct got_fileindex *, struct got_repository *,
419 2822a352 2019-10-15 stsp struct got_reference *, struct got_reference *);
420 2822a352 2019-10-15 stsp
421 2822a352 2019-10-15 stsp /*
422 fdfa9bf2 2019-08-03 stsp * Stage the specified paths for commit.
423 dc424a06 2019-08-07 stsp * If the patch callback is not NULL, call it to select patch hunks for
424 dc424a06 2019-08-07 stsp * staging. Otherwise, stage the full file content found at each path.
425 fdfa9bf2 2019-08-03 stsp */
426 1e71573e 2019-08-03 stsp const struct got_error *got_worktree_stage(struct got_worktree *,
427 1e71573e 2019-08-03 stsp struct got_pathlist_head *, got_worktree_status_cb, void *,
428 dc424a06 2019-08-07 stsp got_worktree_patch_cb, void *, struct got_repository *);
429 ad493afc 2019-08-03 stsp
430 ad493afc 2019-08-03 stsp /*
431 ad493afc 2019-08-03 stsp * Merge staged changes for the specified paths back into the work tree
432 ad493afc 2019-08-03 stsp * and mark the paths as non-staged again.
433 ad493afc 2019-08-03 stsp */
434 ad493afc 2019-08-03 stsp const struct got_error *got_worktree_unstage(struct got_worktree *,
435 ad493afc 2019-08-03 stsp struct got_pathlist_head *, got_worktree_checkout_cb, void *,
436 2e1f37b0 2019-08-08 stsp got_worktree_patch_cb, void *, struct got_repository *);