Skip to content

git: fix config value dropped when set to empty string#304363

Open
xingsy97 wants to merge 1 commit intomicrosoft:mainfrom
xingsy97:wt/git-fix-config-falsy
Open

git: fix config value dropped when set to empty string#304363
xingsy97 wants to merge 1 commit intomicrosoft:mainfrom
xingsy97:wt/git-fix-config-falsy

Conversation

@xingsy97
Copy link
Member

@xingsy97 xingsy97 commented Mar 24, 2026

Problem

The config() method uses if (value) to decide whether to append the value argument to the git command. This drops valid falsy values like empty string, since if ('') is false.

Example

Setting a config key to empty string to clear it:

git config --local user.signingKey ""

With if (value), the empty string is dropped and the command becomes git 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.

Copilot AI review requested due to automatic review settings March 24, 2026 05:41
@vs-code-engineering
Copy link
Contributor

vs-code-engineering bot commented Mar 24, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@lszomoru

Matched files:

  • extensions/git/src/git.ts

@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 24, 2026
@xingsy97 xingsy97 marked this pull request as draft March 24, 2026 05:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 value presence check in Repository.config() to allow passing empty strings through to the git CLI.

@xingsy97 xingsy97 force-pushed the wt/git-fix-config-falsy branch from 0203852 to 921d5b4 Compare March 24, 2026 06:04
@xingsy97 xingsy97 marked this pull request as ready for review March 24, 2026 06:31
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.

3 participants