Skip to content

Commit 5fbc50d

Browse files
authored
Merge pull request #7902 from gitbutlerapp/fix-commiting-with-one-stack
Fix commting with one stack
2 parents 5987430 + 0115d53 commit 5fbc50d

File tree

19 files changed

+148
-104
lines changed

19 files changed

+148
-104
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", rev = "cd96b6439d119c5189a8e7349d2e7e2533db41b5", 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
@@ -175,7 +175,7 @@ pub(crate) fn discard_change(
175175
change.path == path
176176
&& change.previous_path() == previous_path.as_ref().map(|p| p.as_bstr())
177177
}).with_context(|| format!("Couldn't find worktree change for file at '{path}' (previous-path: {previous_path:?}"))?;
178-
let UnifiedDiff::Patch { hunks } =
178+
let UnifiedDiff::Patch { hunks, .. } =
179179
worktree_changes.unified_diff(&repo, UI_CONTEXT_LINES)?
180180
else {
181181
bail!("No hunks available for given '{path}'")

crates/but-core/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,13 @@ pub enum UnifiedDiff {
137137
size_in_bytes: u64,
138138
},
139139
/// A patch that if applied to the previous state of the resource would yield the current state.
140+
#[serde(rename_all = "camelCase")]
140141
Patch {
141142
/// All non-overlapping hunks, including their context lines.
142143
hunks: Vec<unified_diff::DiffHunk>,
144+
/// If `true`, a binary to text filter (`textconv` in Git config) was used to obtain the `hunks` in the diff.
145+
/// This means hunk-based operations must be disabled.
146+
is_result_of_binary_to_text_conversion: bool,
143147
},
144148
}
145149

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/ui.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,15 @@ fn worktree_changes_unified_diffs_json_example() -> anyhow::Result<()> {
590590
"newLines": 1,
591591
"diff": "@@ -1,0 +1,1 @@\n+content\n"
592592
}
593-
]
593+
],
594+
"isResultOfBinaryToTextConversion": false
594595
}
595596
},
596597
{
597598
"type": "Patch",
598599
"subject": {
599-
"hunks": []
600+
"hunks": [],
601+
"isResultOfBinaryToTextConversion": false
600602
}
601603
},
602604
{
@@ -610,7 +612,8 @@ fn worktree_changes_unified_diffs_json_example() -> anyhow::Result<()> {
610612
"newLines": 1,
611613
"diff": "@@ -1,0 +1,1 @@\n+link-target\n"
612614
}
613-
]
615+
],
616+
"isResultOfBinaryToTextConversion": false
614617
}
615618
},
616619
{
@@ -624,7 +627,8 @@ fn worktree_changes_unified_diffs_json_example() -> anyhow::Result<()> {
624627
"newLines": 1,
625628
"diff": "@@ -1,0 +1,1 @@\n+content not to add to the index\n"
626629
}
627-
]
630+
],
631+
"isResultOfBinaryToTextConversion": false
628632
}
629633
},
630634
{
@@ -638,7 +642,8 @@ fn worktree_changes_unified_diffs_json_example() -> anyhow::Result<()> {
638642
"newLines": 1,
639643
"diff": "@@ -1,0 +1,1 @@\n+change-in-index\n"
640644
}
641-
]
645+
],
646+
"isResultOfBinaryToTextConversion": false
642647
}
643648
},
644649
{
@@ -652,13 +657,15 @@ fn worktree_changes_unified_diffs_json_example() -> anyhow::Result<()> {
652657
"newLines": 1,
653658
"diff": "@@ -1,0 +1,1 @@\n+change-in-worktree\n"
654659
}
655-
]
660+
],
661+
"isResultOfBinaryToTextConversion": false
656662
}
657663
},
658664
{
659665
"type": "Patch",
660666
"subject": {
661-
"hunks": []
667+
"hunks": [],
668+
"isResultOfBinaryToTextConversion": false
662669
}
663670
},
664671
{
@@ -672,19 +679,22 @@ fn worktree_changes_unified_diffs_json_example() -> anyhow::Result<()> {
672679
"newLines": 1,
673680
"diff": "@@ -1,0 +1,1 @@\n+worktree-change\n"
674681
}
675-
]
682+
],
683+
"isResultOfBinaryToTextConversion": false
676684
}
677685
},
678686
{
679687
"type": "Patch",
680688
"subject": {
681-
"hunks": []
689+
"hunks": [],
690+
"isResultOfBinaryToTextConversion": false
682691
}
683692
},
684693
{
685694
"type": "Patch",
686695
"subject": {
687-
"hunks": []
696+
"hunks": [],
697+
"isResultOfBinaryToTextConversion": false
688698
}
689699
}
690700
]

0 commit comments

Comments
 (0)