@@ -53,9 +53,11 @@ pub struct Outcome {
53
53
pub entries_skipped_by_entry_flags : usize ,
54
54
/// The amount of times we queried symlink-metadata for a file on disk.
55
55
pub symlink_metadata_calls : usize ,
56
- /// The amount of entries whose stats have been updated as its modification couldn't be determined without an expensive calculation.
56
+ /// The amount of entries whose stats would need to be updated as its modification couldn't be determined without
57
+ /// an expensive calculation.
57
58
///
58
59
/// With these updates, this calculation will be avoided next time the status runs.
60
+ /// Note that the stat updates are delegated to the caller.
59
61
pub entries_updated : usize ,
60
62
/// The amount of entries that were considered racy-clean - they will need thorough checking to see if they are truly clean,
61
63
/// i.e. didn't change.
@@ -79,7 +81,7 @@ impl Outcome {
79
81
}
80
82
81
83
/// How an index entry needs to be changed to obtain the destination worktree state, i.e. `entry.apply(this_change) == worktree-entry`.
82
- #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
84
+ #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
83
85
pub enum Change < T = ( ) , U = ( ) > {
84
86
/// This corresponding file does not exist in the worktree anymore.
85
87
Removed ,
@@ -95,6 +97,11 @@ pub enum Change<T = (), U = ()> {
95
97
/// If there is no content change and only the executable bit
96
98
/// changed then this is `None`.
97
99
content_change : Option < T > ,
100
+ /// If true, the caller is expected to set [entry.stat.size = 0](gix_index::entry::Stat::size) to assure this
101
+ /// otherwise racily clean entry can still be detected as dirty next time this is called, but this time without
102
+ /// reading it from disk to hash it. It's a performance optimization and not doing so won't change the correctness
103
+ /// of the operation.
104
+ set_entry_stat_size_zero : bool ,
98
105
} ,
99
106
/// A submodule is initialized and checked out, and there was modification to either:
100
107
///
@@ -105,28 +112,73 @@ pub enum Change<T = (), U = ()> {
105
112
/// The exact nature of the modification is handled by the caller which may retain information per submodule or
106
113
/// re-compute details as needed when seeing this variant.
107
114
SubmoduleModification ( U ) ,
108
- /// An index entry that correspond to an untracked worktree file marked with `git add --intent-to-add`.
115
+ }
116
+
117
+ /// Information about an entry.
118
+ #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
119
+ pub enum EntryStatus < T = ( ) , U = ( ) > {
120
+ /// The entry is in a conflicting state, and we didn't collect any more information about it.
121
+ Conflict ( Conflict ) ,
122
+ /// There is no conflict and a change was discovered.
123
+ Change ( Change < T , U > ) ,
124
+ /// The entry didn't change, but its state caused extra work that can be avoided next time if its stats would be updated to the
125
+ /// given stat.
126
+ NeedsUpdate (
127
+ /// The new stats which represent what's currently in the working tree. If these replace the current stats in the entry,
128
+ /// next time this operation runs we can determine the actual state much faster.
129
+ gix_index:: entry:: Stat ,
130
+ ) ,
131
+ /// An index entry that corresponds to an untracked worktree file marked with `git add --intent-to-add`.
109
132
///
110
- /// This means it's not available in the object database yet
111
- /// even though now an entry exists that represents the worktree file.
133
+ /// This means it's not available in the object database yet even though now an entry exists that represents the worktree file.
134
+ /// The entry represents the promise of adding a new file, no matter the actual stat or content.
135
+ /// Effectively this means nothing changed.
136
+ /// This also means the file is still present, and that no detailed change checks were performed.
112
137
IntentToAdd ,
113
138
}
114
139
115
- /// Observe changes by comparing an index entry to the worktree or another index.
140
+ impl < T , U > From < Change < T , U > > for EntryStatus < T , U > {
141
+ fn from ( value : Change < T , U > ) -> Self {
142
+ EntryStatus :: Change ( value)
143
+ }
144
+ }
145
+
146
+ /// Describes a conflicting entry as comparison between 'our' version and 'their' version of it.
147
+ ///
148
+ /// If one side isn't specified, it is assumed to have modified the entry. In general, there would be no conflict
149
+ /// if both parties ended up in the same state.
150
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
151
+ pub enum Conflict {
152
+ /// Both deleted a different version of the entry.
153
+ BothDeleted ,
154
+ /// We added, they modified, ending up in different states.
155
+ AddedByUs ,
156
+ /// They deleted the entry, we modified it.
157
+ DeletedByThem ,
158
+ /// They added the entry, we modified it, ending up in different states.
159
+ AddedByThem ,
160
+ /// We deleted the entry, they modified it, ending up in different states.
161
+ DeletedByUs ,
162
+ /// Both added the entry in different states.
163
+ BothAdded ,
164
+ /// Both modified the entry, ending up in different states.
165
+ BothModified ,
166
+ }
167
+
168
+ /// Observe the status of an entry by comparing an index entry to the worktree.
116
169
pub trait VisitEntry < ' index > {
117
170
/// Data generated by comparing an entry with a file.
118
171
type ContentChange ;
119
172
/// Data obtained when checking the submodule status.
120
173
type SubmoduleStatus ;
121
- /// Observe the `change` of `entry` at the repository-relative `rela_path` at `entry_index`
122
- /// (relative to the complete list of all index entries), indicating whether or not it has a `conflict`.
123
- /// If `change` is `None`, there is no change.
174
+ /// Observe the `status` of `entry` at the repository-relative `rela_path` at `entry_index`
175
+ /// (for accessing `entry` and surrounding in the complete list of `entries`).
124
176
fn visit_entry (
125
177
& mut self ,
178
+ entries : & ' index [ gix_index:: Entry ] ,
126
179
entry : & ' index gix_index:: Entry ,
127
180
entry_index : usize ,
128
181
rela_path : & ' index BStr ,
129
- change : Option < Change < Self :: ContentChange , Self :: SubmoduleStatus > > ,
130
- conflict : bool ,
182
+ status : EntryStatus < Self :: ContentChange , Self :: SubmoduleStatus > ,
131
183
) ;
132
184
}
0 commit comments