Skip to content

Commit

Permalink
fix: binary config output parsing can now deal with quotes on windows. (
Browse files Browse the repository at this point in the history
#790)

Previously we would return paths that contained quotes.
Note that we don't properly unquote C-style strings
(which this is: https://github.com/git/git/blob/d9d677b2d8cc5f70499db04e633ba7a400f64cbf/builtin/config.c#L197)
thinking that the git-binary configuration paths are well-known and don't need the complete decoding.
If so, this is already implemented in `gix_quote::ansi_c::undo()`.
  • Loading branch information
Byron committed Mar 26, 2023
1 parent 7bd8823 commit 603776e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gix-config/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod git {
fn first_file_from_config_with_origin(source: &BStr) -> Option<&BStr> {
let file = source.strip_prefix(b"file:")?;
let end_pos = file.find_byte(b'\t')?;
file[..end_pos].as_bstr().into()
file[..end_pos].trim_with(|c| c == '"').as_bstr().into()
}

#[cfg(test)]
Expand All @@ -138,6 +138,7 @@ mod git {
let win_msys =
"file:C:/git-sdk-64/etc/gitconfig core.symlinks=false\r\nfile:C:/git-sdk-64/etc/gitconfig core.autocrlf=true";
let win_cmd = "file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain\r\nfile:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=gix-lfs clean -- %f\r\n";
let win_msys_old = "file:\"C:\\ProgramData/Git/config\" diff.astextplain.textconv=astextplain\r\nfile:\"C:\\ProgramData/Git/config\" filter.lfs.clean=git-lfs clean -- %f\r\n";
let linux = "file:/home/parallels/.gitconfig core.excludesfile=~/.gitignore\n";
let bogus = "something unexpected";
let empty = "";
Expand All @@ -148,6 +149,7 @@ mod git {
Some("/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig"),
),
(win_msys, Some("C:/git-sdk-64/etc/gitconfig")),
(win_msys_old, Some("C:\\ProgramData/Git/config")),
(win_cmd, Some("C:/Program Files/Git/etc/gitconfig")),
(linux, Some("/home/parallels/.gitconfig")),
(bogus, None),
Expand Down

0 comments on commit 603776e

Please sign in to comment.