Skip to content

Commit 5bfbb9a

Browse files
committed
feat: Repository::shallow_commits() returns an uptodate list of shallow boundary commits.
1 parent 3e69535 commit 5bfbb9a

File tree

19 files changed

+180
-114
lines changed

19 files changed

+180
-114
lines changed

gix/src/diff.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub use gix_diff::*;
2+
3+
///
4+
pub mod rename {
5+
/// Determine how to do rename tracking.
6+
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
7+
pub enum Tracking {
8+
/// Do not track renames at all, the fastest option.
9+
Disabled,
10+
/// Track renames.
11+
Renames,
12+
/// Track renames and copies.
13+
///
14+
/// This is the most expensive option.
15+
RenamesAndCopies,
16+
}
17+
}

gix/src/lib.rs

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ pub mod interrupt;
9898

9999
mod ext;
100100
///
101-
pub mod prelude {
102-
pub use gix_features::parallel::reduce::Finalize;
103-
pub use gix_odb::{Find, FindExt, Header, HeaderExt, Write};
104-
105-
pub use crate::ext::*;
106-
}
101+
pub mod prelude;
107102

108103
///
109104
pub mod path;
@@ -133,31 +128,10 @@ mod repository;
133128
pub mod tag;
134129

135130
///
136-
pub mod progress {
137-
#[cfg(feature = "progress-tree")]
138-
pub use gix_features::progress::prodash::tree;
139-
pub use gix_features::progress::*;
140-
}
131+
pub mod progress;
141132

142133
///
143-
pub mod diff {
144-
pub use gix_diff::*;
145-
///
146-
pub mod rename {
147-
/// Determine how to do rename tracking.
148-
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
149-
pub enum Tracking {
150-
/// Do not track renames at all, the fastest option.
151-
Disabled,
152-
/// Track renames.
153-
Renames,
154-
/// Track renames and copies.
155-
///
156-
/// This is the most expensive option.
157-
RenamesAndCopies,
158-
}
159-
}
160-
}
134+
pub mod diff;
161135

162136
/// See [ThreadSafeRepository::discover()], but returns a [`Repository`] instead.
163137
#[allow(clippy::result_large_err)]
@@ -238,20 +212,10 @@ pub fn open_opts(directory: impl Into<std::path::PathBuf>, options: open::Option
238212
}
239213

240214
///
241-
pub mod permission {
242-
///
243-
pub mod env_var {
244-
///
245-
pub mod resource {
246-
///
247-
pub type Error = gix_sec::permission::Error<std::path::PathBuf>;
248-
}
249-
}
250-
}
215+
pub mod permission;
216+
251217
///
252-
pub mod permissions {
253-
pub use crate::repository::permissions::{Config, Environment};
254-
}
218+
pub mod permissions;
255219
pub use repository::permissions::Permissions;
256220

257221
///
@@ -278,33 +242,10 @@ pub mod remote;
278242
pub mod init;
279243

280244
/// Not to be confused with 'status'.
281-
pub mod state {
282-
/// Tell what operation is currently in progress.
283-
#[derive(Debug, PartialEq, Eq)]
284-
pub enum InProgress {
285-
/// A mailbox is being applied.
286-
ApplyMailbox,
287-
/// A rebase is happening while a mailbox is being applied.
288-
// TODO: test
289-
ApplyMailboxRebase,
290-
/// A git bisect operation has not yet been concluded.
291-
Bisect,
292-
/// A cherry pick operation.
293-
CherryPick,
294-
/// A cherry pick with multiple commits pending.
295-
CherryPickSequence,
296-
/// A merge operation.
297-
Merge,
298-
/// A rebase operation.
299-
Rebase,
300-
/// An interactive rebase operation.
301-
RebaseInteractive,
302-
/// A revert operation.
303-
Revert,
304-
/// A revert operation with multiple commits pending.
305-
RevertSequence,
306-
}
307-
}
245+
pub mod state;
246+
247+
///
248+
pub mod shallow;
308249

309250
///
310251
pub mod discover;

