From e6606466563b4f6d69498476dfbb2d571a665d81 Mon Sep 17 00:00:00 2001 From: yogeshwaran-c Date: Thu, 26 Mar 2026 06:36:44 +0530 Subject: [PATCH] fix: respect git.requireGitUserConfig setting on commit errors When git.requireGitUserConfig is set to false, handleCommitError still checks for user.name and user.email configuration on any commit failure, showing the misleading message 'Make sure you configure your user.name and user.email in git' even though the user explicitly opted out of this requirement. Pass the requireUserConfig flag to handleCommitError and skip the user config validation when it is false, allowing the actual commit error to surface instead. Closes #194102 --- extensions/git/src/git.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 14e61bc3f8b70..c0d17f49ab683 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -2126,7 +2126,7 @@ export class Repository { try { await this.exec(args, options); } catch (commitErr) { - await this.handleCommitError(commitErr); + await this.handleCommitError(commitErr, opts.requireUserConfig ?? true); } } @@ -2145,7 +2145,7 @@ export class Repository { } - private async handleCommitError(commitErr: unknown): Promise { + private async handleCommitError(commitErr: unknown, requireUserConfig = true): Promise { if (commitErr instanceof GitError && /not possible because you have unmerged files/.test(commitErr.stderr || '')) { commitErr.gitErrorCode = GitErrorCodes.UnmergedChanges; throw commitErr; @@ -2154,18 +2154,20 @@ export class Repository { throw commitErr; } - try { - await this.exec(['config', '--get-all', 'user.name']); - } catch (err) { - err.gitErrorCode = GitErrorCodes.NoUserNameConfigured; - throw err; - } + if (requireUserConfig) { + try { + await this.exec(['config', '--get-all', 'user.name']); + } catch (err) { + err.gitErrorCode = GitErrorCodes.NoUserNameConfigured; + throw err; + } - try { - await this.exec(['config', '--get-all', 'user.email']); - } catch (err) { - err.gitErrorCode = GitErrorCodes.NoUserEmailConfigured; - throw err; + try { + await this.exec(['config', '--get-all', 'user.email']); + } catch (err) { + err.gitErrorCode = GitErrorCodes.NoUserEmailConfigured; + throw err; + } } throw commitErr;