Skip to content

Commit 2f9f0ac

Browse files
committed
Merge branch 'status'
2 parents 2856434 + acc1331 commit 2f9f0ac

File tree

28 files changed

+140
-111
lines changed

28 files changed

+140
-111
lines changed

Diff for: Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: gitoxide-core/src/repository/attributes/validate_baseline.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ pub(crate) mod function {
305305
}
306306

307307
fn parse_exclude(line: &str) -> Option<(String, Baseline)> {
308-
let (left, value) = line.split_at(line.find(|c| c == '\t')?);
308+
let (left, value) = line.split_at(line.find('\t')?);
309309
let value = &value[1..];
310310

311311
let location = if left == "::" {
312312
None
313313
} else {
314-
let mut tokens = left.split(|b| b == ':');
314+
let mut tokens = left.split(':');
315315
let source = tokens.next()?;
316316
let line_number: usize = tokens.next()?.parse().ok()?;
317317
let pattern = tokens.next()?;
@@ -363,8 +363,8 @@ pub(crate) mod function {
363363
"unspecified" => StateRef::Unspecified,
364364
_ => StateRef::from_bytes(info.as_bytes()),
365365
};
366-
path = path.trim_end_matches(|b| b == ':');
367-
let attr = attr.trim_end_matches(|b| b == ':');
366+
path = path.trim_end_matches(':');
367+
let attr = attr.trim_end_matches(':');
368368
let assignment = gix::attrs::AssignmentRef {
369369
name: gix::attrs::NameRef::try_from(attr.as_bytes().as_bstr()).ok()?,
370370
state,

Diff for: gitoxide-core/src/repository/index/entries.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ pub(crate) mod function {
319319

320320
#[cfg(feature = "serde")]
321321
fn to_json(
322-
mut out: &mut impl std::io::Write,
322+
out: &mut impl std::io::Write,
323323
index: &gix::index::File,
324324
entry: &gix::index::Entry,
325325
attrs: Option<Attrs>,
@@ -338,7 +338,7 @@ pub(crate) mod function {
338338
}
339339

340340
serde_json::to_writer(
341-
&mut out,
341+
&mut *out,
342342
&Entry {
343343
stat: &entry.stat,
344344
hex_id: entry.id.to_hex().to_string(),

Diff for: gix-config/src/file/section/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a> Section<'a> {
7575
/// Stream ourselves to the given `out`, in order to reproduce this section mostly losslessly
7676
/// as it was parsed.
7777
pub fn write_to(&self, mut out: &mut dyn std::io::Write) -> std::io::Result<()> {
78-
self.header.write_to(&mut out)?;
78+
self.header.write_to(&mut *out)?;
7979

8080
if self.body.0.is_empty() {
8181
return Ok(());

Diff for: gix-config/src/file/write.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl File<'_> {
1818
pub fn write_to_filter(
1919
&self,
2020
mut out: &mut dyn std::io::Write,
21-
mut filter: &mut dyn FnMut(&Section<'_>) -> bool,
21+
filter: &mut dyn FnMut(&Section<'_>) -> bool,
2222
) -> std::io::Result<()> {
2323
let nl = self.detect_newline_style();
2424

@@ -27,7 +27,8 @@ impl File<'_> {
2727
event.write_to(&mut out)?;
2828
}
2929

30-
if !ends_with_newline(self.frontmatter_events.as_ref(), nl, true) && self.sections.values().any(&mut filter)
30+
if !ends_with_newline(self.frontmatter_events.as_ref(), nl, true)
31+
&& self.sections.values().any(&mut *filter)
3132
{
3233
out.write_all(nl)?;
3334
}

Diff for: gix-config/src/parse/event.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Event<'_> {
3333

3434
/// Stream ourselves to the given `out`, in order to reproduce this event mostly losslessly
3535
/// as it was parsed.
36-
pub fn write_to(&self, mut out: &mut dyn std::io::Write) -> std::io::Result<()> {
36+
pub fn write_to(&self, out: &mut dyn std::io::Write) -> std::io::Result<()> {
3737
match self {
3838
Self::ValueNotDone(e) => {
3939
out.write_all(e.as_ref())?;
@@ -42,8 +42,8 @@ impl Event<'_> {
4242
Self::Whitespace(e) | Self::Newline(e) | Self::Value(e) | Self::ValueDone(e) => out.write_all(e.as_ref()),
4343
Self::KeyValueSeparator => out.write_all(b"="),
4444
Self::SectionKey(k) => out.write_all(k.0.as_ref()),
45-
Self::SectionHeader(h) => h.write_to(&mut out),
46-
Self::Comment(c) => c.write_to(&mut out),
45+
Self::SectionHeader(h) => h.write_to(out),
46+
Self::Comment(c) => c.write_to(out),
4747
}
4848
}
4949

Diff for: gix-config/src/parse/events.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@ pub type FrontMatterEvents<'a> = SmallVec<[Event<'a>; 8]>;
2828
///
2929
/// For concrete examples, some notable differences are:
3030
/// - `git-config` sections permit subsections via either a quoted string
31-
/// (`[some-section "subsection"]`) or via the deprecated dot notation
32-
/// (`[some-section.subsection]`). Successful parsing these section names is not
33-
/// well defined in typical `.ini` parsers. This parser will handle these cases
34-
/// perfectly.
31+
/// (`[some-section "subsection"]`) or via the deprecated dot notation
32+
/// (`[some-section.subsection]`). Successful parsing these section names is not
33+
/// well defined in typical `.ini` parsers. This parser will handle these cases
34+
/// perfectly.
3535
/// - Comment markers are not strictly defined either. This parser will always
36-
/// and only handle a semicolon or octothorpe (also known as a hash or number
37-
/// sign).
36+
/// and only handle a semicolon or octothorpe (also known as a hash or number
37+
/// sign).
3838
/// - Global properties may be allowed in `.ini` parsers, but is strictly
39-
/// disallowed by this parser.
39+
/// disallowed by this parser.
4040
/// - Only `\t`, `\n`, `\b` `\\` are valid escape characters.
4141
/// - Quoted and semi-quoted values will be parsed (but quotes will be included
42-
/// in event outputs). An example of a semi-quoted value is `5"hello world"`,
43-
/// which should be interpreted as `5hello world` after
44-
/// [normalization][crate::value::normalize()].
42+
/// in event outputs). An example of a semi-quoted value is `5"hello world"`,
43+
/// which should be interpreted as `5hello world` after
44+
/// [normalization][crate::value::normalize()].
4545
/// - Line continuations via a `\` character is supported (inside or outside of quotes)
4646
/// - Whitespace handling similarly follows the `git-config` specification as
47-
/// closely as possible, where excess whitespace after a non-quoted value are
48-
/// trimmed, and line continuations onto a new line with excess spaces are kept.
47+
/// closely as possible, where excess whitespace after a non-quoted value are
48+
/// trimmed, and line continuations onto a new line with excess spaces are kept.
4949
/// - Only equal signs (optionally padded by spaces) are valid name/value
50-
/// delimiters.
50+
/// delimiters.
5151
///
5252
/// Note that things such as case-sensitivity or duplicate sections are
5353
/// _not_ handled. This parser is a low level _syntactic_ interpreter
@@ -62,8 +62,8 @@ pub type FrontMatterEvents<'a> = SmallVec<[Event<'a>; 8]>;
6262
/// # Trait Implementations
6363
///
6464
/// - This struct does _not_ implement [`FromStr`] due to lifetime
65-
/// constraints implied on the required `from_str` method. Instead, it provides
66-
/// [`From<&'_ str>`].
65+
/// constraints implied on the required `from_str` method. Instead, it provides
66+
/// [`From<&'_ str>`].
6767
///
6868
/// # Idioms
6969
///

Diff for: gix-fs/src/symlink.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
use std::{io, io::ErrorKind::AlreadyExists, path::Path};
22

3-
#[cfg(not(windows))]
43
/// Create a new symlink at `link` which points to `original`.
54
///
65
/// Note that `original` doesn't have to exist.
6+
#[cfg(not(windows))]
77
pub fn create(original: &Path, link: &Path) -> io::Result<()> {
88
std::os::unix::fs::symlink(original, link)
99
}
1010

11-
#[cfg(not(windows))]
1211
/// Remove a symlink.
1312
///
1413
/// Note that on only on windows this is special.
14+
#[cfg(not(windows))]
1515
pub fn remove(path: &Path) -> io::Result<()> {
1616
std::fs::remove_file(path)
1717
}
@@ -31,12 +31,12 @@ pub fn remove(path: &Path) -> io::Result<()> {
3131
}
3232
}
3333

34-
#[cfg(windows)]
3534
/// Create a new symlink at `link` which points to `original`.
3635
///
3736
/// Note that if a symlink target (the `original`) isn't present on disk, it's assumed to be a
3837
/// file, creating a dangling file symlink. This is similar to a dangling symlink on Unix,
3938
/// which doesn't have to care about the target type though.
39+
#[cfg(windows)]
4040
pub fn create(original: &Path, link: &Path) -> io::Result<()> {
4141
use std::os::windows::fs::{symlink_dir, symlink_file};
4242
// TODO: figure out if links to links count as files or whatever they point at
@@ -53,20 +53,20 @@ pub fn create(original: &Path, link: &Path) -> io::Result<()> {
5353
}
5454
}
5555

56-
#[cfg(not(windows))]
5756
/// Return true if `err` indicates that a file collision happened, i.e. a symlink couldn't be created as the `link`
5857
/// already exists as filesystem object.
58+
#[cfg(not(windows))]
5959
pub fn is_collision_error(err: &std::io::Error) -> bool {
6060
// TODO: use ::IsDirectory as well when stabilized instead of raw_os_error(), and ::FileSystemLoop respectively
6161
err.kind() == AlreadyExists
62-
|| err.raw_os_error() == Some(if cfg!(windows) { 5 } else { 21 })
62+
|| err.raw_os_error() == Some(21)
6363
|| err.raw_os_error() == Some(62) // no-follow on symlnk on mac-os
6464
|| err.raw_os_error() == Some(40) // no-follow on symlnk on ubuntu
6565
}
6666

67-
#[cfg(windows)]
6867
/// Return true if `err` indicates that a file collision happened, i.e. a symlink couldn't be created as the `link`
6968
/// already exists as filesystem object.
69+
#[cfg(windows)]
7070
pub fn is_collision_error(err: &std::io::Error) -> bool {
7171
err.kind() == AlreadyExists || err.kind() == std::io::ErrorKind::PermissionDenied
7272
}

Diff for: gix-ignore/src/search.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Search {
5555
.transpose()?,
5656
);
5757
group.patterns.extend(pattern::List::<Ignore>::from_file(
58-
&git_dir.join("info").join("exclude"),
58+
git_dir.join("info").join("exclude"),
5959
None,
6060
follow_symlinks,
6161
buf,

Diff for: gix-odb/tests/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ gix-date = { path = "../../gix-date" }
2424
gix-object = { path = "../../gix-object" }
2525
gix-pack = { path = "../../gix-pack" }
2626

27-
gix-testtools = { path = "../../tests/tools"}
27+
gix-testtools = { path = "../../tests/tools" }
2828
gix-actor = { path = "../../gix-actor" }
2929
pretty_assertions = "1.0.0"
3030
filetime = "0.2.15"
3131
maplit = "1.0.2"
32+
crossbeam-channel = "0.5.13"
3233

Binary file not shown.

Diff for: gix-odb/tests/odb/regression/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ mod repo_with_small_packs {
1717
}
1818

1919
#[test]
20-
#[cfg(feature = "internal-testing-gix-features-parallel")]
20+
#[cfg(feature = "gix-features-parallel")]
2121
fn multi_threaded_access_will_not_panic() -> crate::Result {
2222
for arg in ["no", "without-multi-index"] {
23-
let base = gix_testtools::scripted_fixture_read_only_with_args("make_repo_multi_index.sh", Some(arg))?
24-
.join(".git")
25-
.join("objects");
23+
let base =
24+
gix_testtools::scripted_fixture_read_only_with_args_standalone("make_repo_multi_index.sh", Some(arg))?
25+
.join(".git")
26+
.join("objects");
2627
let store = gix_odb::at(base)?;
2728
let (tx, barrier) = crossbeam_channel::unbounded::<()>();
2829
let handles = (0..std::thread::available_parallelism()?.get()).map(|tid| {
@@ -36,7 +37,7 @@ mod repo_with_small_packs {
3637
for id in store.iter()? {
3738
let id = id?;
3839
assert!(
39-
store.try_find(id, &mut buf).is_ok(),
40+
store.try_find(&id, &mut buf).is_ok(),
4041
"Thread {} could not find {}",
4142
tid,
4243
id

Diff for: gix-pack/src/bundle/write/mod.rs

+32-26
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ impl crate::Bundle {
5151
/// * `progress` provides detailed progress information which can be discarded with [`gix_features::progress::Discard`].
5252
/// * `should_interrupt` is checked regularly and when true, the whole operation will stop.
5353
/// * `thin_pack_base_object_lookup` If set, we expect to see a thin-pack with objects that reference their base object by object id which is
54-
/// expected to exist in the object database the bundle is contained within.
55-
/// `options` further configure how the task is performed.
54+
/// expected to exist in the object database the bundle is contained within.
55+
/// `options` further configure how the task is performed.
5656
///
5757
/// # Note
5858
///
@@ -300,31 +300,37 @@ impl crate::Bundle {
300300
)?;
301301
drop(pack_entries_iter);
302302

303-
let data_path = directory.join(format!("pack-{}.pack", outcome.data_hash.to_hex()));
304-
let index_path = data_path.with_extension("idx");
305-
let keep_path = data_path.with_extension("keep");
303+
if outcome.num_objects == 0 {
304+
WriteOutcome {
305+
outcome,
306+
data_path: None,
307+
index_path: None,
308+
keep_path: None,
309+
}
310+
} else {
311+
let data_path = directory.join(format!("pack-{}.pack", outcome.data_hash.to_hex()));
312+
let index_path = data_path.with_extension("idx");
313+
let keep_path = data_path.with_extension("keep");
306314

307-
std::fs::write(&keep_path, b"")?;
308-
Arc::try_unwrap(data_file)
309-
.expect("only one handle left after pack was consumed")
310-
.into_inner()
311-
.into_inner()
312-
.map_err(|err| Error::from(err.into_error()))?
313-
.persist(&data_path)?;
314-
index_file
315-
.persist(&index_path)
316-
.map_err(|err| {
317-
progress.info(format!(
318-
"pack file at {} is retained despite failing to move the index file into place. You can use plumbing to make it usable.",
319-
data_path.display()
320-
));
321-
err
322-
})?;
323-
WriteOutcome {
324-
outcome,
325-
data_path: Some(data_path),
326-
index_path: Some(index_path),
327-
keep_path: Some(keep_path),
315+
std::fs::write(&keep_path, b"")?;
316+
Arc::try_unwrap(data_file)
317+
.expect("only one handle left after pack was consumed")
318+
.into_inner()
319+
.into_inner()
320+
.map_err(|err| Error::from(err.into_error()))?
321+
.persist(&data_path)?;
322+
index_file
323+
.persist(&index_path)
324+
.map_err(|err| {
325+
gix_features::trace::warn!("pack file at \"{}\" is retained despite failing to move the index file into place. You can use plumbing to make it usable.",data_path.display());
326+
err
327+
})?;
328+
WriteOutcome {
329+
outcome,
330+
data_path: Some(data_path),
331+
index_path: Some(index_path),
332+
keep_path: Some(keep_path),
333+
}
328334
}
329335
}
330336
None => WriteOutcome {

Diff for: gix-pack/src/cache/delta/from_offsets.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ const PACK_HEADER_LEN: usize = 12;
3131
impl<T> Tree<T> {
3232
/// Create a new `Tree` from any data sorted by offset, ascending as returned by the `data_sorted_by_offsets` iterator.
3333
/// * `get_pack_offset(item: &T) -> data::Offset` is a function returning the pack offset of the given item, which can be used
34-
/// for obtaining the objects entry within the pack.
34+
/// for obtaining the objects entry within the pack.
3535
/// * `pack_path` is the path to the pack file itself and from which to read the entry data, which is a pack file matching the offsets
36-
/// returned by `get_pack_offset(…)`.
36+
/// returned by `get_pack_offset(…)`.
3737
/// * `progress` is used to track progress when creating the tree.
3838
/// * `resolve_in_pack_id(gix_hash::oid) -> Option<data::Offset>` takes an object ID and tries to resolve it to an object within this pack if
39-
/// possible. Failing to do so aborts the operation, and this function is not expected to be called in usual packs. It's a theoretical
40-
/// possibility though as old packs might have referred to their objects using the 20 bytes hash, instead of their encoded offset from the base.
39+
/// possible. Failing to do so aborts the operation, and this function is not expected to be called in usual packs. It's a theoretical
40+
/// possibility though as old packs might have referred to their objects using the 20 bytes hash, instead of their encoded offset from the base.
4141
///
4242
/// Note that the sort order is ascending. The given pack file path must match the provided offsets.
4343
pub fn from_offsets_in_pack(

Diff for: gix-pack/src/data/output/entry/iter_from_counts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(crate) mod function {
4040
///
4141
/// * ~~currently there is no way to easily write the pack index, even though the state here is uniquely positioned to do
4242
/// so with minimal overhead (especially compared to `gix index-from-pack`)~~ Probably works now by chaining Iterators
43-
/// or keeping enough state to write a pack and then generate an index with recorded data.
43+
/// or keeping enough state to write a pack and then generate an index with recorded data.
4444
///
4545
pub fn iter_from_counts<Find>(
4646
mut counts: Vec<output::Count>,

Diff for: gix-pack/src/index/write/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ impl crate::index::File {
7878
///
7979
/// * neither in-pack nor out-of-pack Ref Deltas are supported here, these must have been resolved beforehand.
8080
/// * `make_resolver()` will only be called after the iterator stopped returning elements and produces a function that
81-
/// provides all bytes belonging to a pack entry writing them to the given mutable output `Vec`.
82-
/// It should return `None` if the entry cannot be resolved from the pack that produced the `entries` iterator, causing
83-
/// the write operation to fail.
81+
/// provides all bytes belonging to a pack entry writing them to the given mutable output `Vec`.
82+
/// It should return `None` if the entry cannot be resolved from the pack that produced the `entries` iterator, causing
83+
/// the write operation to fail.
8484
#[allow(clippy::too_many_arguments)]
8585
pub fn write_data_iter_to_stream<F, F2, R>(
8686
version: crate::index::Version,

0 commit comments

Comments
 (0)