gix/src/open/repository.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ impl ThreadSafeRepository {
267267
// used when spawning new repositories off this one when following worktrees
268268
linked_worktree_options: options,
269269
index: gix_features::fs::MutableSnapshot::new().into(),
270+
shallow_commits: gix_features::fs::MutableSnapshot::new().into(),
270271
})
271272
}
272273
}

gix/src/permission.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
///
2+
pub mod env_var {
3+
///
4+
pub mod resource {
5+
///
6+
pub type Error = gix_sec::permission::Error<std::path::PathBuf>;
7+
}
8+
}

gix/src/permissions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub use crate::repository::permissions::{Config, Environment};

gix/src/prelude.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub use gix_features::parallel::reduce::Finalize;
2+
pub use gix_odb::{Find, FindExt, Header, HeaderExt, Write};
3+
4+
pub use crate::ext::*;

gix/src/progress.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#[cfg(feature = "progress-tree")]
2+
pub use gix_features::progress::prodash::tree;
3+
pub use gix_features::progress::*;

gix/src/repository/impls.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ impl Clone for crate::Repository {
88
self.config.clone(),
99
self.options.clone(),
1010
self.index.clone(),
11+
self.shallow_commits.clone(),
1112
)
1213
}
1314
}
@@ -40,6 +41,7 @@ impl From<&crate::ThreadSafeRepository> for crate::Repository {
4041
repo.config.clone(),
4142
repo.linked_worktree_options.clone(),
4243
repo.index.clone(),
44+
repo.shallow_commits.clone(),
4345
)
4446
}
4547
}
@@ -54,6 +56,7 @@ impl From<crate::ThreadSafeRepository> for crate::Repository {
5456
repo.config,
5557
repo.linked_worktree_options,
5658
repo.index,
59+
repo.shallow_commits,
5760
)
5861
}
5962
}
@@ -68,6 +71,7 @@ impl From<crate::Repository> for crate::ThreadSafeRepository {
6871
config: r.config,
6972
linked_worktree_options: r.options,
7073
index: r.index,
74+
shallow_commits: r.shallow_commits,
7175
}
7276
}
7377
}

gix/src/repository/init.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::cell::RefCell;
22

33
impl crate::Repository {
4+
#[allow(clippy::too_many_arguments)]
45
pub(crate) fn from_refs_and_objects(
56
refs: crate::RefStore,
67
objects: crate::OdbHandle,
@@ -9,6 +10,7 @@ impl crate::Repository {
910
config: crate::config::Cache,
1011
linked_worktree_options: crate::open::Options,
1112
index: crate::worktree::IndexStorage,
13+
shallow_commits: crate::shallow::CommitsStorage,
1214
) -> Self {
1315
let objects = setup_objects(objects, &config);
1416
crate::Repository {
@@ -20,6 +22,7 @@ impl crate::Repository {
2022
config,
2123
options: linked_worktree_options,
2224
index,
25+
shallow_commits,
2326
}
2427
}
2528

gix/src/repository/location.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use std::borrow::Cow;
21
use std::path::PathBuf;
32

4-
use crate::config::tree::{gitoxide, Key};
53
use gix_path::realpath::MAX_SYMLINKS;
64

75
impl crate::Repository {
@@ -43,20 +41,6 @@ impl crate::Repository {
4341
crate::path::install_dir()
4442
}
4543

46-
/// Return the path to the `shallow` file which contains hashes, one per line, that describe commits that don't have their
47-
/// parents within this repository.
48-
pub fn shallow_file(&self) -> PathBuf {
49-
let shallow_name = self
50-
.config
51-
.resolved
52-
.string_filter_by_key(
53-
gitoxide::Core::SHALLOW_FILE.logical_name().as_str(),
54-
&mut self.filter_config_section(),
55-
)
56-
.unwrap_or(Cow::Borrowed("shallow".into()));
57-
self.common_dir().join(gix_path::from_bstr(shallow_name))
58-
}
59-
6044
/// Returns the relative path which is the components between the working tree and the current working dir (CWD).
6145
/// Note that there may be `None` if there is no work tree, even though the `PathBuf` will be empty
6246
/// if the CWD is at the root of the work tree.

0 commit comments

Comments
 (0)