Repository navigation
fix(core): remove invalid diff.external override - #29467
Conversation
Configuring diff.external to an empty string ("") causes Git to attempt to
execute "" as an external diff tool, which fails with "cannot spawn : No such
file or directory" (Windows) or "error: cannot run : No such file or directory"
(POSIX) whenever differences exist between trees or in the working tree.
Removes diff.external from defaultGitOverrides in ShellExecutionService and
from getSafeGitEnv in gitUtils, restoring Git's built-in diff engine, and adds
comprehensive test coverage for gitUtils.
Fixes google-gemini#28928
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where Git operations failed due to an incorrectly configured 'diff.external' environment variable. By removing this invalid override, the system now correctly executes Git commands without attempting to invoke non-existent external diff tools. The changes include updates to core service configurations and the addition of robust unit tests to prevent future regressions in Git environment isolation. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/L
|
|
/Gemini review |
There was a problem hiding this comment.
Code Review
This pull request removes the diff.external override from the default Git security configuration across ShellExecutionService and gitUtils. This change prevents Git from attempting to execute an empty string as an external diff tool, which would otherwise fail. Additionally, a comprehensive test suite has been introduced in packages/core/src/utils/gitUtils.test.ts to validate the behavior of Git utility functions, including environment sanitization and repository detection. There are no review comments, and I have no feedback to provide.
There was a problem hiding this comment.
Code Review
This pull request removes the diff.external security override from the default Git environment configuration in both ShellExecutionService and gitUtils to prevent Git from failing when attempting to execute an empty string as an external diff tool. Additionally, the PR updates the associated unit tests to reflect the reduced count of security overrides and introduces a comprehensive new test suite for gitUtils.ts. There are no review comments to address.
…s CI Use fs.realpath to resolve macOS symlinked /var paths and Windows 8.3 short filename aliases in absolute git dir assertions.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request removes the 'diff.external' security override from the default Git configuration environment variables in both shellExecutionService.ts and gitUtils.ts, updating the respective configuration counts. It also introduces a comprehensive test suite for gitUtils.ts. The review feedback suggests improving the test for filesystem errors by asserting that the existsSync spy was actually called, ensuring the error-handling path is correctly exercised.
Assert existsSyncSpy was called to ensure the error-handling path in isGitRepository and findGitRoot is exercised.
|
/Gemini review |
There was a problem hiding this comment.
Code Review
This pull request removes the diff.external override from the default Git security configurations to prevent execution failures during git diff operations, updating the environment configuration count from 8 to 7. It also introduces a new test suite for Git utilities. The reviewer feedback suggests replacing git init -b main with git init in the tests to ensure compatibility with Git versions older than 2.28.0.
…tibility Avoid -b option in git init calls within gitUtils tests to ensure compatibility with Git versions pre-2.28.0.
|
/Gemini review |
There was a problem hiding this comment.
Code Review
This pull request removes the diff.external override from the default Git environment configuration in both ShellExecutionService and gitUtils to prevent Git execution failures. It also introduces a new comprehensive test suite in gitUtils.test.ts and updates existing tests to reflect the updated configuration count. I have no feedback to provide as there are no review comments.
562f036
Summary
Removes the invalid
diff.externalconfiguration override fromShellExecutionServiceandgitUtils.getSafeGitEnv(), resolving fatalcannot spawn : No such file or directory/error: cannot run : No such file or directoryerrors when executing Git diff commands in the execution sandbox.Details
In PR #28792, environment overrides were added to isolate Git operations. Among these,
diff.externalwas mapped to an empty string ("") under the assumption that an empty value would disable external diffing (similar tocredential.helper = ""resetting helper lists).However, in Git's internal diff engine (
diff.c/run_external_diff), any non-NULL string configured fordiff.externalis treated as an executable command path. When differences are computed, Git attempts to invoke"", failing viaexecvporCreateProcesswithENOENT.Changes in this PR:
['diff.external', '']fromdefaultGitOverridesinpackages/core/src/services/shellExecutionService.ts.GIT_CONFIG_KEY_7: 'diff.external'andGIT_CONFIG_VALUE_7: ''frompackages/core/src/utils/gitUtils.ts, adjustingGIT_CONFIG_COUNTfrom8to7.packages/core/src/services/shellExecutionService.test.ts.packages/core/src/utils/gitUtils.test.tscovering safe environment variables, absence ofdiff.external, and end-to-endgit diffoperations on modified repositories and commits.Related Issues
Fixes #28928
How to Validate
npm test -w @google/gemini-cli-core -- src/utils/gitUtils.test.ts src/services/shellExecutionService.test.tsgit diffon a modified file withgetSafeGitEnv:0without external diff spawn errors.Pre-Merge Checklist