Skip to content

Commit 2170563

Browse files
committed
Merge branch 'maintenance'
2 parents 167a34a + ad50624 commit 2170563

File tree

9 files changed

+29
-20
lines changed

9 files changed

+29
-20
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**/generated-archives/*.tar.xz filter=lfs diff=lfs merge=lfs -text
1+
**/generated-archives/*.tar.xz diff=lfs merge=lfs -text
22

33
# assure line feeds don't interfere with our working copy hash
44
**/tests/fixtures/*.sh text crlf=input eol=lf

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v2
1414
- uses: Swatinem/rust-cache@v2
15-
- run: git lfs fetch && git lfs checkout
1615
- name: tests
1716
run: make test
1817
- name: docs

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ http-reqwest = ["gix/blocking-http-transport-reqwest-rust-tls"]
3737

3838

3939
[dependencies]
40-
gix = { version = "0.55.2", default-features = false, features = ["blocking-network-client", "blob-diff", "revision"] }
40+
gix = { version = "0.57.0", default-features = false, features = ["blocking-network-client", "blob-diff", "revision"] }
4141
serde = { version = "1", features = ["std", "derive"] }
4242
hex = { version = "0.4.3", features = ["serde"] }
4343
smartstring = { version = "1.0.1", features = ["serde"] }

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ baseline-atomic: ## run very slow tests that single-step through all commits
1111

1212
test: ## run all tests with cargo
1313
RUST_BACKTRACE=1 cargo test --test crates-index-diff
14-
GITOXIDE_PACK_CACHE_MEMORY=1g RUST_BACKTRACE=1 cargo test --test baseline --release --features max-performance
14+
GIX_PACK_CACHE_MEMORY=1g RUST_BACKTRACE=1 cargo test --test baseline --release --features max-performance
1515

src/index/diff/delegate.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ impl Delegate {
2121
) -> Result<gix::object::tree::diff::Action, Error> {
2222
use gix::bstr::ByteSlice;
2323
use gix::object::tree::diff::change::Event::*;
24-
use gix::objs::tree::EntryMode::*;
24+
use gix::objs::tree::EntryKind::*;
2525
fn entry_data(
26-
entry: gix::objs::tree::EntryMode,
26+
entry: gix::objs::tree::EntryKind,
2727
id: gix::Id<'_>,
2828
) -> Result<Option<gix::Object<'_>>, Error> {
2929
matches!(entry, Blob | BlobExecutable)
@@ -40,7 +40,7 @@ impl Delegate {
4040
unreachable!("BUG: this is disabled so shouldn't happen")
4141
}
4242
Addition { entry_mode, id } => {
43-
if let Some(obj) = entry_data(entry_mode, id)? {
43+
if let Some(obj) = entry_data(entry_mode.kind(), id)? {
4444
for line in obj.data.lines() {
4545
let version = version_from_json_line(line, change.location)?;
4646
let change = if version.yanked {
@@ -65,11 +65,18 @@ impl Delegate {
6565
});
6666
}
6767
}
68-
Modification { .. } => {
69-
if let Some(diff) = change.event.diff().transpose()? {
68+
Modification {
69+
entry_mode,
70+
previous_id,
71+
id,
72+
..
73+
} => {
74+
if entry_mode.is_blob() {
75+
let old = previous_id.object()?.into_blob();
76+
let new = id.object()?.into_blob();
7077
let mut old_lines = AHashSet::with_capacity(1024);
7178
let location = change.location;
72-
for (number, line) in diff.old.data.lines().enumerate() {
79+
for (number, line) in old.data.lines().enumerate() {
7380
old_lines.insert(Line(number, line));
7481
}
7582

@@ -79,7 +86,7 @@ impl Delegate {
7986
let mut new_versions = RawTable::with_capacity(old_lines.len().min(1024));
8087
let hasher = RandomState::new();
8188

82-
for (number, line) in diff.new.data.lines().enumerate() {
89+
for (number, line) in new.data.lines().enumerate() {
8390
// first quickly check if the exact same line is already present in this file in that case we don't need to do anything else
8491
if old_lines.remove(&Line(number, line)) {
8592
continue;

src/index/diff/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{Change, Index};
2+
use bstr::ByteSlice;
23
use gix::prelude::ObjectIdExt;
34
use std::sync::atomic::AtomicBool;
45

@@ -32,7 +33,7 @@ pub enum Error {
3233
#[error("Failed to parse rev-spec to determine which revisions to diff")]
3334
RevParse(#[from] gix::revision::spec::parse::Error),
3435
#[error(transparent)]
35-
DiffRewrites(#[from] gix::object::tree::diff::rewrites::Error),
36+
DiffRewrites(#[from] gix::diff::new_rewrites::Error),
3637
#[error("Couldn't find blob that showed up when diffing trees")]
3738
FindObject(#[from] gix::object::find::existing::Error),
3839
#[error("Couldn't get the tree of a commit for diffing purposes")]
@@ -127,7 +128,7 @@ impl Index {
127128
.remote_name
128129
.as_deref()
129130
.and_then(|name| {
130-
self.repo.find_remote(name).ok().or_else(|| {
131+
self.repo.find_remote(name.as_bstr()).ok().or_else(|| {
131132
self.repo
132133
.head()
133134
.ok()
@@ -162,7 +163,11 @@ impl Index {
162163
if remote.refspecs(gix::remote::Direction::Fetch).is_empty() {
163164
let spec = format!(
164165
"+refs/heads/{branch}:refs/remotes/{remote}/{branch}",
165-
remote = self.remote_name.as_deref().unwrap_or("origin"),
166+
remote = self
167+
.remote_name
168+
.as_ref()
169+
.map(|n| n.as_bstr())
170+
.unwrap_or("origin".into()),
166171
branch = self.branch_name,
167172
);
168173
remote

src/index/init.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::index::{CloneOptions, LAST_SEEN_REFNAME};
22
use crate::Index;
3+
use std::borrow::Cow;
34
use std::path::Path;
45
use std::sync::atomic::AtomicBool;
56

@@ -61,11 +62,7 @@ impl Index {
6162
};
6263

6364
repo.object_cache_size_if_unset(4 * 1024 * 1024);
64-
let remote_name = repo
65-
.remote_names()
66-
.into_iter()
67-
.next()
68-
.map(ToOwned::to_owned);
65+
let remote_name = repo.remote_names().into_iter().next().map(Cow::into_owned);
6966
Ok(Index {
7067
repo,
7168
remote_name,

src/types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::HashMap;
22

3+
use bstr::BString;
34
use smartstring::alias::String as SmolString;
45
use std::hash::Hash;
56
use std::{fmt, slice};
@@ -13,7 +14,7 @@ pub struct Index {
1314
pub branch_name: &'static str,
1415
/// The name of the symbolic name of the remote to fetch from.
1516
/// If `None`, obtain the remote name from the configuration of the currently checked-out branch.
16-
pub remote_name: Option<String>,
17+
pub remote_name: Option<BString>,
1718
/// The git repository to use for diffing
1819
pub(crate) repo: gix::Repository,
1920
}
Binary file not shown.

0 commit comments

Comments
 (0)