1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Git rebase operations using libgit2 with Git CLI fallback.
//!
//! This module provides functionality to:
//! - Perform rebase operations onto a specified upstream branch
//! - Detect and report conflicts during rebase
//! - Abort an in-progress rebase
//! - Continue a rebase after conflict resolution
//! - Get lists of conflicted files
//! - Handle all rebase failure modes with fault tolerance
//!
//! # Architecture
//!
//! This module uses a hybrid approach:
//! - **libgit2**: For repository state detection, validation, and queries
//! - **Git CLI**: For the actual rebase operation (more reliable)
//! - **Fallback patterns**: For operations that may fail with libgit2
//!
//! The Git CLI is used for rebase operations because:
//! 1. Better error messages for classification
//! 2. More robust edge case handling
//! 3. Better tested across Git versions
//! 4. Supports autostash and other features reliably
#![deny(unsafe_code)]
/// Git directory name for rebase-apply state (for `git am`-style rebases).
///
/// Used by `detect_concurrent_git_operations` and `cleanup_stale_rebase_state`
/// functions which are only available with the test-utils feature.
#[cfg(any(test, feature = "test-utils"))]
const REBASE_APPLY_DIR: &str = "rebase-apply";
/// Git directory name for rebase-merge state (for interactive rebases).
///
/// Used by `detect_concurrent_git_operations` and `cleanup_stale_rebase_state`
/// functions which are only available with the test-utils feature.
#[cfg(any(test, feature = "test-utils"))]
const REBASE_MERGE_DIR: &str = "rebase-merge";
use std::path::Path;
use crate::git_helpers::git2_to_io_error;
mod io {
pub type Result<T> = std::io::Result<T>;
pub type Error = std::io::Error;
pub type ErrorKind = std::io::ErrorKind;
}
include!("rebase_kinds.rs");
include!("rebase_classification.rs");
include!("conflict_detection.rs");
include!("rebase_preconditions.rs");
include!("rebase_run.rs");
include!("rebase_abort.rs");
include!("rebase_conflicts.rs");
include!("rebase_continuation.rs");
include!("rebase_tests.rs");