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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use AtomicBool;
use ;
use crate::;
/// Caller-owned content merging selected by repository-relative byte path.
///
/// Implement this interface to compose attribute lookup with [`super::Driver`], or invoke a
/// custom implementation under caller-owned process and trust policy. The example preserves named
/// drivers as `CustomRequired`; callers matching Git's undefined-driver fallback should check
/// `merge.<name>.driver` in their configuration snapshot and select text when absent. Only paths
/// requiring three-way regular-file comparison invoke it; unchanged-side and structural resolutions
/// do not. Rename alignment supplies destination paths. Commit merging uses the same instance for
/// virtual bases and the final merge. Options remain plain data and hold no callback.
///
/// Library computation installs no objects. Callback side effects, cancellation of any custom
/// process and external state consistency belong to the caller. Returning resolved bytes is an
/// explicit resolution decision; return structured conflicts to preserve unresolved input.
///
/// ```
/// use std::sync::atomic::AtomicBool;
///
/// use girt::attributes::{Attributes, Case, Limits, Source};
/// use girt::merge::{ContentMerge, ContentOptions, Driver, TreeDriver};
///
/// struct AttributeDriver(Attributes);
/// impl TreeDriver for AttributeDriver {
/// fn merge(
/// &mut self,
/// path: &[u8],
/// base: &[u8],
/// ours: &[u8],
/// theirs: &[u8],
/// options: ContentOptions,
/// cancel: &AtomicBool,
/// ) -> Result<ContentMerge, Box<dyn std::error::Error + Send + Sync>> {
/// let selected = Driver::from_attribute(self.0.get(path, b"merge")?);
/// Ok(selected.merge(base, ours, theirs, options, cancel)?)
/// }
/// }
/// let mut attributes = Attributes::new(Case::Sensitive, Limits::default());
/// attributes.add(Source::Directory(b""), b"*.list merge=union\n")?;
/// let mut driver = AttributeDriver(attributes);
/// let result = driver.merge(
/// b"names.list",
/// b"old\n",
/// b"ours\n",
/// b"theirs\n",
/// ContentOptions::default(),
/// &AtomicBool::new(false),
/// )?;
/// assert!(result.is_clean());
/// # Ok::<(), Box<dyn std::error::Error + Send + Sync>>(())
/// ```