MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / reuse_prepared_capture

Function reuse_prepared_capture

atomic-repository/src/wip.rs:216–305  ·  view source on GitHub ↗
(
    root: &Path,
    ref_name: String,
    commit_oid: String,
    prepared: PreparedWip,
)

Source from the content-addressed store, hash-verified

214}
215
216fn reuse_prepared_capture(
217 root: &Path,
218 ref_name: String,
219 commit_oid: String,
220 prepared: PreparedWip,
221) -> Result<WipCapture, WipCaptureError> {
222 ensure_head_unchanged(root, &prepared.parent_oid)?;
223 let actual_tree = git_text(
224 root,
225 "read existing WIP tree",
226 &[
227 OsString::from("show"),
228 OsString::from("-s"),
229 OsString::from("--format=%T"),
230 OsString::from(&commit_oid),
231 ],
232 None,
233 None,
234 )?;
235 if actual_tree != prepared.tree_oid {
236 return Err(WipCaptureError::ExistingRefMismatch {
237 ref_name,
238 detail: format!(
239 "tree differs (existing {actual_tree}, current {})",
240 prepared.tree_oid
241 ),
242 });
243 }
244
245 let parents = git_text(
246 root,
247 "read existing WIP parents",
248 &[
249 OsString::from("show"),
250 OsString::from("-s"),
251 OsString::from("--format=%P"),
252 OsString::from(&commit_oid),
253 ],
254 None,
255 None,
256 )?;
257 let actual_parents: Vec<_> = parents.split_whitespace().collect();
258 let expected_parents: Vec<_> = prepared.parent_oid.iter().map(String::as_str).collect();
259 if actual_parents != expected_parents {
260 return Err(WipCaptureError::ExistingRefMismatch {
261 ref_name,
262 detail: format!(
263 "parent differs (existing {:?}, expected {:?})",
264 actual_parents, expected_parents
265 ),
266 });
267 }
268
269 let identity_and_message = git_text(
270 root,
271 "verify existing WIP identity",
272 &[
273 OsString::from("show"),

Callers 1

Calls 5

ensure_head_unchangedFunction · 0.85
git_textFunction · 0.70
collectMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected