Skip to content

Commit

Permalink
Merge branch 'main' into davidkna-envopen
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 28, 2022
2 parents 7b307f5 + 6106521 commit bc0abc6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
16 changes: 14 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion git-attributes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bstr = { version = "0.2.13", default-features = false, features = ["std"]}
unicode-bom = "1.1.4"
quick-error = "2.0.0"
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
compact_str = "0.3.2"
compact_str = "0.4"

[dev-dependencies]
git-testtools = { path = "../tests/tools"}
6 changes: 3 additions & 3 deletions git-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::path::PathBuf;

use bstr::{BStr, BString};
use compact_str::CompactStr;
use compact_str::CompactString;
pub use git_glob as glob;

/// The state an attribute can be in, referencing the value.
Expand Down Expand Up @@ -37,7 +37,7 @@ pub enum State {
Unset,
/// The attribute is set to the given value, which followed the `=` sign.
/// Note that values can be empty.
Value(compact_str::CompactStr),
Value(CompactString),
/// The attribute isn't mentioned with a given path or is explicitly set to `Unspecified` using the `!` sign.
Unspecified,
}
Expand All @@ -47,7 +47,7 @@ pub enum State {
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Assignment {
/// The name of the attribute.
pub name: CompactStr,
pub name: CompactString,
/// The state of the attribute.
pub state: State,
}
Expand Down
2 changes: 1 addition & 1 deletion git-discover/src/upwards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub(crate) mod function {
match filter_by_trust(&cursor)? {
Some(trust) => {
// TODO: test this more, it definitely doesn't find the shortest path to a directory
let path = if dir_made_absolute {
let path = if dir_made_absolute && !directory.as_ref().is_absolute() {
shorten_path_with_cwd(cursor, cwd)
} else {
cursor
Expand Down
15 changes: 15 additions & 0 deletions git-discover/tests/upwards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,21 @@ fn cross_fs() -> crate::Result {
Ok(())
}

#[test]
fn do_not_shorten_absolute_paths() -> crate::Result {
let top_level_repo = repo_path()?.canonicalize().expect("repo path exists");
let (repo_path, _trust) = git_discover::upwards(top_level_repo).expect("we can discover the repo");

match repo_path {
git_discover::repository::Path::WorkTree(work_dir) => {
assert!(work_dir.is_absolute());
}
_ => panic!("expected worktree path"),
};

Ok(())
}

fn repo_path() -> crate::Result<PathBuf> {
git_testtools::scripted_fixture_repo_read_only("make_basic_repo.sh")
}

0 comments on commit bc0abc6

Please sign in to comment.