From c06a57e698ee21d6c6d8a35bbb37323ceef1e143 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sun, 22 Dec 2024 00:54:39 -0500 Subject: [PATCH 1/4] doc: Clarify and expand descriptions of `NonFile`s Discussed in: https://github.com/GitoxideLabs/gitoxide/pull/1730#discussion_r1894381449 At least for now, they remain called `NonFile`s (and sometimes referred to as "non-files" in text), but more specifically defined. --- gix-dir/src/entry.rs | 8 +++++--- gix-status/src/index_as_worktree/types.rs | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gix-dir/src/entry.rs b/gix-dir/src/entry.rs index 51dd41d22e0..66a987bc1f7 100644 --- a/gix-dir/src/entry.rs +++ b/gix-dir/src/entry.rs @@ -26,11 +26,13 @@ pub enum Property { /// The kind of the entry, seated in their kinds available on disk. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] pub enum Kind { - /// Something that is not a file, like a named pipe or character device. + /// Something that is not a regular file, directory, or symbolic link. /// - /// These can only exist in the filesystem. + /// These can only exist in the filesystem, because Git repositories do not support them. + /// They do not appear as blobs in a repository, and their type is not specifiable in a tree object. + /// Examples include named pipes (FIFOs), character devices, block devices, and sockets. NonFile, - /// The entry is a blob, executable or not. + /// The entry is a blob, representing a regular file, executable or not. File, /// The entry is a symlink. Symlink, diff --git a/gix-status/src/index_as_worktree/types.rs b/gix-status/src/index_as_worktree/types.rs index 446ac8ce250..80554a77f38 100644 --- a/gix-status/src/index_as_worktree/types.rs +++ b/gix-status/src/index_as_worktree/types.rs @@ -103,7 +103,9 @@ impl Outcome { pub enum Change { /// This corresponding file does not exist in the worktree anymore. Removed, - /// The type of file changed compared to the worktree, i.e. a symlink is now a file, or a file was replaced with a named pipe. + /// The type of file changed compared to the worktree. + /// + /// Examples include when a symlink is now a regular file, or a regular file was replaced with a named pipe. /// /// ### Deviation /// From d90412bdf86c70ecb5a6d0a1fefae875b3eb836b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 22 Dec 2024 08:55:30 +0100 Subject: [PATCH 2/4] fix!: rename `entry::Kind::NonFile` to `entry::Kind::Untrackable`. --- gix-dir/src/entry.rs | 9 +++++---- gix-dir/tests/dir/walk.rs | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gix-dir/src/entry.rs b/gix-dir/src/entry.rs index 66a987bc1f7..ff0ce460c27 100644 --- a/gix-dir/src/entry.rs +++ b/gix-dir/src/entry.rs @@ -28,10 +28,11 @@ pub enum Property { pub enum Kind { /// Something that is not a regular file, directory, or symbolic link. /// - /// These can only exist in the filesystem, because Git repositories do not support them. - /// They do not appear as blobs in a repository, and their type is not specifiable in a tree object. + /// These can only exist in the filesystem, + /// because Git repositories do not support them, thus they cannot be tracked. + /// Hence, they do not appear as blobs in a repository, and their type is not specifiable in a tree object. /// Examples include named pipes (FIFOs), character devices, block devices, and sockets. - NonFile, + Untrackable, /// The entry is a blob, representing a regular file, executable or not. File, /// The entry is a symlink. @@ -163,7 +164,7 @@ impl From for Kind { } else if value.is_file() { Kind::File } else { - Kind::NonFile + Kind::Untrackable } } } diff --git a/gix-dir/tests/dir/walk.rs b/gix-dir/tests/dir/walk.rs index 10673e34f48..a7c5074cb9c 100644 --- a/gix-dir/tests/dir/walk.rs +++ b/gix-dir/tests/dir/walk.rs @@ -68,7 +68,7 @@ fn one_top_level_fifo() { assert_eq!( entries, - &[entry("top", Untracked, NonFile),], + &[entry("top", Untracked, Untrackable),], "Non-files are like normal files, but with a different state" ); } @@ -103,9 +103,9 @@ fn fifo_in_traversal() { &[ entry_nokind(".git", Pruned).with_property(DotGit).with_match(Always), entry("dir-with-file/nested-file", Untracked, File), - entry("dir/nested", Untracked, NonFile), + entry("dir/nested", Untracked, Untrackable), entry("file", Untracked, File), - entry("top", Untracked, NonFile), + entry("top", Untracked, Untrackable), ], "Non-files only differ by their disk-kind" ); From 329a734e0f5d23de2bd9af87f6da85cb6154a97c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 22 Dec 2024 08:59:37 +0100 Subject: [PATCH 3/4] adapt to changes in `gix-dir` --- gitoxide-core/src/repository/clean.rs | 4 ++-- gix-status/src/index_as_worktree_with_renames/mod.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gitoxide-core/src/repository/clean.rs b/gitoxide-core/src/repository/clean.rs index 0a05d4c0e7d..740a0d7f34f 100644 --- a/gitoxide-core/src/repository/clean.rs +++ b/gitoxide-core/src/repository/clean.rs @@ -188,7 +188,7 @@ pub(crate) mod function { } match disk_kind { - Kind::NonFile => { + Kind::Untrackable => { if debug { writeln!(err, "DBG: skipped non-file at '{}'", entry.rela_path).ok(); } @@ -265,7 +265,7 @@ pub(crate) mod function { "WOULD remove" }, suffix = match disk_kind { - Kind::NonFile => unreachable!("always skipped earlier"), + Kind::Untrackable => unreachable!("always skipped earlier"), Kind::Directory if entry.property == Some(gix::dir::entry::Property::EmptyDirectory) => { " empty" } diff --git a/gix-status/src/index_as_worktree_with_renames/mod.rs b/gix-status/src/index_as_worktree_with_renames/mod.rs index 24a220e5a90..3711151ec7f 100644 --- a/gix-status/src/index_as_worktree_with_renames/mod.rs +++ b/gix-status/src/index_as_worktree_with_renames/mod.rs @@ -388,7 +388,7 @@ pub(super) mod function { impl gix_dir::walk::Delegate for Delegate<'_, '_, T, U> { fn emit(&mut self, entry: EntryRef<'_>, collapsed_directory_status: Option) -> Action { // Status never shows untracked non-files - if entry.disk_kind != Some(gix_dir::entry::Kind::NonFile) { + if entry.disk_kind != Some(gix_dir::entry::Kind::Untrackable) { let entry = entry.to_owned(); self.tx.send(Event::DirEntry(entry, collapsed_directory_status)).ok(); } @@ -469,7 +469,7 @@ pub(super) mod function { ModificationOrDirwalkEntry::Modification(c) => c.entry.mode.to_tree_entry_mode(), ModificationOrDirwalkEntry::DirwalkEntry { entry, .. } => entry.disk_kind.map(|kind| { match kind { - Kind::NonFile => { + Kind::Untrackable => { // Trees are never tracked for rewrites, so we 'pretend'. gix_object::tree::EntryKind::Tree } @@ -507,7 +507,7 @@ pub(super) mod function { }; Ok(match kind { - Kind::NonFile => { + Kind::Untrackable => { // Go along with unreadable files, they are passed along without rename tracking. return Ok(object_hash.null()); } From 154b21f0e9beb0e5b6615f091f5f0716df6a3f7b Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sun, 22 Dec 2024 03:11:31 -0500 Subject: [PATCH 4/4] Reword "non-files" in documentation comments This goes along with changing `NonFile` to `Untrackable`. --- gitoxide-core/src/repository/clean.rs | 2 +- gix-dir/tests/dir/walk.rs | 4 ++-- gix-status/src/index_as_worktree_with_renames/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gitoxide-core/src/repository/clean.rs b/gitoxide-core/src/repository/clean.rs index 740a0d7f34f..8ccc8a90dfb 100644 --- a/gitoxide-core/src/repository/clean.rs +++ b/gitoxide-core/src/repository/clean.rs @@ -190,7 +190,7 @@ pub(crate) mod function { match disk_kind { Kind::Untrackable => { if debug { - writeln!(err, "DBG: skipped non-file at '{}'", entry.rela_path).ok(); + writeln!(err, "DBG: skipped untrackable entry at '{}'", entry.rela_path).ok(); } continue; } diff --git a/gix-dir/tests/dir/walk.rs b/gix-dir/tests/dir/walk.rs index a7c5074cb9c..a6e34b257af 100644 --- a/gix-dir/tests/dir/walk.rs +++ b/gix-dir/tests/dir/walk.rs @@ -69,7 +69,7 @@ fn one_top_level_fifo() { assert_eq!( entries, &[entry("top", Untracked, Untrackable),], - "Non-files are like normal files, but with a different state" + "Untrackable entries are like normal files, but with a different state" ); } @@ -107,7 +107,7 @@ fn fifo_in_traversal() { entry("file", Untracked, File), entry("top", Untracked, Untrackable), ], - "Non-files only differ by their disk-kind" + "Untrackable entries only differ by their disk-kind" ); } diff --git a/gix-status/src/index_as_worktree_with_renames/mod.rs b/gix-status/src/index_as_worktree_with_renames/mod.rs index 3711151ec7f..ea62d825ee6 100644 --- a/gix-status/src/index_as_worktree_with_renames/mod.rs +++ b/gix-status/src/index_as_worktree_with_renames/mod.rs @@ -387,7 +387,7 @@ pub(super) mod function { impl gix_dir::walk::Delegate for Delegate<'_, '_, T, U> { fn emit(&mut self, entry: EntryRef<'_>, collapsed_directory_status: Option) -> Action { - // Status never shows untracked non-files + // Status never shows untracked entries of untrackable type if entry.disk_kind != Some(gix_dir::entry::Kind::Untrackable) { let entry = entry.to_owned(); self.tx.send(Event::DirEntry(entry, collapsed_directory_status)).ok();