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 6353ad76 2019-02-08 stsp #define GOT_STATUS_CONFLICT 'C'
30 6353ad76 2019-02-08 stsp #define GOT_STATUS_MERGE 'G'
31 f8d1f275 2019-02-04 stsp #define GOT_STATUS_MISSING '!'
32 f8d1f275 2019-02-04 stsp #define GOT_STATUS_UNVERSIONED '?'
33 0dbc2271 2019-02-05 stsp #define GOT_STATUS_OBSTRUCTED '~'
34 a129376b 2019-03-28 stsp #define GOT_STATUS_REVERT 'R'
35 2b92fad7 2019-06-02 stsp #define GOT_STATUS_CANNOT_DELETE 'd'
36 a484d721 2019-06-10 stsp #define GOT_STATUS_BUMP_BASE 'b'
37 eecfbcd1 2018-12-29 stsp
38 0c60ce5a 2018-04-02 stsp /*
39 0c60ce5a 2018-04-02 stsp * Attempt to initialize a new work tree on disk.
40 0c60ce5a 2018-04-02 stsp * The first argument is the path to a directory where the work tree
41 0c60ce5a 2018-04-02 stsp * will be created. The path itself must not yet exist, but the dirname(3)
42 0c60ce5a 2018-04-02 stsp * of the path must already exist.
43 93a30277 2018-12-24 stsp * The reference provided will be used to determine the new worktree's
44 93a30277 2018-12-24 stsp * base commit. The third argument speficies the work tree's path prefix.
45 0c60ce5a 2018-04-02 stsp */
46 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_init(const char *, struct got_reference *,
47 577ec78f 2018-03-11 stsp const char *, struct got_repository *);
48 0c60ce5a 2018-04-02 stsp
49 0c60ce5a 2018-04-02 stsp /*
50 247140b2 2019-02-05 stsp * Attempt to open a worktree at or above the specified path.
51 0c60ce5a 2018-04-02 stsp * The caller must dispose of it with got_worktree_close().
52 0c60ce5a 2018-04-02 stsp */
53 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_open(struct got_worktree **, const char *);
54 0c60ce5a 2018-04-02 stsp
55 0c60ce5a 2018-04-02 stsp /* Dispose of an open work tree. */
56 3a6ce05a 2019-02-11 stsp const struct got_error *got_worktree_close(struct got_worktree *);
57 0c60ce5a 2018-04-02 stsp
58 0c60ce5a 2018-04-02 stsp /*
59 c7f4312f 2019-02-05 stsp * Get the path to the root directory of a worktree.
60 c7f4312f 2019-02-05 stsp */
61 c7f4312f 2019-02-05 stsp const char *got_worktree_get_root_path(struct got_worktree *);
62 c7f4312f 2019-02-05 stsp
63 c7f4312f 2019-02-05 stsp /*
64 0c60ce5a 2018-04-02 stsp * Get the path to the repository associated with a worktree.
65 0c60ce5a 2018-04-02 stsp */
66 2fbdb5ae 2018-12-29 stsp const char *got_worktree_get_repo_path(struct got_worktree *);
67 0c60ce5a 2018-04-02 stsp
68 0c60ce5a 2018-04-02 stsp /*
69 49520a32 2018-12-29 stsp * Get the path prefix associated with a worktree.
70 49520a32 2018-12-29 stsp */
71 49520a32 2018-12-29 stsp const char *got_worktree_get_path_prefix(struct got_worktree *);
72 49520a32 2018-12-29 stsp
73 49520a32 2018-12-29 stsp /*
74 e5dc7198 2018-12-29 stsp * Check if a user-provided path prefix matches that of the worktree.
75 e5dc7198 2018-12-29 stsp */
76 e5dc7198 2018-12-29 stsp const struct got_error *got_worktree_match_path_prefix(int *,
77 e5dc7198 2018-12-29 stsp struct got_worktree *, const char *);
78 e5dc7198 2018-12-29 stsp
79 e5dc7198 2018-12-29 stsp /*
80 0c60ce5a 2018-04-02 stsp * Get the name of a work tree's HEAD reference.
81 0c60ce5a 2018-04-02 stsp */
82 bc70eb79 2019-05-09 stsp const char *got_worktree_get_head_ref_name(struct got_worktree *);
83 0c60ce5a 2018-04-02 stsp
84 507dc3bb 2018-12-29 stsp /*
85 024e9686 2019-05-14 stsp * Set the branch head reference of the work tree.
86 024e9686 2019-05-14 stsp */
87 024e9686 2019-05-14 stsp const struct got_error *got_worktree_set_head_ref(struct got_worktree *,
88 024e9686 2019-05-14 stsp struct got_reference *);
89 024e9686 2019-05-14 stsp
90 024e9686 2019-05-14 stsp /*
91 507dc3bb 2018-12-29 stsp * Get the current base commit ID of a worktree.
92 507dc3bb 2018-12-29 stsp */
93 b72f483a 2019-02-05 stsp struct got_object_id *got_worktree_get_base_commit_id(struct got_worktree *);
94 507dc3bb 2018-12-29 stsp
95 507dc3bb 2018-12-29 stsp /*
96 507dc3bb 2018-12-29 stsp * Set the base commit Id of a worktree.
97 507dc3bb 2018-12-29 stsp */
98 507dc3bb 2018-12-29 stsp const struct got_error *got_worktree_set_base_commit_id(struct got_worktree *,
99 507dc3bb 2018-12-29 stsp struct got_repository *, struct got_object_id *);
100 507dc3bb 2018-12-29 stsp
101 0c60ce5a 2018-04-02 stsp /* A callback function which is invoked when a path is checked out. */
102 1ee397ad 2019-07-12 stsp typedef const struct got_error *(*got_worktree_checkout_cb)(void *,
103 1ee397ad 2019-07-12 stsp unsigned char, const char *);
104 0c60ce5a 2018-04-02 stsp
105 99437157 2018-11-11 stsp /* A callback function which is invoked at cancellation points.
106 99437157 2018-11-11 stsp * May return GOT_ERR_CANCELLED to abort the runing operation. */
107 99437157 2018-11-11 stsp typedef const struct got_error *(*got_worktree_cancel_cb)(void *);
108 99437157 2018-11-11 stsp
109 0c60ce5a 2018-04-02 stsp /*
110 0c60ce5a 2018-04-02 stsp * Attempt to check out files into a work tree from its associated repository
111 0c60ce5a 2018-04-02 stsp * and path prefix, and update the work tree's file index accordingly.
112 0c60ce5a 2018-04-02 stsp * File content is obtained from blobs within the work tree's path prefix
113 93a30277 2018-12-24 stsp * inside the tree corresponding to the work tree's base commit.
114 0c60ce5a 2018-04-02 stsp * The checkout progress callback will be invoked with the provided
115 0c60ce5a 2018-04-02 stsp * void * argument, and the path of each checked out file.
116 c4cdcb68 2019-04-03 stsp *
117 f2ea84fa 2019-07-27 stsp * It is possible to restrict the checkout operation to specific paths in
118 f2ea84fa 2019-07-27 stsp * the work tree, in which case all files outside those paths will remain at
119 c4cdcb68 2019-04-03 stsp * their currently recorded base commit. Inconsistent base commits can be
120 c4cdcb68 2019-04-03 stsp * repaired later by running another update operation across the entire work
121 c4cdcb68 2019-04-03 stsp * tree. Inconsistent base-commits may also occur if this function runs into
122 c4cdcb68 2019-04-03 stsp * an error or if the checkout operation is cancelled by the cancel callback.
123 f2ea84fa 2019-07-27 stsp * Allspecified paths are relative to the work tree's root. Pass a pathlist
124 f2ea84fa 2019-07-27 stsp * with a single empty path "" to check out files across the entire work tree.
125 c4cdcb68 2019-04-03 stsp *
126 c4cdcb68 2019-04-03 stsp * Some operations may refuse to run while the work tree contains files from
127 c4cdcb68 2019-04-03 stsp * multiple base commits.
128 0c60ce5a 2018-04-02 stsp */
129 86c3caaf 2018-03-09 stsp const struct got_error *got_worktree_checkout_files(struct got_worktree *,
130 f2ea84fa 2019-07-27 stsp struct got_pathlist_head *, struct got_repository *,
131 f2ea84fa 2019-07-27 stsp got_worktree_checkout_cb, void *, got_worktree_cancel_cb, void *);
132 507dc3bb 2018-12-29 stsp
133 234035bc 2019-06-01 stsp /* Merge the differences between two commits into a work tree. */
134 234035bc 2019-06-01 stsp const struct got_error *
135 234035bc 2019-06-01 stsp got_worktree_merge_files(struct got_worktree *,
136 234035bc 2019-06-01 stsp struct got_object_id *, struct got_object_id *,
137 234035bc 2019-06-01 stsp struct got_repository *, got_worktree_checkout_cb, void *,
138 234035bc 2019-06-01 stsp got_worktree_cancel_cb, void *);
139 234035bc 2019-06-01 stsp
140 f8d1f275 2019-02-04 stsp /* A callback function which is invoked to report a path's status. */
141 b72f483a 2019-02-05 stsp typedef const struct got_error *(*got_worktree_status_cb)(void *,
142 016a88dd 2019-05-13 stsp unsigned char, const char *, struct got_object_id *,
143 016a88dd 2019-05-13 stsp struct got_object_id *);
144 f8d1f275 2019-02-04 stsp
145 f8d1f275 2019-02-04 stsp /*
146 f8d1f275 2019-02-04 stsp * Report the status of paths in the work tree.
147 f8d1f275 2019-02-04 stsp * The status callback will be invoked with the provided void * argument,
148 f8d1f275 2019-02-04 stsp * a path, and a corresponding status code.
149 f8d1f275 2019-02-04 stsp */
150 6c34b1aa 2019-03-18 stsp const struct got_error *got_worktree_status(struct got_worktree *,
151 72ea6654 2019-07-27 stsp struct got_pathlist_head *, struct got_repository *,
152 72ea6654 2019-07-27 stsp got_worktree_status_cb, void *, got_worktree_cancel_cb cancel_cb, void *);
153 6c7ab921 2019-03-18 stsp
154 6c7ab921 2019-03-18 stsp /*
155 6c7ab921 2019-03-18 stsp * Try to resolve a user-provided path to an on-disk path in the work tree.
156 6c7ab921 2019-03-18 stsp * The caller must dispose of the resolved path with free(3).
157 6c7ab921 2019-03-18 stsp */
158 6c7ab921 2019-03-18 stsp const struct got_error *got_worktree_resolve_path(char **,
159 6c7ab921 2019-03-18 stsp struct got_worktree *, const char *);
160 d00136be 2019-03-26 stsp
161 1dd54920 2019-05-11 stsp /* Schedule files at on-disk paths for addition in the next commit. */
162 031a5338 2019-03-26 stsp const struct got_error *got_worktree_schedule_add(struct got_worktree *,
163 1dd54920 2019-05-11 stsp struct got_pathlist_head *, got_worktree_status_cb, void *,
164 1dd54920 2019-05-11 stsp struct got_repository *);
165 2ec1f75b 2019-03-26 stsp
166 2ec1f75b 2019-03-26 stsp /*
167 17ed4618 2019-06-02 stsp * Remove files from disk and schedule them to be deleted in the next commit.
168 2ec1f75b 2019-03-26 stsp * Don't allow deleting files with uncommitted modifications, unless the
169 2ec1f75b 2019-03-26 stsp * parameter 'delete_local_mods' is set.
170 2ec1f75b 2019-03-26 stsp */
171 2ec1f75b 2019-03-26 stsp const struct got_error *
172 17ed4618 2019-06-02 stsp got_worktree_schedule_delete(struct got_worktree *,
173 17ed4618 2019-06-02 stsp struct got_pathlist_head *, int, got_worktree_status_cb, void *,
174 17ed4618 2019-06-02 stsp struct got_repository *);
175 a129376b 2019-03-28 stsp
176 a129376b 2019-03-28 stsp /*
177 a129376b 2019-03-28 stsp * Revert a file at the specified path such that it matches its
178 a129376b 2019-03-28 stsp * original state in the worktree's base commit.
179 a129376b 2019-03-28 stsp */
180 a129376b 2019-03-28 stsp const struct got_error *got_worktree_revert(struct got_worktree *,
181 e20a8b6f 2019-06-04 stsp struct got_pathlist_head *, got_worktree_checkout_cb, void *,
182 e20a8b6f 2019-06-04 stsp struct got_repository *);
183 c4296144 2019-05-09 stsp
184 c4296144 2019-05-09 stsp /*
185 33ad4cbe 2019-05-12 jcs * A callback function which is invoked when a commit message is requested.
186 8656d6c4 2019-05-20 stsp * Passes a pathlist with a struct got_commitable * in the data pointer of
187 8656d6c4 2019-05-20 stsp * each element, a pointer to the log message that must be set by the
188 8656d6c4 2019-05-20 stsp * callback and will be freed after committing, and an argument passed
189 8656d6c4 2019-05-20 stsp * through to the callback.
190 33ad4cbe 2019-05-12 jcs */
191 33ad4cbe 2019-05-12 jcs typedef const struct got_error *(*got_worktree_commit_msg_cb)(
192 33ad4cbe 2019-05-12 jcs struct got_pathlist_head *, char **, void *);
193 33ad4cbe 2019-05-12 jcs
194 33ad4cbe 2019-05-12 jcs /*
195 c4296144 2019-05-09 stsp * Create a new commit from changes in the work tree.
196 c4296144 2019-05-09 stsp * Return the ID of the newly created commit.
197 c4296144 2019-05-09 stsp * The worktree's base commit will be set to this new commit.
198 c4296144 2019-05-09 stsp * Files unaffected by this commit operation will retain their
199 c4296144 2019-05-09 stsp * current base commit.
200 de18fc63 2019-05-09 stsp * An author and a non-empty log message must be specified.
201 de18fc63 2019-05-09 stsp * The name of the committer is optional (may be NULL).
202 c4296144 2019-05-09 stsp */
203 de18fc63 2019-05-09 stsp const struct got_error *got_worktree_commit(struct got_object_id **,
204 5c1e53bc 2019-07-28 stsp struct got_worktree *, struct got_pathlist_head *, const char *,
205 5c1e53bc 2019-07-28 stsp const char *, got_worktree_commit_msg_cb, void *,
206 33ad4cbe 2019-05-12 jcs got_worktree_status_cb, void *, struct got_repository *);
207 8656d6c4 2019-05-20 stsp
208 8656d6c4 2019-05-20 stsp /* Get the path of a commitable worktree item. */
209 8656d6c4 2019-05-20 stsp const char *got_commitable_get_path(struct got_commitable *);
210 8656d6c4 2019-05-20 stsp
211 8656d6c4 2019-05-20 stsp /* Get the status of a commitable worktree item. */
212 8656d6c4 2019-05-20 stsp unsigned int got_commitable_get_status(struct got_commitable *);
213 818c7501 2019-07-11 stsp
214 818c7501 2019-07-11 stsp /*
215 818c7501 2019-07-11 stsp * Prepare for rebasing a branch onto the work tree's current branch.
216 818c7501 2019-07-11 stsp * This function creates references to a temporary branch, the branch
217 818c7501 2019-07-11 stsp * being rebased, and the work tree's current branch, under the
218 818c7501 2019-07-11 stsp * "got/worktree/rebase/" namespace. These references are used to
219 818c7501 2019-07-11 stsp * keep track of rebase operation state and are used as input and/or
220 818c7501 2019-07-11 stsp * output arguments with other rebase-related functions.
221 3e3a69f1 2019-07-25 stsp * The function also returns a pointer to a fileindex which must be
222 3e3a69f1 2019-07-25 stsp * passed back to other rebase-related functions.
223 818c7501 2019-07-11 stsp */
224 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_prepare(struct got_reference **,
225 3e3a69f1 2019-07-25 stsp struct got_reference **, struct got_fileindex **, struct got_worktree *,
226 3e3a69f1 2019-07-25 stsp struct got_reference *, struct got_repository *);
227 818c7501 2019-07-11 stsp
228 818c7501 2019-07-11 stsp /*
229 818c7501 2019-07-11 stsp * Continue an interrupted rebase operation.
230 818c7501 2019-07-11 stsp * This function returns existing references created when rebase was prepared,
231 818c7501 2019-07-11 stsp * and the ID of the commit currently being rebased. This should be called
232 818c7501 2019-07-11 stsp * before either resuming or aborting a rebase operation.
233 3e3a69f1 2019-07-25 stsp * The function also returns a pointer to a fileindex which must be
234 3e3a69f1 2019-07-25 stsp * passed back to other rebase-related functions.
235 818c7501 2019-07-11 stsp */
236 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_continue(struct got_object_id **,
237 818c7501 2019-07-11 stsp struct got_reference **, struct got_reference **, struct got_reference **,
238 3e3a69f1 2019-07-25 stsp struct got_fileindex **, struct got_worktree *, struct got_repository *);
239 818c7501 2019-07-11 stsp
240 818c7501 2019-07-11 stsp /* Check whether a, potentially interrupted, rebase operation is in progress. */
241 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_in_progress(int *,
242 818c7501 2019-07-11 stsp struct got_worktree *);
243 818c7501 2019-07-11 stsp
244 818c7501 2019-07-11 stsp /*
245 818c7501 2019-07-11 stsp * Merge changes from the commit currently being rebased into the work tree.
246 818c7501 2019-07-11 stsp * Report affected files, including merge conflicts, via the specified
247 01757395 2019-07-12 stsp * progress callback. Also populate a list of affected paths which should
248 01757395 2019-07-12 stsp * be passed to got_worktree_rebase_commit() after a conflict-free merge.
249 01757395 2019-07-12 stsp * This list must be initialized with TAILQ_INIT() and disposed of with
250 01757395 2019-07-12 stsp * got_worktree_rebase_pathlist_free().
251 818c7501 2019-07-11 stsp */
252 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_merge_files(
253 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
254 01757395 2019-07-12 stsp struct got_object_id *, struct got_object_id *, struct got_repository *,
255 01757395 2019-07-12 stsp got_worktree_checkout_cb, void *, got_worktree_cancel_cb, void *);
256 818c7501 2019-07-11 stsp
257 818c7501 2019-07-11 stsp /*
258 01757395 2019-07-12 stsp * Commit changes merged by got_worktree_rebase_merge_files() to a temporary
259 01757395 2019-07-12 stsp * branch and return the ID of the newly created commit. An optional list of
260 01757395 2019-07-12 stsp * merged paths can be provided; otherwise this function will perform a status
261 01757395 2019-07-12 stsp * crawl across the entire work tree to find paths to commit.
262 818c7501 2019-07-11 stsp */
263 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_commit(struct got_object_id **,
264 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
265 01757395 2019-07-12 stsp struct got_reference *, struct got_commit_object *,
266 818c7501 2019-07-11 stsp struct got_object_id *, struct got_repository *);
267 818c7501 2019-07-11 stsp
268 01757395 2019-07-12 stsp /* Free a list of merged paths from got_worktree_merge_files. */
269 01757395 2019-07-12 stsp void got_worktree_rebase_pathlist_free(struct got_pathlist_head *);
270 01757395 2019-07-12 stsp
271 818c7501 2019-07-11 stsp /* Postpone the rebase operation. Should be called after a merge conflict. */
272 3e3a69f1 2019-07-25 stsp const struct got_error *got_worktree_rebase_postpone(struct got_worktree *,
273 3e3a69f1 2019-07-25 stsp struct got_fileindex *);
274 818c7501 2019-07-11 stsp
275 818c7501 2019-07-11 stsp /*
276 818c7501 2019-07-11 stsp * Complete the current rebase operation. This should be called once all
277 818c7501 2019-07-11 stsp * commits have been rebased successfully.
278 818c7501 2019-07-11 stsp */
279 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_complete(struct got_worktree *,
280 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_reference *, struct got_reference *,
281 3e3a69f1 2019-07-25 stsp struct got_reference *, struct got_repository *);
282 818c7501 2019-07-11 stsp
283 818c7501 2019-07-11 stsp /*
284 818c7501 2019-07-11 stsp * Abort the current rebase operation.
285 818c7501 2019-07-11 stsp * Report reverted files via the specified progress callback.
286 818c7501 2019-07-11 stsp */
287 818c7501 2019-07-11 stsp const struct got_error *got_worktree_rebase_abort(struct got_worktree *,
288 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_repository *, struct got_reference *,
289 0ebf8283 2019-07-24 stsp got_worktree_checkout_cb, void *);
290 0ebf8283 2019-07-24 stsp
291 0ebf8283 2019-07-24 stsp /*
292 0ebf8283 2019-07-24 stsp * Prepare for editing the history of the work tree's current branch.
293 0ebf8283 2019-07-24 stsp * This function creates references to a temporary branch, and the
294 0ebf8283 2019-07-24 stsp * work tree's current branch, under the "got/worktree/histedit/" namespace.
295 0ebf8283 2019-07-24 stsp * These references are used to keep track of histedit operation state and
296 0ebf8283 2019-07-24 stsp * are used as input and/or output arguments with other histedit-related
297 0ebf8283 2019-07-24 stsp * functions.
298 0ebf8283 2019-07-24 stsp */
299 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_prepare(struct got_reference **,
300 3e3a69f1 2019-07-25 stsp struct got_reference **, struct got_object_id **, struct got_fileindex **,
301 3e3a69f1 2019-07-25 stsp struct got_worktree *, struct got_repository *);
302 0ebf8283 2019-07-24 stsp
303 0ebf8283 2019-07-24 stsp /*
304 0ebf8283 2019-07-24 stsp * Continue an interrupted histedit operation.
305 0ebf8283 2019-07-24 stsp * This function returns existing references created when histedit was
306 0ebf8283 2019-07-24 stsp * prepared and the ID of the commit currently being edited.
307 0ebf8283 2019-07-24 stsp * It should be called before resuming or aborting a histedit operation.
308 0ebf8283 2019-07-24 stsp */
309 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_continue(struct got_object_id **,
310 0ebf8283 2019-07-24 stsp struct got_reference **, struct got_reference **, struct got_object_id **,
311 3e3a69f1 2019-07-25 stsp struct got_fileindex **, struct got_worktree *, struct got_repository *);
312 0ebf8283 2019-07-24 stsp
313 0ebf8283 2019-07-24 stsp /* Check whether a histedit operation is in progress. */
314 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_in_progress(int *,
315 0ebf8283 2019-07-24 stsp struct got_worktree *);
316 0ebf8283 2019-07-24 stsp
317 0ebf8283 2019-07-24 stsp /*
318 0ebf8283 2019-07-24 stsp * Merge changes from the commit currently being edited into the work tree.
319 0ebf8283 2019-07-24 stsp * Report affected files, including merge conflicts, via the specified
320 0ebf8283 2019-07-24 stsp * progress callback. Also populate a list of affected paths which should
321 0ebf8283 2019-07-24 stsp * be passed to got_worktree_histedit_commit() after a conflict-free merge.
322 0ebf8283 2019-07-24 stsp * This list must be initialized with TAILQ_INIT() and disposed of with
323 0ebf8283 2019-07-24 stsp * got_worktree_rebase_pathlist_free().
324 0ebf8283 2019-07-24 stsp */
325 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_merge_files(
326 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
327 0ebf8283 2019-07-24 stsp struct got_object_id *, struct got_object_id *, struct got_repository *,
328 0ebf8283 2019-07-24 stsp got_worktree_checkout_cb, void *, got_worktree_cancel_cb, void *);
329 0ebf8283 2019-07-24 stsp
330 0ebf8283 2019-07-24 stsp /*
331 0ebf8283 2019-07-24 stsp * Commit changes merged by got_worktree_histedit_merge_files() to a temporary
332 0ebf8283 2019-07-24 stsp * branch and return the ID of the newly created commit. An optional list of
333 0ebf8283 2019-07-24 stsp * merged paths can be provided; otherwise this function will perform a status
334 0ebf8283 2019-07-24 stsp * crawl across the entire work tree to find paths to commit.
335 0ebf8283 2019-07-24 stsp * An optional log message can be provided which will be used instead of the
336 0ebf8283 2019-07-24 stsp * commit's original message.
337 0ebf8283 2019-07-24 stsp */
338 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_commit(struct got_object_id **,
339 3e3a69f1 2019-07-25 stsp struct got_pathlist_head *, struct got_worktree *, struct got_fileindex *,
340 0ebf8283 2019-07-24 stsp struct got_reference *, struct got_commit_object *,
341 0ebf8283 2019-07-24 stsp struct got_object_id *, const char *, struct got_repository *);
342 0ebf8283 2019-07-24 stsp
343 0ebf8283 2019-07-24 stsp /*
344 0ebf8283 2019-07-24 stsp * Record the specified commit as skipped during histedit.
345 0ebf8283 2019-07-24 stsp * This should be called for commits which get dropped or get folded into
346 0ebf8283 2019-07-24 stsp * a subsequent commit.
347 0ebf8283 2019-07-24 stsp */
348 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_skip_commit(struct got_worktree *,
349 0ebf8283 2019-07-24 stsp struct got_object_id *, struct got_repository *);
350 0ebf8283 2019-07-24 stsp
351 0ebf8283 2019-07-24 stsp /* Postpone the histedit operation. */
352 3e3a69f1 2019-07-25 stsp const struct got_error *got_worktree_histedit_postpone(struct got_worktree *,
353 3e3a69f1 2019-07-25 stsp struct got_fileindex *);
354 0ebf8283 2019-07-24 stsp
355 0ebf8283 2019-07-24 stsp /*
356 0ebf8283 2019-07-24 stsp * Complete the current histedit operation. This should be called once all
357 0ebf8283 2019-07-24 stsp * commits have been edited successfully.
358 0ebf8283 2019-07-24 stsp */
359 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_complete(struct got_worktree *,
360 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_reference *, struct got_reference *,
361 3e3a69f1 2019-07-25 stsp struct got_repository *);
362 0ebf8283 2019-07-24 stsp
363 0ebf8283 2019-07-24 stsp /*
364 0ebf8283 2019-07-24 stsp * Abort the current histedit operation.
365 0ebf8283 2019-07-24 stsp * Report reverted files via the specified progress callback.
366 0ebf8283 2019-07-24 stsp */
367 0ebf8283 2019-07-24 stsp const struct got_error *got_worktree_histedit_abort(struct got_worktree *,
368 3e3a69f1 2019-07-25 stsp struct got_fileindex *, struct got_repository *, struct got_reference *,
369 3e3a69f1 2019-07-25 stsp struct got_object_id *, got_worktree_checkout_cb, void *);
370 0ebf8283 2019-07-24 stsp
371 c3022ba5 2019-07-27 stsp /* Get the path to this work tree's histedit script file. */
372 c3022ba5 2019-07-27 stsp const struct got_error *got_worktree_get_histedit_script_path(char **,
373 0ebf8283 2019-07-24 stsp struct got_worktree *);
374 0cb83759 2019-08-03 stsp
375 0cb83759 2019-08-03 stsp /* Stage the specified paths for commit. */
376 0cb83759 2019-08-03 stsp const struct got_error *got_worktree_stage_paths(struct got_worktree *,
377 0cb83759 2019-08-03 stsp struct got_pathlist_head *, struct got_repository *,
378 0cb83759 2019-08-03 stsp got_worktree_status_cb, void *,
379 0cb83759 2019-08-03 stsp got_worktree_cancel_cb , void *);