Skip to content

Commit 0b62ff4

Browse files
committed
upgrade gix to the latest version
1 parent 7c1628b commit 0b62ff4

File tree

17 files changed

+97
-86
lines changed

17 files changed

+97
-86
lines changed

Cargo.lock

Lines changed: 58 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolver = "2"
55
[workspace.dependencies]
66
bstr = "1.11.1"
77
# Add the `tracing` or `tracing-detail` features to see more of gitoxide in the logs. Useful to see which programs it invokes.
8-
gix = { git = "https://github.com/GitoxideLabs/gitoxide", rev = "7255a5fc0aa790b54e3176e8ecf066457acd9eef", default-features = false, features = [
8+
gix = { git = "https://github.com/GitoxideLabs/gitoxide", branch = "improvements", default-features = false, features = [
99
] }
1010
gix-testtools = "0.15.0"
1111
insta = "1.41.1"

crates/but-cli/src/command/diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn intersect_workspace_ranges(
7878
let mut missed_hunks = Vec::new();
7979
for change in worktree_changes {
8080
let unidiff = change.unified_diff(repo, 0)?;
81-
let but_core::UnifiedDiff::Patch { hunks } = unidiff else {
81+
let but_core::UnifiedDiff::Patch { hunks, .. } = unidiff else {
8282
continue;
8383
};
8484
let mut intersections = Vec::new();

crates/but-cli/src/command/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub(crate) fn discard_change(
173173
change.path == path
174174
&& change.previous_path() == previous_path.as_ref().map(|p| p.as_bstr())
175175
}).with_context(|| format!("Couldn't find worktree change for file at '{path}' (previous-path: {previous_path:?}"))?;
176-
let UnifiedDiff::Patch { hunks } =
176+
let UnifiedDiff::Patch { hunks, .. } =
177177
worktree_changes.unified_diff(&repo, UI_CONTEXT_LINES)?
178178
else {
179179
bail!("No hunks available for given '{path}'")

crates/but-core/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ pub enum UnifiedDiff {
140140
Patch {
141141
/// All non-overlapping hunks, including their context lines.
142142
hunks: Vec<unified_diff::DiffHunk>,
143+
/// If `true`, a binary to text filter (`textconv` in Git config) was used to obtain the `hunks` in the diff.
144+
/// This means hunk-based operations must be disabled.
145+
is_result_of_binary_to_text_conversion: bool,
143146
},
144147
}
145148

crates/but-core/src/unified_diff.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ impl UnifiedDiff {
164164
}
165165
let input = prep.interned_input();
166166
UnifiedDiff::Patch {
167+
is_result_of_binary_to_text_conversion: prep.old_or_new_is_derived,
167168
hunks: gix::diff::blob::diff(
168169
algorithm,
169170
&input,
@@ -185,7 +186,7 @@ impl UnifiedDiff {
185186
use gix::diff::blob::platform::resource::Data;
186187
fn size_for_data(data: Data<'_>) -> Option<u64> {
187188
match data {
188-
Data::Missing | Data::Buffer(_) => None,
189+
Data::Missing | Data::Buffer { .. } => None,
189190
Data::Binary { size } => Some(size),
190191
}
191192
}

crates/but-core/tests/core/diff/worktree_changes.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ fn modified_in_index_and_worktree_mod_mod() -> Result<()> {
11941194
}
11951195
"#);
11961196

1197-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1197+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
11981198
unreachable!("need hunks")
11991199
};
12001200
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1251,7 +1251,7 @@ fn modified_in_index_and_worktree_mod_mod_symlink() -> Result<()> {
12511251
}
12521252
"#);
12531253

1254-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1254+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
12551255
unreachable!("need hunks")
12561256
};
12571257
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1304,7 +1304,7 @@ fn modified_in_index_and_worktree_add_mod() -> Result<()> {
13041304
}
13051305
"#);
13061306

1307-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1307+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
13081308
unreachable!("need hunks")
13091309
};
13101310
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1341,7 +1341,7 @@ fn modified_in_index_and_worktree_add_del() -> Result<()> {
13411341
}
13421342
"#);
13431343

1344-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1344+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
13451345
unreachable!("need hunks")
13461346
};
13471347
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1382,7 +1382,7 @@ fn modified_in_index_and_worktree_del_add() -> Result<()> {
13821382
}
13831383
"#);
13841384

1385-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1385+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
13861386
unreachable!("need hunks")
13871387
};
13881388
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1432,7 +1432,7 @@ fn modified_in_index_and_worktree_mod_del() -> Result<()> {
14321432
}
14331433
"#);
14341434

1435-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1435+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
14361436
unreachable!("need hunks")
14371437
};
14381438
// newlines at the end should work.
@@ -1476,7 +1476,7 @@ fn modified_in_index_and_worktree_rename_mod() -> Result<()> {
14761476
}
14771477
"#);
14781478

1479-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1479+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
14801480
unreachable!("need hunks")
14811481
};
14821482
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1519,7 +1519,7 @@ fn modified_in_index_and_worktree_rename_rename() -> Result<()> {
15191519
}
15201520
"#);
15211521

1522-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1522+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
15231523
unreachable!("need hunks")
15241524
};
15251525
assert_eq!(
@@ -1556,7 +1556,7 @@ fn modified_in_index_and_worktree_rename_del() -> Result<()> {
15561556
}
15571557
"#);
15581558

1559-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1559+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
15601560
unreachable!("need hunks")
15611561
};
15621562
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1598,7 +1598,7 @@ fn modified_in_index_and_worktree_mod_rename() -> Result<()> {
15981598
}
15991599
"#);
16001600

