Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various improvements #1768

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .github/workflows/cifuzz.yml

This file was deleted.

2 changes: 1 addition & 1 deletion gitoxide-core/src/repository/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn change_to_char(change: &Change<(), gix::submodule::Status>) -> u8 {
// Known status letters: https://github.com/git/git/blob/6807fcfedab84bc8cd0fbf721bc13c4e68cda9ae/diff.h#L613
match change {
Change::Removed => b'D',
Change::Type => b'T',
Change::Type { .. } => b'T',
Change::SubmoduleModification(_) => b'M',
Change::Modification {
executable_bit_changed, ..
Expand Down
2 changes: 1 addition & 1 deletion gix-index/src/entry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use bitflags::bitflags;

bitflags! {
/// The kind of file of an entry.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd)]
pub struct Mode: u32 {
/// directory (only used for sparse checkouts), equivalent to a tree, which is _excluded_ from the index via
/// cone-mode.
Expand Down
4 changes: 2 additions & 2 deletions gix-index/src/entry/mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ impl Mode {
/// If there is a type change then we will use whatever information is
/// present on the FS. Specifically if `has_symlinks` is false we will
/// never generate `Change::TypeChange { new_mode: Mode::SYMLINK }`. and
/// iff `executable_bit` is false we will never generate `Change::TypeChange
/// if `executable_bit` is false we will never generate `Change::TypeChange
/// { new_mode: Mode::FILE_EXECUTABLE }` (all files are assumed to be not
/// executable). That measn that unstaging and staging files can be a lossy
/// executable). That means that unstaging and staging files can be a lossy
/// operation on such file systems.
///
/// If a directory replaced a normal file/symlink we assume that the
Expand Down
9 changes: 8 additions & 1 deletion gix-status/src/index_as_worktree/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,14 @@ impl<'index> State<'_, 'index> {
.mode
.change_to_match_fs(&metadata, self.options.fs.symlink, self.options.fs.executable_bit)
{
Some(gix_index::entry::mode::Change::Type { .. }) => return Ok(Some(Change::Type.into())),
Some(gix_index::entry::mode::Change::Type { new_mode }) => {
return Ok(Some(
Change::Type {
worktree_mode: new_mode,
}
.into(),
))
}
Some(gix_index::entry::mode::Change::ExecutableBit) => true,
None => false,
};
Expand Down
6 changes: 5 additions & 1 deletion gix-status/src/index_as_worktree/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ pub enum Change<T = (), U = ()> {
///
/// A change to a non-file is marked as `modification` in Git, but that's related to the content which we can't evaluate.
/// Hence, a type-change is considered more appropriate.
Type,
Type {
/// The mode the worktree file would have if it was added to the index, and the mode that differs compared
/// to what's currently stored in the index.
worktree_mode: gix_index::entry::Mode,
},
/// This worktree file was modified in some form, like a permission change or content change or both,
/// as compared to this entry.
Modification {
Expand Down
2 changes: 1 addition & 1 deletion gix-status/src/index_as_worktree_with_renames/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ pub(super) mod function {
}
EntryStatus::Change(c) => match c {
Change::Removed => ChangeKind::Deletion,
Change::Type | Change::Modification { .. } | Change::SubmoduleModification(_) => {
Change::Type { .. } | Change::Modification { .. } | Change::SubmoduleModification(_) => {
ChangeKind::Modification
}
},
Expand Down
2 changes: 1 addition & 1 deletion gix-status/src/index_as_worktree_with_renames/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl<ContentChange, SubmoduleStatus> Entry<'_, ContentChange, SubmoduleStatus> {
..
} => match change {
Change::SubmoduleModification(_) | Change::Modification { .. } => Summary::Modified,
Change::Type => Summary::TypeChange,
Change::Type { .. } => Summary::TypeChange,
Change::Removed => Summary::Removed,
},
Entry::DirectoryContents { entry, .. } => {
Expand Down
64 changes: 56 additions & 8 deletions gix-status/tests/status/index_as_worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bstr::BStr;
use filetime::{set_file_mtime, FileTime};
use gix_filter::eol::AutoCrlf;
use gix_index as index;
use gix_index::Entry;
use gix_index::{entry, Entry};
use gix_status::index_as_worktree::Context;
use gix_status::{
index_as_worktree,
Expand Down Expand Up @@ -231,7 +231,7 @@ fn deracify_status(status: EntryStatus) -> Option<EntryStatus> {
EntryStatus::Conflict(c) => EntryStatus::Conflict(c),
EntryStatus::Change(c) => match c {
Change::Removed => Change::Removed,
Change::Type => Change::Type,
Change::Type { worktree_mode } => Change::Type { worktree_mode },
Change::Modification {
executable_bit_changed,
content_change,
Expand Down Expand Up @@ -284,7 +284,17 @@ fn nonfile_untracked_are_not_visible() {
#[test]
#[cfg(unix)]
fn tracked_changed_to_non_file() {
nonfile_fixture("tracked-swapped", &[(BStr::new(b"file"), 0, Change::Type.into())]);
nonfile_fixture(
"tracked-swapped",
&[(
BStr::new(b"file"),
0,
Change::Type {
worktree_mode: entry::Mode::FILE,
}
.into(),
)],
);
}

#[test]
Expand Down Expand Up @@ -384,7 +394,17 @@ fn subomdule_deleted_dir() {
#[test]
fn subomdule_typechange() {
assert_eq!(
submodule_fixture("type-change", &[(BStr::new(b"m1"), 1, Change::Type.into())]),
submodule_fixture(
"type-change",
&[(
BStr::new(b"m1"),
1,
Change::Type {
worktree_mode: entry::Mode::FILE
}
.into()
)]
),
Outcome {
entries_to_process: 2,
entries_processed: 2,
Expand Down Expand Up @@ -596,7 +616,14 @@ fn refresh() {
}
.into(),
),
(BStr::new(b"empty"), 3, Change::Type.into()),
(
BStr::new(b"empty"),
3,
Change::Type {
worktree_mode: entry::Mode::FILE
}
.into()
),
(
BStr::new(b"executable"),
4,
Expand All @@ -620,7 +647,14 @@ fn refresh() {
}
.into(),
),
(BStr::new("empty"), 3, Change::Type.into()),
(
BStr::new("empty"),
3,
Change::Type {
worktree_mode: entry::Mode::FILE
}
.into()
),
(
BStr::new("executable"),
4,
Expand Down Expand Up @@ -669,7 +703,14 @@ fn modified() {
}
.into(),
),
(BStr::new(b"empty"), 3, Change::Type.into()),
(
BStr::new(b"empty"),
3,
Change::Type {
worktree_mode: entry::Mode::FILE,
}
.into(),
),
(
BStr::new(b"executable"),
4,
Expand All @@ -693,7 +734,14 @@ fn modified() {
}
.into(),
),
(BStr::new("empty"), 3, Change::Type.into()),
(
BStr::new("empty"),
3,
Change::Type {
worktree_mode: entry::Mode::FILE,
}
.into(),
),
(
BStr::new("executable"),
4,
Expand Down
8 changes: 6 additions & 2 deletions gix-status/tests/status/index_as_worktree_with_renames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::fixture_path;
use bstr::ByteSlice;
use gix_diff::blob::pipeline::WorktreeRoots;
use gix_diff::rewrites::CopySource;
use gix_index::entry;
use gix_status::index_as_worktree::traits::FastEq;
use gix_status::index_as_worktree::{Change, EntryStatus};
use gix_status::index_as_worktree_with_renames;
Expand Down Expand Up @@ -123,7 +124,10 @@ fn tracked_changed_to_non_file() {
&[],
&[Expectation::Modification {
rela_path: "file",
status: Change::Type.into(),
status: Change::Type {
worktree_mode: entry::Mode::FILE,
}
.into(),
}],
None,
Some(Default::default()),
Expand Down Expand Up @@ -393,7 +397,7 @@ impl Expectation<'_> {
EntryStatus::Conflict(_) => Summary::Conflict,
EntryStatus::Change(change) => match change {
Change::Removed => Summary::Removed,
Change::Type => Summary::TypeChange,
Change::Type { .. } => Summary::TypeChange,
Change::Modification { .. } | Change::SubmoduleModification(_) => Summary::Modified,
},
EntryStatus::NeedsUpdate(_) => return None,
Expand Down
2 changes: 1 addition & 1 deletion gix/src/status/index_worktree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ pub mod iter {
EntryStatus::Conflict(_) => Conflict,
EntryStatus::Change(change) => match change {
Change::Removed => Removed,
Change::Type => TypeChange,
Change::Type { .. } => TypeChange,
Change::Modification { .. } | Change::SubmoduleModification(_) => Modified,
},
EntryStatus::NeedsUpdate(_) => return None,
Expand Down
Loading