Skip to main content

mantle_git/
lib.rs

1#[cfg(feature = "uniffi")]
2uniffi::setup_scaffolding!();
3
4mod error;
5mod ops;
6mod repo;
7mod types;
8
9use std::collections::HashMap;
10
11pub use error::GitError;
12pub use types::MergeStateKind;
13pub use types::*;
14
15// MARK: - Artifact operations
16
17#[cfg_attr(feature = "uniffi", uniffi::export)]
18pub fn scan_clone_candidates(
19    repo_path: String,
20    worktree_path: String,
21) -> Result<Vec<CloneCandidate>, GitError> {
22    ops::artifacts::scan_clone_candidates(&repo_path, &worktree_path)
23}
24
25#[cfg_attr(feature = "uniffi", uniffi::export)]
26pub fn scan_worktreeinclude(
27    repo_path: String,
28    worktree_path: String,
29    gitignore_fallback: bool,
30) -> Result<WorktreeIncludeResult, GitError> {
31    ops::artifacts::scan_worktreeinclude(&repo_path, &worktree_path, gitignore_fallback)
32}
33
34#[cfg_attr(feature = "uniffi", uniffi::export)]
35pub fn compute_effective_worktreeinclude(
36    repo_path: String,
37    size_threshold_bytes: u64,
38) -> Result<EffectiveWorktreeinclude, GitError> {
39    ops::artifacts::compute_effective_worktreeinclude(&repo_path, size_threshold_bytes)
40}
41
42#[cfg_attr(feature = "uniffi", uniffi::export)]
43pub fn generate_default_worktreeinclude(
44    repo_path: String,
45) -> Result<GeneratedWorktreeinclude, GitError> {
46    ops::artifacts::generate_default_worktreeinclude(&repo_path)
47}
48
49#[cfg_attr(feature = "uniffi", uniffi::export)]
50pub fn bootstrap_worktreeinclude(repo_path: String) -> Result<GeneratedWorktreeinclude, GitError> {
51    ops::artifacts::bootstrap_worktreeinclude(&repo_path)
52}
53
54// MARK: - CoW operations
55
56#[cfg_attr(feature = "uniffi", uniffi::export)]
57pub fn cow_clone_directory(
58    source: String,
59    destination: String,
60) -> Result<CowCloneResult, GitError> {
61    ops::cow::cow_clone_directory(&source, &destination)
62}
63
64// MARK: - Worktree operations (direct)
65
66#[cfg_attr(feature = "uniffi", uniffi::export)]
67pub fn list_worktrees(repo_path: String) -> Result<Vec<WorktreeInfo>, GitError> {
68    ops::worktree::list_worktrees(&repo_path)
69}
70
71#[cfg_attr(feature = "uniffi", uniffi::export)]
72pub fn worktree_add_new_branch(
73    repo_path: String,
74    path: String,
75    branch: String,
76    start_point: String,
77) -> Result<(), GitError> {
78    ops::worktree::worktree_add_new_branch(&repo_path, &path, &branch, &start_point)
79}
80
81#[cfg_attr(feature = "uniffi", uniffi::export)]
82pub fn worktree_add_existing(
83    repo_path: String,
84    path: String,
85    branch: String,
86) -> Result<(), GitError> {
87    ops::worktree::worktree_add_existing(&repo_path, &path, &branch)
88}
89
90#[cfg_attr(feature = "uniffi", uniffi::export)]
91pub fn worktree_prune(repo_path: String) -> Result<(), GitError> {
92    ops::worktree::worktree_prune(&repo_path)
93}
94
95#[cfg_attr(feature = "uniffi", uniffi::export)]
96pub fn worktree_remove_clean(repo_path: String, path: String) -> Result<(), GitError> {
97    ops::worktree::worktree_remove_clean(&repo_path, &path)
98}
99
100#[cfg_attr(feature = "uniffi", uniffi::export)]
101pub fn worktree_remove_force(repo_path: String, path: String) -> Result<(), GitError> {
102    ops::worktree::worktree_remove_force(&repo_path, &path)
103}
104
105// MARK: - Blame operations
106
107#[cfg_attr(feature = "uniffi", uniffi::export)]
108pub fn git_blame_file(
109    repo_path: String,
110    file_path: String,
111) -> Result<Vec<BlameLineInfo>, GitError> {
112    ops::blame::blame_file(&repo_path, &file_path)
113}
114
115#[cfg_attr(feature = "uniffi", uniffi::export)]
116pub fn git_blame_file_at(
117    repo_path: String,
118    file_path: String,
119    commit_hash: String,
120) -> Result<Vec<BlameLineInfo>, GitError> {
121    ops::blame::blame_file_at(&repo_path, &file_path, &commit_hash)
122}
123
124// MARK: - Log operations
125
126#[cfg_attr(feature = "uniffi", uniffi::export)]
127pub fn git_log(repo_path: String, max_count: u32, skip: u32) -> Result<Vec<CommitInfo>, GitError> {
128    ops::log::log(&repo_path, max_count, skip)
129}
130
131#[cfg_attr(feature = "uniffi", uniffi::export)]
132pub fn git_log_for_ref(
133    repo_path: String,
134    git_ref: String,
135    max_count: u32,
136    skip: u32,
137) -> Result<Vec<CommitInfo>, GitError> {
138    ops::log::log_for_ref(&repo_path, &git_ref, max_count, skip)
139}
140
141#[cfg_attr(feature = "uniffi", uniffi::export)]
142pub fn git_log_for_path(
143    worktree_path: String,
144    max_count: u32,
145    skip: u32,
146) -> Result<Vec<CommitInfo>, GitError> {
147    ops::log::log_for_path(&worktree_path, max_count, skip)
148}
149
150#[cfg_attr(feature = "uniffi", uniffi::export)]
151pub fn git_log_by_file(
152    repo_path: String,
153    pattern: String,
154    max_count: u32,
155    skip: u32,
156) -> Result<Vec<CommitInfo>, GitError> {
157    ops::log::log_by_file(&repo_path, &pattern, max_count, skip)
158}
159
160#[cfg_attr(feature = "uniffi", uniffi::export)]
161pub fn git_log_for_paths(
162    repo_path: String,
163    paths: Vec<String>,
164    max_count: u32,
165    skip: u32,
166) -> Result<Vec<CommitInfo>, GitError> {
167    ops::log::log_for_paths(&repo_path, &paths, max_count, skip)
168}
169
170#[cfg_attr(feature = "uniffi", uniffi::export)]
171pub fn git_recent_commits_for_context(repo_path: String, count: u32) -> Result<String, GitError> {
172    ops::log::recent_commits_for_context(&repo_path, count)
173}
174
175#[cfg_attr(feature = "uniffi", uniffi::export)]
176pub fn git_full_message(repo_path: String, commit_hash: String) -> Result<String, GitError> {
177    ops::log::full_message(&repo_path, &commit_hash)
178}
179
180// MARK: - Branch operations
181
182#[cfg_attr(feature = "uniffi", uniffi::export)]
183pub fn git_current_branch(repo_path: String) -> Result<String, GitError> {
184    ops::branch::current_branch(&repo_path)
185}
186
187#[cfg_attr(feature = "uniffi", uniffi::export)]
188pub fn git_list_local_branches(repo_path: String) -> Result<Vec<BranchInfo>, GitError> {
189    ops::branch::list_local_branches(&repo_path)
190}
191
192#[cfg_attr(feature = "uniffi", uniffi::export)]
193pub fn git_list_remote_branches(repo_path: String) -> Result<Vec<BranchInfo>, GitError> {
194    ops::branch::list_remote_branches(&repo_path)
195}
196
197#[cfg_attr(feature = "uniffi", uniffi::export)]
198pub fn git_verify_branch_exists(repo_path: String, branch: String) -> Result<bool, GitError> {
199    ops::branch::verify_branch_exists(&repo_path, &branch)
200}
201
202#[cfg_attr(feature = "uniffi", uniffi::export)]
203pub fn git_branch_is_merged(
204    repo_path: String,
205    branch: String,
206    target_branch: String,
207) -> Result<bool, GitError> {
208    ops::branch::branch_is_merged(&repo_path, &branch, &target_branch)
209}
210
211#[cfg_attr(feature = "uniffi", uniffi::export)]
212pub fn git_latest_commit_date(
213    repo_path: String,
214    branch: String,
215) -> Result<Option<String>, GitError> {
216    ops::branch::latest_commit_date(&repo_path, &branch)
217}
218
219// MARK: - Config operations
220
221#[cfg_attr(feature = "uniffi", uniffi::export)]
222pub fn git_config_user_name(repo_path: String) -> Result<String, GitError> {
223    ops::config::config_user_name(&repo_path)
224}
225
226#[cfg_attr(feature = "uniffi", uniffi::export)]
227pub fn git_config_user_email(repo_path: String) -> Result<String, GitError> {
228    ops::config::config_user_email(&repo_path)
229}
230
231// MARK: - Ref operations
232
233#[cfg_attr(feature = "uniffi", uniffi::export)]
234pub fn git_rev_parse(repo_path: String, rev: String) -> Result<String, GitError> {
235    ops::refs::rev_parse(&repo_path, &rev)
236}
237
238#[cfg_attr(feature = "uniffi", uniffi::export)]
239pub fn git_is_valid_repo(path: String) -> bool {
240    ops::refs::is_valid_repo(&path)
241}
242
243#[cfg_attr(feature = "uniffi", uniffi::export)]
244pub fn git_rev_list_parents(
245    repo_path: String,
246    commit_hash: String,
247) -> Result<Vec<String>, GitError> {
248    ops::refs::rev_list_parents(&repo_path, &commit_hash)
249}
250
251#[cfg_attr(feature = "uniffi", uniffi::export)]
252pub fn git_commit_tree_and_refs(
253    repo_path: String,
254    commit_hash: String,
255) -> Result<CommitTreeRefsInfo, GitError> {
256    ops::refs::commit_tree_and_refs(&repo_path, &commit_hash)
257}
258
259#[cfg_attr(feature = "uniffi", uniffi::export)]
260pub fn git_ahead_behind(
261    repo_path: String,
262    ref1: String,
263    ref2: String,
264) -> Result<AheadBehindResult, GitError> {
265    ops::refs::ahead_behind(&repo_path, &ref1, &ref2)
266}
267
268// MARK: - Diff operations
269
270#[cfg_attr(feature = "uniffi", uniffi::export)]
271pub fn git_show_diff(repo_path: String, commit_hash: String) -> Result<String, GitError> {
272    ops::diff::show_diff(&repo_path, &commit_hash)
273}
274
275#[cfg_attr(feature = "uniffi", uniffi::export)]
276pub fn git_working_tree_diff(repo_path: String) -> Result<String, GitError> {
277    ops::diff::working_tree_diff(&repo_path)
278}
279
280#[cfg_attr(feature = "uniffi", uniffi::export)]
281pub fn git_working_tree_diff_for_context(repo_path: String) -> Result<String, GitError> {
282    ops::diff::working_tree_diff_for_context(&repo_path)
283}
284
285#[cfg_attr(feature = "uniffi", uniffi::export)]
286pub fn git_diff_between_refs(
287    repo_path: String,
288    base: String,
289    head: String,
290) -> Result<String, GitError> {
291    ops::diff::diff_between_refs(&repo_path, &base, &head)
292}
293
294// MARK: - Status operations
295
296#[cfg_attr(feature = "uniffi", uniffi::export)]
297pub fn git_is_clean(repo_path: String) -> Result<bool, GitError> {
298    ops::status::is_clean(&repo_path)
299}
300
301#[cfg_attr(feature = "uniffi", uniffi::export)]
302pub fn git_status_summary(repo_path: String) -> Result<StatusSummary, GitError> {
303    ops::status::status_summary(&repo_path)
304}
305
306#[cfg_attr(feature = "uniffi", uniffi::export)]
307pub fn git_list_tracked_files(repo_path: String) -> Result<Vec<String>, GitError> {
308    ops::status::list_tracked_files(&repo_path)
309}
310
311#[cfg_attr(feature = "uniffi", uniffi::export)]
312pub fn git_list_untracked_files(repo_path: String) -> Result<Vec<String>, GitError> {
313    ops::status::list_untracked_files(&repo_path)
314}
315
316#[cfg_attr(feature = "uniffi", uniffi::export)]
317pub fn git_changed_paths(repo_path: String) -> Result<Vec<String>, GitError> {
318    ops::status::changed_paths(&repo_path)
319}
320
321#[cfg_attr(feature = "uniffi", uniffi::export)]
322pub fn git_worktree_status(path: String) -> Result<WorktreeStatusInfo, GitError> {
323    ops::status::worktree_status(&path)
324}
325
326// MARK: - Repository operations (git2)
327
328#[cfg_attr(feature = "uniffi", uniffi::export)]
329pub fn git_init_repo(path: String) -> Result<(), GitError> {
330    ops::write::init_repo(&path)
331}
332
333#[cfg_attr(feature = "uniffi", uniffi::export)]
334pub fn git_repo_root(path: String) -> Result<String, GitError> {
335    ops::write::repo_root(&path)
336}
337
338// MARK: - Branch write operations (git2)
339
340#[cfg_attr(feature = "uniffi", uniffi::export)]
341pub fn git_checkout(repo_path: String, branch: String) -> Result<(), GitError> {
342    ops::write::checkout(&repo_path, &branch)
343}
344
345#[cfg_attr(feature = "uniffi", uniffi::export)]
346pub fn git_branch_delete(repo_path: String, name: String) -> Result<(), GitError> {
347    ops::write::branch_delete(&repo_path, &name)
348}
349
350#[cfg_attr(feature = "uniffi", uniffi::export)]
351pub fn git_create_branch_at(
352    repo_path: String,
353    branch: String,
354    start_point: String,
355) -> Result<(), GitError> {
356    ops::write::create_branch_at(&repo_path, &branch, &start_point)
357}
358
359// MARK: - Ref write operations (git2)
360
361#[cfg_attr(feature = "uniffi", uniffi::export)]
362pub fn git_update_ref(repo_path: String, ref_name: String, value: String) -> Result<(), GitError> {
363    ops::write::update_ref(&repo_path, &ref_name, &value)
364}
365
366#[cfg_attr(feature = "uniffi", uniffi::export)]
367pub fn git_delete_ref(repo_path: String, ref_name: String) -> Result<(), GitError> {
368    ops::write::delete_ref(&repo_path, &ref_name)
369}
370
371#[cfg_attr(feature = "uniffi", uniffi::export)]
372pub fn git_reset_hard(repo_path: String, rev: String) -> Result<(), GitError> {
373    ops::write::reset_hard(&repo_path, &rev)
374}
375
376#[cfg_attr(feature = "uniffi", uniffi::export)]
377pub fn git_reset_soft(repo_path: String, rev: String) -> Result<(), GitError> {
378    ops::write::reset_soft(&repo_path, &rev)
379}
380
381#[cfg_attr(feature = "uniffi", uniffi::export)]
382pub fn git_reset_mixed(repo_path: String, rev: String) -> Result<(), GitError> {
383    ops::write::reset_mixed(&repo_path, &rev)
384}
385
386// MARK: - Clean operations
387
388#[cfg_attr(feature = "uniffi", uniffi::export)]
389pub fn git_clean_untracked(repo_path: String) -> Result<(), GitError> {
390    ops::write::clean_untracked(&repo_path)
391}
392
393// MARK: - Stash operations (git2)
394
395#[cfg_attr(feature = "uniffi", uniffi::export)]
396pub fn git_stash_push(repo_path: String, message: String) -> Result<(), GitError> {
397    ops::write::stash_push(&repo_path, &message)
398}
399
400#[cfg_attr(feature = "uniffi", uniffi::export)]
401pub fn git_stash_pop(repo_path: String) -> Result<(), GitError> {
402    ops::write::stash_pop(&repo_path)
403}
404
405#[cfg_attr(feature = "uniffi", uniffi::export)]
406pub fn git_stash_list(repo_path: String) -> Result<Vec<StashEntry>, GitError> {
407    ops::write::stash_list(&repo_path)
408}
409
410#[cfg_attr(feature = "uniffi", uniffi::export)]
411pub fn git_stash_apply(repo_path: String, index: u32) -> Result<(), GitError> {
412    ops::write::stash_apply(&repo_path, index)
413}
414
415#[cfg_attr(feature = "uniffi", uniffi::export)]
416pub fn git_stash_drop(repo_path: String, index: u32) -> Result<(), GitError> {
417    ops::write::stash_drop(&repo_path, index)
418}
419
420#[cfg_attr(feature = "uniffi", uniffi::export)]
421pub fn git_stash_show(repo_path: String, index: u32) -> Result<String, GitError> {
422    ops::write::stash_show(&repo_path, index)
423}
424
425// MARK: - Tag operations (git2)
426
427#[cfg_attr(feature = "uniffi", uniffi::export)]
428pub fn git_list_tags(repo_path: String) -> Result<Vec<TagInfo>, GitError> {
429    ops::tag::list_tags(&repo_path)
430}
431
432#[cfg_attr(feature = "uniffi", uniffi::export)]
433pub fn git_create_tag(
434    repo_path: String,
435    name: String,
436    target_hash: String,
437    message: Option<String>,
438) -> Result<(), GitError> {
439    ops::tag::create_tag(&repo_path, &name, &target_hash, message)
440}
441
442#[cfg_attr(feature = "uniffi", uniffi::export)]
443pub fn git_delete_tag(repo_path: String, name: String) -> Result<(), GitError> {
444    ops::tag::delete_tag(&repo_path, &name)
445}
446
447// MARK: - Staging & commit operations (git2)
448
449#[cfg_attr(feature = "uniffi", uniffi::export)]
450pub fn git_add_all(repo_path: String) -> Result<(), GitError> {
451    ops::write::add_all(&repo_path)
452}
453
454#[cfg_attr(feature = "uniffi", uniffi::export)]
455pub fn git_add_files(repo_path: String, paths: Vec<String>) -> Result<(), GitError> {
456    ops::write::add_files(&repo_path, &paths)
457}
458
459#[cfg_attr(feature = "uniffi", uniffi::export)]
460pub fn git_reset_staging(repo_path: String) -> Result<(), GitError> {
461    ops::write::reset_staging(&repo_path)
462}
463
464#[cfg_attr(feature = "uniffi", uniffi::export)]
465pub fn git_commit(repo_path: String, message: String) -> Result<(), GitError> {
466    ops::write::commit(&repo_path, &message)
467}
468
469#[cfg_attr(feature = "uniffi", uniffi::export)]
470pub fn git_amend_commit(repo_path: String, message: String) -> Result<(), GitError> {
471    ops::write::amend_commit(&repo_path, &message)
472}
473
474#[cfg_attr(feature = "uniffi", uniffi::export)]
475pub fn git_restore_file(repo_path: String, file_path: String) -> Result<(), GitError> {
476    ops::write::restore_file(&repo_path, &file_path)
477}
478
479// MARK: - Remote operations (git2)
480
481#[cfg_attr(feature = "uniffi", uniffi::export)]
482pub fn git_list_remotes(repo_path: String) -> Result<Vec<RemoteInfo>, GitError> {
483    ops::remote::list_remotes(&repo_path)
484}
485
486#[cfg_attr(feature = "uniffi", uniffi::export)]
487pub fn git_fetch(repo_path: String, remote_name: String) -> Result<FetchResult, GitError> {
488    ops::remote::fetch(&repo_path, &remote_name)
489}
490
491#[cfg_attr(feature = "uniffi", uniffi::export)]
492pub fn git_push(
493    repo_path: String,
494    remote_name: String,
495    refspec: String,
496    force: bool,
497) -> Result<PushResult, GitError> {
498    ops::remote::push(&repo_path, &remote_name, &refspec, force)
499}
500
501#[cfg_attr(feature = "uniffi", uniffi::export)]
502pub fn git_push_branch(
503    repo_path: String,
504    branch: String,
505    set_upstream: bool,
506    force: bool,
507) -> Result<PushResult, GitError> {
508    ops::remote::push_branch(&repo_path, &branch, set_upstream, force)
509}
510
511#[cfg_attr(feature = "uniffi", uniffi::export)]
512pub fn git_pull(
513    repo_path: String,
514    remote_name: String,
515    branch: String,
516) -> Result<PullResult, GitError> {
517    ops::remote::pull(&repo_path, &remote_name, &branch)
518}
519
520#[cfg_attr(feature = "uniffi", uniffi::export)]
521pub fn git_remote_tracking_branch(
522    repo_path: String,
523    branch: String,
524) -> Result<Option<String>, GitError> {
525    ops::remote::remote_tracking_branch(&repo_path, &branch)
526}
527
528#[cfg_attr(feature = "uniffi", uniffi::export)]
529pub fn git_ahead_behind_remote(
530    repo_path: String,
531    branch: String,
532) -> Result<AheadBehindResult, GitError> {
533    ops::remote::ahead_behind_remote(&repo_path, &branch)
534}
535
536// MARK: - Blob operations
537
538#[cfg_attr(feature = "uniffi", uniffi::export)]
539pub fn git_blob_oids(repo_path: String) -> Result<HashMap<String, String>, GitError> {
540    ops::blob::blob_oids(&repo_path)
541}
542
543#[cfg_attr(feature = "uniffi", uniffi::export)]
544pub fn git_show_file(
545    repo_path: String,
546    commit_hash: String,
547    file_path: String,
548) -> Result<String, GitError> {
549    ops::blob::show_file(&repo_path, &commit_hash, &file_path)
550}
551
552// MARK: - Reflog operations (git2)
553
554#[cfg_attr(feature = "uniffi", uniffi::export)]
555pub fn git_reflog(
556    repo_path: String,
557    refname: String,
558    max_count: u32,
559) -> Result<Vec<ReflogEntry>, GitError> {
560    ops::reflog::reflog(&repo_path, &refname, max_count)
561}
562
563// MARK: - Cherry-pick operations (git2)
564
565#[cfg_attr(feature = "uniffi", uniffi::export)]
566pub fn git_cherry_pick(
567    repo_path: String,
568    commit_hash: String,
569    auto_stash: bool,
570) -> Result<String, GitError> {
571    ops::rewrite::cherry_pick(&repo_path, &commit_hash, auto_stash)
572}
573
574#[cfg_attr(feature = "uniffi", uniffi::export)]
575pub fn git_cherry_pick_to_branch(
576    repo_path: String,
577    commit_hash: String,
578    target_branch: String,
579    auto_stash: bool,
580) -> Result<String, GitError> {
581    ops::rewrite::cherry_pick_to_branch(&repo_path, &commit_hash, &target_branch, auto_stash)
582}
583
584// MARK: - Rewrite operations (git2 cherry-pick engine)
585
586#[cfg_attr(feature = "uniffi", uniffi::export)]
587pub fn git_rewrite_commit_author(
588    repo_path: String,
589    commit_hash: String,
590    new_name: String,
591    new_email: String,
592    auto_stash: bool,
593) -> Result<RewriteResult, GitError> {
594    ops::rewrite::rewrite_commit_author(&repo_path, &commit_hash, &new_name, &new_email, auto_stash)
595}
596
597#[cfg_attr(feature = "uniffi", uniffi::export)]
598pub fn git_rewrite_commit_date(
599    repo_path: String,
600    commit_hash: String,
601    new_date_iso: String,
602    auto_stash: bool,
603) -> Result<RewriteResult, GitError> {
604    ops::rewrite::rewrite_commit_date(&repo_path, &commit_hash, &new_date_iso, auto_stash)
605}
606
607#[cfg_attr(feature = "uniffi", uniffi::export)]
608pub fn git_rewrite_commit_message(
609    repo_path: String,
610    commit_hash: String,
611    new_message: String,
612    auto_stash: bool,
613) -> Result<RewriteResult, GitError> {
614    ops::rewrite::rewrite_commit_message(&repo_path, &commit_hash, &new_message, auto_stash)
615}
616
617#[cfg_attr(feature = "uniffi", uniffi::export)]
618pub fn git_fixup_commits(
619    repo_path: String,
620    commit_hashes: Vec<String>,
621    auto_stash: bool,
622) -> Result<RewriteResult, GitError> {
623    ops::rewrite::fixup_commits(&repo_path, &commit_hashes, auto_stash)
624}
625
626#[cfg_attr(feature = "uniffi", uniffi::export)]
627pub fn git_drop_commits(
628    repo_path: String,
629    commit_hashes: Vec<String>,
630    auto_stash: bool,
631) -> Result<RewriteResult, GitError> {
632    ops::rewrite::drop_commits(&repo_path, &commit_hashes, auto_stash)
633}
634
635#[cfg_attr(feature = "uniffi", uniffi::export)]
636pub fn git_commit_metadata(
637    repo_path: String,
638    commit_hash: String,
639) -> Result<CommitMetadataInfo, GitError> {
640    ops::rewrite::commit_metadata(&repo_path, &commit_hash)
641}
642
643#[cfg_attr(feature = "uniffi", uniffi::export)]
644pub fn git_prune_backup_refs(repo_path: String, retention_days: u32) -> Result<u32, GitError> {
645    ops::rewrite::prune_backup_refs(&repo_path, retention_days)
646}
647
648// MARK: - Worktree operations
649
650#[cfg_attr(feature = "uniffi", uniffi::export)]
651pub fn git_list_worktrees(repo_path: String) -> Result<Vec<WorktreeInfo>, GitError> {
652    ops::worktree::list_worktrees(&repo_path)
653}
654
655#[cfg_attr(feature = "uniffi", uniffi::export)]
656pub fn git_worktree_add_new_branch(
657    repo_path: String,
658    path: String,
659    branch: String,
660    start_point: String,
661) -> Result<(), GitError> {
662    ops::worktree::worktree_add_new_branch(&repo_path, &path, &branch, &start_point)
663}
664
665#[cfg_attr(feature = "uniffi", uniffi::export)]
666pub fn git_worktree_add_existing(
667    repo_path: String,
668    path: String,
669    branch: String,
670) -> Result<(), GitError> {
671    ops::worktree::worktree_add_existing(&repo_path, &path, &branch)
672}
673
674#[cfg_attr(feature = "uniffi", uniffi::export)]
675pub fn git_worktree_remove_clean(repo_path: String, path: String) -> Result<(), GitError> {
676    ops::worktree::worktree_remove_clean(&repo_path, &path)
677}
678
679#[cfg_attr(feature = "uniffi", uniffi::export)]
680pub fn git_worktree_remove_force(repo_path: String, path: String) -> Result<(), GitError> {
681    ops::worktree::worktree_remove_force(&repo_path, &path)
682}
683
684#[cfg_attr(feature = "uniffi", uniffi::export)]
685pub fn git_worktree_prune(repo_path: String) -> Result<(), GitError> {
686    ops::worktree::worktree_prune(&repo_path)
687}
688
689// MARK: - Merge state & conflict operations
690
691#[cfg_attr(feature = "uniffi", uniffi::export)]
692pub fn git_merge_state(repo_path: String) -> Result<MergeStateInfo, GitError> {
693    ops::merge::merge_state(&repo_path)
694}
695
696#[cfg_attr(feature = "uniffi", uniffi::export)]
697pub fn git_list_conflict_paths(repo_path: String) -> Result<Vec<String>, GitError> {
698    ops::merge::list_conflict_paths(&repo_path)
699}
700
701#[cfg_attr(feature = "uniffi", uniffi::export)]
702pub fn git_checkout_ours(repo_path: String, file_path: String) -> Result<(), GitError> {
703    ops::merge::checkout_ours(&repo_path, &file_path)
704}
705
706#[cfg_attr(feature = "uniffi", uniffi::export)]
707pub fn git_checkout_theirs(repo_path: String, file_path: String) -> Result<(), GitError> {
708    ops::merge::checkout_theirs(&repo_path, &file_path)
709}
710
711#[cfg_attr(feature = "uniffi", uniffi::export)]
712pub fn git_mark_resolved(repo_path: String, file_path: String) -> Result<(), GitError> {
713    ops::merge::mark_resolved(&repo_path, &file_path)
714}
715
716#[cfg_attr(feature = "uniffi", uniffi::export)]
717pub fn git_conflict_sides(repo_path: String, file_path: String) -> Result<ConflictSides, GitError> {
718    ops::merge::conflict_sides(&repo_path, &file_path)
719}