Skip to content

Conversation

@jamietanna
Copy link
Contributor

@jamietanna jamietanna commented Jan 21, 2026

Changes

As noted in #40580, we have cases where the GIT_CONFIG environment
variables may be set by a user, and Renovate doesn't correctly merge
them into the resulting variables, although it does use the existing
GIT_CONFIG_COUNT as its starting point for new variables.

To correctly handle this, we should make sure that if there are existing
variables set, we copy them over.

If the GIT_CONFIG_COUNT is set, but some value(s) are missing, we
should make sure to log a warning and default them to the empty string.

It's likely this may break Git, but be a more reasonable error than the
current behaviour.

Context

Please select one of the below:

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository: https://github.com/JamieTanna-Mend-testing/issue-40575

As noted in #40580, we have cases where the `GIT_CONFIG` environment
variables may be set by a user, and Renovate doesn't correctly merge
them into the resulting variables, although it does use the existing
`GIT_CONFIG_COUNT` as its starting point for new variables.

To correctly handle this, we should make sure that if there are existing
variables set, we copy them over.

If the `GIT_CONFIG_COUNT` is set, but some value(s) are missing, we
should make sure to log a warning and default them to the empty string.

It's likely this may break Git, but be a more reasonable error than the
current behaviour.
Comment on lines +83 to +86
logger.once.warn(
`GIT_CONFIG_COUNT=${gitConfigCount}, but there was no value for ${envKey}. Setting it to the empty string, which may break git`,
);
newEnvironmentVariables[envKey] = '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd probably say that this could be an error, and/or stop processing Renovate (we could check it earlier in the Renovate process) - I think it isn't the best to try and "massage" environment here, if it's incorrectly set

Copy link
Member

Choose a reason for hiding this comment

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

this should be done somewhere at line 42, where we parse the existing count.

your fix can still error if both env have the count set.

@szpak
Copy link
Contributor

szpak commented Jan 27, 2026

It's still in a draft mode. What is needed to make it "non-draft"? It would be good to release it before Renovate 43.

@jamietanna
Copy link
Contributor Author

Sorry, won't make it in before 43!

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_CONFIG_KEY_ handling doesn't merge existing environment variables in

4 participants