Skip to content

Commit 8892cb1

Browse files
authored
Merge pull request #2088 from GitoxideLabs/improvements
improvements
2 parents 8d4d18d + 88dc1c2 commit 8892cb1

File tree

15 files changed

+58
-27
lines changed

15 files changed

+58
-27
lines changed

gix-ref/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "A crate to handle git references"
99
authors = ["Sebastian Thiel <[email protected]>"]
1010
edition = "2021"
1111
include = ["src/**/*", "LICENSE-*"]
12-
rust-version = "1.70"
12+
rust-version = "1.74"
1313
autotests = false
1414

1515
[lib]

gix-ref/src/store/file/find.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ impl file::Store {
280280
.filter_map(|c| gix_path::try_os_str_into_bstr(c.as_os_str().into()).ok())
281281
.any(|c| gix_validate::path::component_is_windows_device(c.as_ref()))
282282
{
283-
return Err(std::io::Error::new(
284-
std::io::ErrorKind::Other,
285-
format!("Illegal use of reserved Windows device name in \"{}\"", name.as_bstr()),
286-
));
283+
return Err(std::io::Error::other(format!(
284+
"Illegal use of reserved Windows device name in \"{}\"",
285+
name.as_bstr()
286+
)));
287287
}
288288

289289
let ref_path = base.join(relative_path);

gix-ref/src/store/file/log/iter.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ where
129129
{
130130
let pos = log.seek(std::io::SeekFrom::End(0))?;
131131
if buf.is_empty() {
132-
return Err(std::io::Error::new(
133-
std::io::ErrorKind::Other,
132+
return Err(std::io::Error::other(
134133
"Zero sized buffers are not allowed, use 256 bytes or more for typical logs",
135134
));
136135
}
@@ -217,10 +216,10 @@ where
217216
} else {
218217
let npos = last_read_pos.saturating_sub((self.buf.len() - end) as u64);
219218
if npos == last_read_pos {
220-
return Some(Err(std::io::Error::new(
221-
std::io::ErrorKind::Other,
222-
format!("buffer too small for line size, got until {:?}", self.buf.as_bstr()),
223-
)
219+
return Some(Err(std::io::Error::other(format!(
220+
"buffer too small for line size, got until {:?}",
221+
self.buf.as_bstr()
222+
))
224223
.into()));
225224
}
226225
let n = (last_read_pos - npos) as usize;

gix-ref/src/store/file/log/line.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod write {
2626

2727
impl From<Error> for io::Error {
2828
fn from(err: Error) -> Self {
29-
io::Error::new(io::ErrorKind::Other, err)
29+
io::Error::other(err)
3030
}
3131
}
3232

gix-ref/src/store/file/overlay_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl file::Store {
438438
Some(prefix) => packed.iter_prefixed(prefix.into_owned()),
439439
None => packed.iter(),
440440
}
441-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?
441+
.map_err(std::io::Error::other)?
442442
.peekable(),
443443
),
444444
None => None,

gix-ref/src/store/file/transaction/commit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Transaction<'_, '_> {
9797
// TODO: when Kind::IsADirectory becomes stable, use that.
9898
let err = if err.instance.resource_path().is_dir() {
9999
gix_tempfile::remove_dir::empty_depth_first(err.instance.resource_path())
100-
.map_err(|io_err| std::io::Error::new(std::io::ErrorKind::Other, io_err))
100+
.map_err(std::io::Error::other)
101101
.and_then(|_| err.instance.commit().map_err(|err| err.error))
102102
.err()
103103
} else {

gix-ref/tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
99
description = "Test the gix-ref crate with feature toggles"
1010
authors = ["Sebastian Thiel <[email protected]>"]
1111
edition = "2021"
12-
rust-version = "1.70"
12+
rust-version = "1.74"
1313

1414
[features]
1515
gix-features-parallel = ["gix-features/parallel"] # test sorted parallel loose file traversal

gix-refspec/src/instruction.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ pub enum Push<'a> {
3737
/// If true, allow non-fast-forward updates of `dest`.
3838
allow_non_fast_forward: bool,
3939
},
40+
/// Exclude a single ref.
41+
Exclude {
42+
/// A full or partial ref name to exclude, or multiple if a single `*` is used.
43+
src: &'a BStr,
44+
},
4045
}
4146

4247
/// Any source can either be a ref name (full or partial) or a fully spelled out hex-sha for an object, on the remote side.

gix-refspec/src/parse.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ pub enum Error {
88
NegativeWithDestination,
99
#[error("Negative specs must not be empty")]
1010
NegativeEmpty,
11-
#[error("Negative specs are only supported when fetching")]
12-
NegativeUnsupported,
1311
#[error("Negative specs must be object hashes")]
1412
NegativeObjectHash,
1513
#[error("Negative specs must be full ref names, starting with \"refs/\"")]
@@ -62,9 +60,6 @@ pub(crate) mod function {
6260
let mode = match spec.first() {
6361
Some(&b'^') => {
6462
spec = &spec[1..];
65-
if operation == Operation::Push {
66-
return Err(Error::NegativeUnsupported);
67-
}
6863
Mode::Negative
6964
}
7065
Some(&b'+') => {

gix-refspec/src/spec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl<'a> RefSpecRef<'a> {
209209
dst,
210210
allow_non_fast_forward: matches!(self.mode, Mode::Force),
211211
}),
212+
(Mode::Negative, Some(src), None) => Instruction::Push(Push::Exclude { src }),
212213
(mode, src, dest) => {
213214
unreachable!(
214215
"BUG: push instructions with {:?} {:?} {:?} are not possible",

0 commit comments

Comments
 (0)