Skip to content

Commit b78e7dd

Browse files
committed
fix!: make clear what with_pruned() is doing by renaming it to with_boundary().
This is how it acts, and it's not at all the same as `hide()` in `git2`.
1 parent 14d6b8d commit b78e7dd

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

gix/src/revision/walk.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub struct Platform<'repo> {
155155
/// The owning repository.
156156
pub repo: &'repo Repository,
157157
pub(crate) tips: Vec<ObjectId>,
158-
pub(crate) prune: Vec<ObjectId>,
158+
pub(crate) boundary: Vec<ObjectId>,
159159
pub(crate) sorting: Sorting,
160160
pub(crate) parents: gix_traverse::commit::Parents,
161161
pub(crate) use_commit_graph: Option<bool>,
@@ -171,7 +171,7 @@ impl<'repo> Platform<'repo> {
171171
parents: Default::default(),
172172
use_commit_graph: None,
173173
commit_graph: None,
174-
prune: Vec::new(),
174+
boundary: Vec::new(),
175175
}
176176
}
177177
}
@@ -210,29 +210,30 @@ impl Platform<'_> {
210210
self
211211
}
212212

213-
/// Prune the commit with the given `ids` such that they won't be returned, and such that none of their ancestors is returned either.
214-
///
215-
/// Note that this forces the [sorting](Self::sorting) to
216-
/// [`ByCommitTimeCutoff`](Sorting::ByCommitTimeCutoff) configured with
217-
/// the oldest available commit time, ensuring that no commits older than the oldest of `ids` will be returned either.
213+
/// Don't cross the given `ids` during traversal.
218214
///
215+
/// Note that this forces the [sorting](Self::sorting()) to [`ByCommitTimeCutoff`](Sorting::ByCommitTimeCutoff)
216+
/// configured with the oldest available commit time, ensuring that no commits older than the oldest of `ids` will be returned either.
219217
/// Also note that commits that can't be accessed or are missing are simply ignored for the purpose of obtaining the cutoff date.
220-
#[doc(alias = "hide", alias = "git2")]
221-
pub fn with_pruned(mut self, ids: impl IntoIterator<Item = impl Into<ObjectId>>) -> Self {
218+
///
219+
/// A boundary is distinctly different from exclusive refsepcs `^branch-to-not-list` in Git log.
220+
///
221+
/// If this is not desired, [set the sorting](Self::sorting()) to something else right after this call.
222+
pub fn with_boundary(mut self, ids: impl IntoIterator<Item = impl Into<ObjectId>>) -> Self {
222223
let (mut cutoff, order) = match self.sorting {
223224
Sorting::ByCommitTimeCutoff { seconds, order } => (Some(seconds), order),
224225
Sorting::ByCommitTime(order) => (None, order),
225226
Sorting::BreadthFirst => (None, CommitTimeOrder::default()),
226227
};
227228
for id in ids.into_iter() {
228229
let id = id.into();
229-
if !self.prune.contains(&id) {
230+
if !self.boundary.contains(&id) {
230231
if let Some(time) = self.repo.find_commit(id).ok().and_then(|c| c.time().ok()) {
231232
if cutoff.is_none() || cutoff > Some(time.seconds) {
232233
cutoff = time.seconds.into();
233234
}
234235
}
235-
self.prune.push(id);
236+
self.boundary.push(id);
236237
}
237238
}
238239

@@ -260,9 +261,9 @@ impl<'repo> Platform<'repo> {
260261
parents,
261262
use_commit_graph,
262263
commit_graph,
263-
mut prune,
264+
mut boundary,
264265
} = self;
265-
prune.sort();
266+
boundary.sort();
266267
Ok(revision::Walk {
267268
repo,
268269
inner: Box::new(
@@ -277,7 +278,7 @@ impl<'repo> Platform<'repo> {
277278
return false;
278279
}
279280
let id = id.to_owned();
280-
if prune.binary_search(&id).is_ok() {
281+
if boundary.binary_search(&id).is_ok() {
281282
return false;
282283
}
283284
match shallow_commits.as_ref() {

gix/tests/gix/id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ mod ancestors {
140140
for use_commit_graph in [false, true] {
141141
let commits_graph_order = head
142142
.ancestors()
143-
.with_pruned(Some(hex_to_id("bcb05040a6925f2ff5e10d3ae1f9264f2e8c43ac")))
143+
.with_boundary(Some(hex_to_id("bcb05040a6925f2ff5e10d3ae1f9264f2e8c43ac")))
144144
.use_commit_graph(use_commit_graph)
145145
.all()?
146146
.map(|c| c.map(|c| c.id))

0 commit comments

Comments
 (0)