Skip to content

Credentials helpers such as git config credential.helper "store --file /path/to/credentials" interpreted wrongly #1136

New issue

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

Closed
aibaars opened this issue Mar 4, 2025 · 0 comments · Fixed by #1137

Comments

@aibaars
Copy link
Contributor

aibaars commented Mar 4, 2025

The implementation of CredentialsHelper::add_command of git2-rs is different from that of the git CLI.

While git2-rs checks whether a command contains a / or \ anywhere, the git CLI checks whether the command is an absolute path (roughly whether it starts with / or \)

Compare

git2-rs/src/cred.rs

Lines 302 to 303 in d1ae3b6

} else if cmd.contains("/") || cmd.contains("\\") {
self.commands.push(cmd.to_string());

with
https://github.com/git/git/blob/6a64ac7b014fa2cfa7a69af3c253bcd53a94b428/credential.c#L492-L493

This leads to rather surprise behaviour when using the store helper with a nontrivial --file argument. For example git config credential.helper "store --file /path/to/credentials" should be interpreted as git credential-store --file /path/to/credentials, but it is not .

aibaars added a commit to aibaars/git2-rs that referenced this issue Mar 5, 2025
aibaars added a commit to aibaars/git2-rs that referenced this issue Mar 10, 2025
aibaars added a commit to aibaars/git2-rs that referenced this issue Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant