We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Unexpected behavior happened when using get_attr_bytes. Here's a minimal example:
get_attr_bytes
in src/main.rs:
src/main.rs
use git2::{AttrCheckFlags, Repository}; use std::path::PathBuf; use std::process::Command; fn main() { let repo = Repository::open(".").unwrap(); let git2_get = |file| { repo.get_attr_bytes(file, "crypt", AttrCheckFlags::default()) .unwrap() .map(String::from_utf8_lossy) }; let file = PathBuf::from(".").join("src").join("main.rs"); let file2 = file.clone(); dbg!(&file, git2_get(&file)); let file = PathBuf::from(&file.to_str().unwrap().replace('\\', "/")); dbg!(&file, git2_get(&file)); let file = PathBuf::from(&file.to_str().unwrap().trim_start_matches("./")); dbg!(&file, git2_get(&file)); let file2 = PathBuf::from(&file2.to_str().unwrap().trim_start_matches(".\\")); dbg!(&file2, git2_get(&file2)); let cli = Command::new("git") .args(["check-attr", "crypt", "--", "./src/main.rs"]) .output() .unwrap() .stdout; dbg!(String::from_utf8_lossy(&cli)); }
in .gitattributes:
.gitattributes
src/** crypt=1
output:
[src/main.rs:13:5] &file = ".\\src\\main.rs" [src/main.rs:13:5] git2_get(&file) = None [src/main.rs:15:5] &file = "./src/main.rs" [src/main.rs:15:5] git2_get(&file) = None [src/main.rs:17:5] &file = "src/main.rs" [src/main.rs:17:5] git2_get(&file) = Some( "1", ) [src/main.rs:19:5] &file2 = "src\\main.rs" [src/main.rs:19:5] git2_get(&file2) = Some( "1", ) [src/main.rs:25:5] String::from_utf8_lossy(&cli) = "./src/main.rs: crypt: 1\n"
Seems like the starting ./ caused this inconsistency. I expect that no matter whether the starting ./ exists, the output should be the same.
./
system: Windows11 rustc: 1.79.0-nightly (ccfcd950b 2024-04-15) git2 = "0.18.3"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Unexpected behavior happened when using
get_attr_bytes
. Here's a minimal example:in
src/main.rs
:in
.gitattributes
:output:
Seems like the starting
./
caused this inconsistency. I expect that no matter whether the starting./
exists, the output should be the same.additional infomation
system: Windows11
rustc: 1.79.0-nightly (ccfcd950b 2024-04-15)
git2 = "0.18.3"
The text was updated successfully, but these errors were encountered: