Skip to content

Commit 34fa6bb

Browse files
authored
Merge pull request #1768 from GitoxideLabs/improvements
various improvements
2 parents e4fb21e + a661a8a commit 34fa6bb

File tree

11 files changed

+82
-65
lines changed

11 files changed

+82
-65
lines changed

.github/workflows/cifuzz.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

gitoxide-core/src/repository/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn change_to_char(change: &Change<(), gix::submodule::Status>) -> u8 {
249249
// Known status letters: https://github.com/git/git/blob/6807fcfedab84bc8cd0fbf721bc13c4e68cda9ae/diff.h#L613
250250
match change {
251251
Change::Removed => b'D',
252-
Change::Type => b'T',
252+
Change::Type { .. } => b'T',
253253
Change::SubmoduleModification(_) => b'M',
254254
Change::Modification {
255255
executable_bit_changed, ..

gix-index/src/entry/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use bitflags::bitflags;
3434

3535
bitflags! {
3636
/// The kind of file of an entry.
37-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
37+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd)]
3838
pub struct Mode: u32 {
3939
/// directory (only used for sparse checkouts), equivalent to a tree, which is _excluded_ from the index via
4040
/// cone-mode.

gix-index/src/entry/mode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ impl Mode {
2828
/// If there is a type change then we will use whatever information is
2929
/// present on the FS. Specifically if `has_symlinks` is false we will
3030
/// never generate `Change::TypeChange { new_mode: Mode::SYMLINK }`. and
31-
/// iff `executable_bit` is false we will never generate `Change::TypeChange
31+
/// if `executable_bit` is false we will never generate `Change::TypeChange
3232
/// { new_mode: Mode::FILE_EXECUTABLE }` (all files are assumed to be not
33-
/// executable). That measn that unstaging and staging files can be a lossy
33+
/// executable). That means that unstaging and staging files can be a lossy
3434
/// operation on such file systems.
3535
///
3636
/// If a directory replaced a normal file/symlink we assume that the

gix-status/src/index_as_worktree/function.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,14 @@ impl<'index> State<'_, 'index> {
397397
.mode
398398
.change_to_match_fs(&metadata, self.options.fs.symlink, self.options.fs.executable_bit)
399399
{
400-
Some(gix_index::entry::mode::Change::Type { .. }) => return Ok(Some(Change::Type.into())),
400+
Some(gix_index::entry::mode::Change::Type { new_mode }) => {
401+
return Ok(Some(
402+
Change::Type {
403+
worktree_mode: new_mode,
404+
}
405+
.into(),
406+
))
407+
}
401408
Some(gix_index::entry::mode::Change::ExecutableBit) => true,
402409
None => false,
403410
};

gix-status/src/index_as_worktree/types.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ pub enum Change<T = (), U = ()> {
111111
///
112112
/// A change to a non-file is marked as `modification` in Git, but that's related to the content which we can't evaluate.
113113
/// Hence, a type-change is considered more appropriate.
114-
Type,
114+
Type {
115+
/// The mode the worktree file would have if it was added to the index, and the mode that differs compared
116+
/// to what's currently stored in the index.
117+
worktree_mode: gix_index::entry::Mode,
118+
},
115119
/// This worktree file was modified in some form, like a permission change or content change or both,
116120
/// as compared to this entry.
117121
Modification {

gix-status/src/index_as_worktree_with_renames/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ pub(super) mod function {
455455
}
456456
EntryStatus::Change(c) => match c {
457457
Change::Removed => ChangeKind::Deletion,
458-
Change::Type | Change::Modification { .. } | Change::SubmoduleModification(_) => {
458+
Change::Type { .. } | Change::Modification { .. } | Change::SubmoduleModification(_) => {
459459
ChangeKind::Modification
460460
}
461461
},

gix-status/src/index_as_worktree_with_renames/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<ContentChange, SubmoduleStatus> Entry<'_, ContentChange, SubmoduleStatus> {
230230
..
231231
} => match change {
232232
Change::SubmoduleModification(_) | Change::Modification { .. } => Summary::Modified,
233-
Change::Type => Summary::TypeChange,
233+
Change::Type { .. } => Summary::TypeChange,
234234
Change::Removed => Summary::Removed,
235235
},
236236
Entry::DirectoryContents { entry, .. } => {

gix-status/tests/status/index_as_worktree.rs

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bstr::BStr;
77
use filetime::{set_file_mtime, FileTime};
88
use gix_filter::eol::AutoCrlf;
99
use gix_index as index;
10-
use gix_index::Entry;
10+
use gix_index::{entry, Entry};
1111
use gix_status::index_as_worktree::Context;
1212
use gix_status::{
1313
index_as_worktree,
@@ -231,7 +231,7 @@ fn deracify_status(status: EntryStatus) -> Option<EntryStatus> {
231231
EntryStatus::Conflict(c) => EntryStatus::Conflict(c),
232232
EntryStatus::Change(c) => match c {
233233
Change::Removed => Change::Removed,
234-
Change::Type => Change::Type,
234+
Change::Type { worktree_mode } => Change::Type { worktree_mode },
235235
Change::Modification {
236236
executable_bit_changed,
237237
content_change,
@@ -284,7 +284,17 @@ fn nonfile_untracked_are_not_visible() {
284284
#[test]
285285
#[cfg(unix)]
286286
fn tracked_changed_to_non_file() {
287-
nonfile_fixture("tracked-swapped", &[(BStr::new(b"file"), 0, Change::Type.into())]);
287+
nonfile_fixture(
288+
"tracked-swapped",
289+
&[(
290+
BStr::new(b"file"),
291+
0,
292+
Change::Type {
293+
worktree_mode: entry::Mode::FILE,
294+
}
295+
.into(),
296+
)],
297+
);
288298
}
289299

290300
#[test]
@@ -384,7 +394,17 @@ fn subomdule_deleted_dir() {
384394
#[test]
385395
fn subomdule_typechange() {
386396
assert_eq!(
387-
submodule_fixture("type-change", &[(BStr::new(b"m1"), 1, Change::Type.into())]),
397+
submodule_fixture(
398+
"type-change",
399+
&[(
400+
BStr::new(b"m1"),
401+
1,
402+
Change::Type {
403+
worktree_mode: entry::Mode::FILE
404+
}
405+
.into()
406+
)]
407+
),
388408
Outcome {
389409
entries_to_process: 2,
390410
entries_processed: 2,
@@ -596,7 +616,14 @@ fn refresh() {
596616
}
597617
.into(),
598618
),
599-
(BStr::new(b"empty"), 3, Change::Type.into()),
619+
(
620+
BStr::new(b"empty"),
621+
3,
622+
Change::Type {
623+
worktree_mode: entry::Mode::FILE
624+
}
625+
.into()
626+
),
600627
(
601628
BStr::new(b"executable"),
602629
4,
@@ -620,7 +647,14 @@ fn refresh() {
620647
}
621648
.into(),
622649
),
623-
(BStr::new("empty"), 3, Change::Type.into()),
650+
(
651+
BStr::new("empty"),
652+
3,
653+
Change::Type {
654+
worktree_mode: entry::Mode::FILE
655+
}
656+
.into()
657+
),
624658
(
625659
BStr::new("executable"),
626660
4,
@@ -669,7 +703,14 @@ fn modified() {
669703
}
670704
.into(),
671705
),
672-
(BStr::new(b"empty"), 3, Change::Type.into()),
706+
(
707+
BStr::new(b"empty"),
708+
3,
709+
Change::Type {
710+
worktree_mode: entry::Mode::FILE,
711+
}
712+
.into(),
713+
),
673714
(
674715
BStr::new(b"executable"),
675716
4,
@@ -693,7 +734,14 @@ fn modified() {
693734
}
694735
.into(),
695736
),
696-
(BStr::new("empty"), 3, Change::Type.into()),
737+
(
738+
BStr::new("empty"),
739+
3,
740+
Change::Type {
741+
worktree_mode: entry::Mode::FILE,
742+
}
743+
.into(),
744+
),
697745
(
698746
BStr::new("executable"),
699747
4,

gix-status/tests/status/index_as_worktree_with_renames.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::fixture_path;
22
use bstr::ByteSlice;
33
use gix_diff::blob::pipeline::WorktreeRoots;
44
use gix_diff::rewrites::CopySource;
5+
use gix_index::entry;
56
use gix_status::index_as_worktree::traits::FastEq;
67
use gix_status::index_as_worktree::{Change, EntryStatus};
78
use gix_status::index_as_worktree_with_renames;
@@ -123,7 +124,10 @@ fn tracked_changed_to_non_file() {
123124
&[],
124125
&[Expectation::Modification {
125126
rela_path: "file",
126-
status: Change::Type.into(),
127+
status: Change::Type {
128+
worktree_mode: entry::Mode::FILE,
129+
}
130+
.into(),
127131
}],
128132
None,
129133
Some(Default::default()),
@@ -393,7 +397,7 @@ impl Expectation<'_> {
393397
EntryStatus::Conflict(_) => Summary::Conflict,
394398
EntryStatus::Change(change) => match change {
395399
Change::Removed => Summary::Removed,
396-
Change::Type => Summary::TypeChange,
400+
Change::Type { .. } => Summary::TypeChange,
397401
Change::Modification { .. } | Change::SubmoduleModification(_) => Summary::Modified,
398402
},
399403
EntryStatus::NeedsUpdate(_) => return None,

gix/src/status/index_worktree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ pub mod iter {
462462
EntryStatus::Conflict(_) => Conflict,
463463
EntryStatus::Change(change) => match change {
464464
Change::Removed => Removed,
465-
Change::Type => TypeChange,
465+
Change::Type { .. } => TypeChange,
466466
Change::Modification { .. } | Change::SubmoduleModification(_) => Modified,
467467
},
468468
EntryStatus::NeedsUpdate(_) => return None,

0 commit comments

Comments
 (0)