1601-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1601+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
16021602
unreachable!("need hunks")
16031603
};
16041604
insta::assert_snapshot!(hunks[0].diff, @r"
@@ -1652,8 +1652,12 @@ fn modified_in_index_and_worktree_rename_add() -> Result<()> {
16521652
"#);
16531653

16541654
let [
1655-
UnifiedDiff::Patch { hunks: ref hunks1 },
1656-
UnifiedDiff::Patch { hunks: ref hunks2 },
1655+
UnifiedDiff::Patch {
1656+
hunks: ref hunks1, ..
1657+
},
1658+
UnifiedDiff::Patch {
1659+
hunks: ref hunks2, ..
1660+
},
16571661
] = unified_diffs(actual, &repo)?[..]
16581662
else {
16591663
unreachable!("need hunks")
@@ -1702,7 +1706,7 @@ fn modified_in_index_and_worktree_add_rename() -> Result<()> {
17021706
}
17031707
"#);
17041708

1705-
let [UnifiedDiff::Patch { ref hunks }] = unified_diffs(actual, &repo)?[..] else {
1709+
let [UnifiedDiff::Patch { ref hunks, .. }] = unified_diffs(actual, &repo)?[..] else {
17061710
unreachable!("need hunks")
17071711
};
17081712
assert_eq!(

crates/but-core/tests/core/unified_diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,6 @@ fn submodule_added() -> anyhow::Result<()> {
253253
fn extract_patch(diff: UnifiedDiff) -> Vec<unified_diff::DiffHunk> {
254254
match diff {
255255
UnifiedDiff::Binary | UnifiedDiff::TooLarge { .. } => unreachable!("should have patches"),
256-
UnifiedDiff::Patch { hunks } => hunks,
256+
UnifiedDiff::Patch { hunks, .. } => hunks,
257257
}
258258
}

crates/but-hunk-dependency/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn tree_changes_to_input_files(
186186
let mut files = Vec::new();
187187
for change in changes {
188188
let diff = change.unified_diff(repo, 0)?;
189-
let UnifiedDiff::Patch { hunks } = diff else {
189+
let UnifiedDiff::Patch { hunks, .. } = diff else {
190190
unreachable!("Test repos don't have file-size issue")
191191
};
192192
let change_type = change.status.kind();

crates/but-hunk-dependency/src/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl HunkDependencies {
6767
let mut diffs = Vec::<(HunkHash, Vec<HunkLock>)>::new();
6868
for change in worktree_changes {
6969
let unidiff = change.unified_diff(repo, 0 /* zero context lines */)?;
70-
let UnifiedDiff::Patch { hunks } = unidiff else {
70+
let UnifiedDiff::Patch { hunks, .. } = unidiff else {
7171
continue;
7272
};
7373
for hunk in hunks {

crates/but-hunk-dependency/tests/hunk_dependency/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn intersect_workspace_ranges(
1414
let mut missed_hunks = Vec::new();
1515
for change in worktree_changes {
1616
let unidiff = change.unified_diff(repo, 0)?;
17-
let but_core::UnifiedDiff::Patch { hunks } = unidiff else {
17+
let but_core::UnifiedDiff::Patch { hunks, .. } = unidiff else {
1818
continue;
1919
};
2020
let mut intersections = Vec::new();

crates/but-workspace/src/commit_engine/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ fn apply_worktree_changes<'repo>(
224224
"BUG: if this changes, the uses of worktree filters need a review"
225225
);
226226
// TODO(perf): avoid computing the unified diff here, we only need hunks with, usually with zero context.
227-
let UnifiedDiff::Patch { hunks } =
227+
let UnifiedDiff::Patch { hunks, .. } =
228228
worktree_change.unified_diff_with_filter(repo, context_lines, &mut diff_filter)?
229229
else {
230230
into_err_spec(possible_change, RejectionReason::FileToLargeOrBinary);

crates/but-workspace/src/discard/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub fn purge_and_restore_from_head_tree(
289289
}
290290

291291
// TODO(motivational test): restore what was there in the the index, and then on disk by checkout.
292-
let path = path_check.verified_path(&gix::path::from_bstr(rela_path))?;
292+
let path = path_check.verified_path(rela_path)?;
293293
if !path.is_dir() {
294294
// Should always exist, this is why it's a rename in the first place.
295295
std::fs::remove_file(path).or_else(|err| {

crates/but-workspace/src/discard/function.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ pub fn discard_workspace_changes(
6363
if spec.hunk_headers.is_empty() {
6464
match wt_change.status {
6565
TreeStatus::Addition { is_untracked, .. } => {
66-
std::fs::remove_file(
67-
path_check
68-
.verified_path(&gix::path::from_bstr(wt_change.path.as_bstr()))?,
69-
)?;
66+
std::fs::remove_file(path_check.verified_path(&wt_change.path)?)?;
7067
if !is_untracked {
7168
file::index::mark_entry_for_deletion(
7269
&mut index,

crates/but-workspace/src/discard/hunk/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub fn restore_state_to_worktree(
4040
)?;
4141
let UnifiedDiff::Patch {
4242
hunks: hunks_in_worktree,
43+
..
4344
} = wt_change.unified_diff_with_filter(repo, context_lines, &mut diff_filter)?
4445
else {
4546
bail!("Couldn't obtain diff for worktree changes.")

crates/but-workspace/tests/workspace/discard/hunk.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ fn from_end() -> anyhow::Result<()> {
130130
17
131131
18
132132
"));
133-
let UnifiedDiff::Patch { mut hunks } = change.unified_diff(&repo, CONTEXT_LINES)? else {
133+
let UnifiedDiff::Patch { mut hunks, .. } = change.unified_diff(&repo, CONTEXT_LINES)?
134+
else {
134135
unreachable!("We know there are hunks")
135136
};
136137
assert_ne!(
@@ -202,7 +203,8 @@ fn from_beginning() -> anyhow::Result<()> {
202203
.into_iter()
203204
.find(|change| change.path == filename)
204205
{
205-
let UnifiedDiff::Patch { mut hunks } = change.unified_diff(&repo, CONTEXT_LINES)? else {
206+
let UnifiedDiff::Patch { mut hunks, .. } = change.unified_diff(&repo, CONTEXT_LINES)?
207+
else {
206208
unreachable!("We know there are hunks")
207209
};
208210
assert_ne!(
@@ -870,7 +872,7 @@ mod util {
870872
.find(|change| change.path == filename)
871873
.expect("well-known fixture");
872874

873-
let UnifiedDiff::Patch { hunks } = change.unified_diff(repo, context_lines)? else {
875+
let UnifiedDiff::Patch { hunks, .. } = change.unified_diff(repo, context_lines)? else {
874876
unreachable!("We know there are hunks")
875877
};
876878
Ok((change, hunks))

crates/but-workspace/tests/workspace/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub fn to_change_specs_all_hunks_with_context_lines(
115115
},
116116
_ => {
117117
match change.unified_diff(repo, context_lines) {
118-
Ok(but_core::UnifiedDiff::Patch { hunks }) => DiffSpec {
118+
Ok(but_core::UnifiedDiff::Patch { hunks, .. }) => DiffSpec {
119119
previous_path: change.previous_path().map(ToOwned::to_owned),
120120
path: change.path,
121121
hunk_headers: hunks.into_iter().map(Into::into).collect(),

0 commit comments

Comments
 (0)