Skip to content

parse GIT_CONFIG_PARAMETERS #979

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pickx
Copy link

@pickx pickx commented Jun 15, 2025

closes #977 .

also contains a drive by refactor: a somewhat nicer way to parse Args from strings (especially in tests).
once again, if this is unnecessary, unwarranted or should just be split out to a smaller PR, that's no problem.

still a draft because of two potential issues:

  1. no unit test. do we have existing tests which actually spawn git?
  2. we don't parse the GIT_CONFIG_PARAMETERS env var (despite the title of this PR), just the value that we expect git to leave there after using git -c. I suspect that we can't assume that it's properly escaped. that said, do we even care about use cases other than setting it via git -c?

@pickx pickx force-pushed the pickx/git-config-from-var branch 2 times, most recently from fb7e660 to fb3bed8 Compare June 15, 2025 17:40
/// will also be an empty string.
/// 4. an empty string will later be interpreted as `true`,
/// but we don't do this here.
pub(crate) fn parse_git_config_parameters(env_var: OsString) -> Vec<(String, String)> {
Copy link
Author

@pickx pickx Jun 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than do this here, passing the (key, value) pairs along until they are consumed and parsed by ConfigLoader, we can read the env directly in ConfigLoader (since that reads the environment to get the repository, etc., so it is already impure).

the advantage (?) of doing this here is that we treat the -cs like the CLI args that they are.

I have no strong opinion regarding which solution is better

@pickx pickx force-pushed the pickx/git-config-from-var branch from fb3bed8 to fb7e660 Compare June 15, 2025 19:36
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 this pull request may close these issues.

git -c <name>=<value> is ignored
1 participant