git: fix config value dropped when set to empty string#304363
Open
xingsy97 wants to merge 1 commit intomicrosoft:mainfrom
Open
git: fix config value dropped when set to empty string#304363xingsy97 wants to merge 1 commit intomicrosoft:mainfrom
xingsy97 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the Git extension’s Repository.config() argument handling so that valid falsy config values (notably the empty string) are not dropped when invoking git config.
Changes:
- Update the
valuepresence check inRepository.config()to allow passing empty strings through to the git CLI.
0203852 to
921d5b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
config()method usesif (value)to decide whether to append the value argument to the git command. This drops valid falsy values like empty string, sinceif ('')is false.Example
Setting a config key to empty string to clear it:
With
if (value), the empty string is dropped and the command becomesgit config --local user.signingKey(no value argument), which reads the key instead of setting it.Fix
Change to
if (value !== undefined && value !== null)so that empty strings and other non-null values are passed through correctly.