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;