-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
status.showUntrackedFiles
to config-tree and use it in status()
- Loading branch information
Showing
13 changed files
with
274 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::config; | ||
use crate::config::tree::sections::Status; | ||
use crate::config::tree::{keys, Key, Section}; | ||
|
||
impl Status { | ||
/// The `status.showUntrackedFiles` key | ||
pub const SHOW_UNTRACKED_FILES: ShowUntrackedFiles = ShowUntrackedFiles::new_with_validate( | ||
"showUntrackedFiles", | ||
&config::Tree::STATUS, | ||
validate::ShowUntrackedFiles, | ||
); | ||
} | ||
|
||
/// The `status.showUntrackedFiles` key. | ||
pub type ShowUntrackedFiles = keys::Any<validate::ShowUntrackedFiles>; | ||
|
||
mod show_untracked_files { | ||
use std::borrow::Cow; | ||
|
||
use crate::{bstr::BStr, config, config::tree::status::ShowUntrackedFiles, status}; | ||
|
||
impl ShowUntrackedFiles { | ||
pub fn try_into_show_untracked_files( | ||
&'static self, | ||
value: Cow<'_, BStr>, | ||
) -> Result<status::UntrackedFiles, config::key::GenericErrorWithValue> { | ||
use crate::bstr::ByteSlice; | ||
Ok(match value.as_ref().as_bytes() { | ||
b"no" => status::UntrackedFiles::None, | ||
b"normal" => status::UntrackedFiles::Collapsed, | ||
b"all" => status::UntrackedFiles::Files, | ||
_ => return Err(config::key::GenericErrorWithValue::from_value(self, value.into_owned())), | ||
}) | ||
} | ||
} | ||
} | ||
|
||
impl Section for Status { | ||
fn name(&self) -> &str { | ||
"status" | ||
} | ||
|
||
fn keys(&self) -> &[&dyn Key] { | ||
&[&Self::SHOW_UNTRACKED_FILES] | ||
} | ||
} | ||
|
||
mod validate { | ||
use crate::{bstr::BStr, config::tree::keys}; | ||
|
||
pub struct ShowUntrackedFiles; | ||
impl keys::Validate for ShowUntrackedFiles { | ||
fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> { | ||
super::Status::SHOW_UNTRACKED_FILES.try_into_show_untracked_files(value.into())?; | ||
Ok(()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file modified
BIN
-48 Bytes
(100%)
gix/tests/fixtures/generated-archives/make_submodules.tar.xz
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
git init -q untracked-only | ||
(cd untracked-only | ||
touch this | ||
mkdir subdir | ||
>subdir/that | ||
|
||
git add . | ||
git commit -q -m init | ||
|
||
mkdir new | ||
touch new/untracked subdir/untracked | ||
) | ||
|
Oops, something went wrong.