Skip to content

Commit a1794b5

Browse files
committed
fix!: use PathStorageRef in place of &PathStorage
1 parent 1568948 commit a1794b5

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

gix-index/src/access/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::ops::Range;
44
use bstr::{BStr, ByteSlice, ByteVec};
55
use filetime::FileTime;
66

7-
use crate::{entry, extension, Entry, PathStorage, State, Version};
7+
use crate::{entry, extension, Entry, PathStorage, PathStorageRef, State, Version};
88

99
// TODO: integrate this somehow, somewhere, depending on later usage.
1010
#[allow(dead_code)]
@@ -41,7 +41,7 @@ impl State {
4141
&self.entries
4242
}
4343
/// Return our path backing, the place which keeps all paths one after another, with entries storing only the range to access them.
44-
pub fn path_backing(&self) -> &PathStorage {
44+
pub fn path_backing(&self) -> &PathStorageRef {
4545
&self.path_backing
4646
}
4747

@@ -58,7 +58,7 @@ impl State {
5858
/// Return mutable entries along with their path, as obtained from `backing`.
5959
pub fn entries_mut_with_paths_in<'state, 'backing>(
6060
&'state mut self,
61-
backing: &'backing PathStorage,
61+
backing: &'backing PathStorageRef,
6262
) -> impl Iterator<Item = (&'state mut Entry, &'backing BStr)> {
6363
self.entries.iter_mut().map(move |e| {
6464
let path = backing[e.path.clone()].as_bstr();
@@ -279,7 +279,7 @@ impl State {
279279
}
280280

281281
/// Return a writable slice to entries and read-access to their path storage at the same time.
282-
pub fn entries_mut_and_pathbacking(&mut self) -> (&mut [Entry], &PathStorage) {
282+
pub fn entries_mut_and_pathbacking(&mut self) -> (&mut [Entry], &PathStorageRef) {
283283
(&mut self.entries, &self.path_backing)
284284
}
285285

gix-index/src/entry/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
/// The stage of an entry, one of 0 = base, 1 = ours, 2 = theirs
1+
/// The stage of an entry, one of…
2+
/// * 0 = no conflict,
3+
/// * 1 = base,
4+
/// * 2 = ours,
5+
/// * 3 = theirs
26
pub type Stage = u32;
37

48
///
@@ -71,7 +75,7 @@ mod access {
7175
backing[self.path.clone()].as_bstr()
7276
}
7377

74-
/// Return an entry's stage.
78+
/// Return an entry's stage. See [entry::Stage] for possible values.
7579
pub fn stage(&self) -> entry::Stage {
7680
self.flags.stage()
7781
}

gix-index/src/entry/stat.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,22 @@ impl Stat {
9292
size: fstat.len() as u32,
9393
};
9494
#[cfg(unix)]
95-
use std::os::unix::fs::MetadataExt;
96-
#[cfg(unix)]
97-
let res = Stat {
98-
mtime: mtime.try_into().unwrap_or_default(),
99-
ctime: ctime.try_into().unwrap_or_default(),
100-
// truncating to 32 bits is fine here because
101-
// that's what the linux syscalls returns
102-
// just rust upcasts to 64 bits for some reason?
103-
// numbers this large are impractical anyway (that's a lot of hard-drives).
104-
dev: fstat.dev() as u32,
105-
ino: fstat.ino() as u32,
106-
uid: fstat.uid(),
107-
gid: fstat.gid(),
108-
// truncation to 32 bits is on purpose (git does the same).
109-
size: fstat.len() as u32,
95+
let res = {
96+
use std::os::unix::fs::MetadataExt;
97+
Stat {
98+
mtime: mtime.try_into().unwrap_or_default(),
99+
ctime: ctime.try_into().unwrap_or_default(),
100+
// truncating to 32 bits is fine here because
101+
// that's what the linux syscalls returns
102+
// just rust upcasts to 64 bits for some reason?
103+
// numbers this large are impractical anyway (that's a lot of hard-drives).
104+
dev: fstat.dev() as u32,
105+
ino: fstat.ino() as u32,
106+
uid: fstat.uid(),
107+
gid: fstat.gid(),
108+
// truncation to 32 bits is on purpose (git does the same).
109+
size: fstat.len() as u32,
110+
}
110111
};
111112

112113
Ok(res)

gix-index/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ mod impls {
121121
f,
122122
"{} {}{:?} {} {}",
123123
match entry.flags.stage() {
124-
0 => "BASE ",
125-
1 => "OURS ",
126-
2 => "THEIRS ",
124+
0 => " ",
125+
1 => "BASE ",
126+
2 => "OURS ",
127+
3 => "THEIRS ",
127128
_ => "UNKNOWN",
128129
},
129130
if entry.flags.is_empty() {

0 commit comments

Comments
 (0)