Skip to content

fix(diff): preserve non-ASCII paths#365

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
dailingtao:fix/non-ascii-diff-paths
Jul 15, 2026
Merged

fix(diff): preserve non-ASCII paths#365
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
dailingtao:fix/non-ascii-diff-paths

Conversation

@dailingtao

@dailingtao dailingtao commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

Git quotes non-ASCII path bytes by default when core.quotepath is enabled. The diff parser then receives escaped, quoted paths instead of the literal repository paths, so the generated diff may not be parsed and the file cannot be read back at the selected ref.

This change:

  • passes -c core.quotepath=false to the range, commit, and workspace diff-generation commands, matching the existing file-read behavior;
  • applies the same configuration when listing untracked files;
  • adds regression tests with paths containing non-ASCII characters and a Next.js-style route group;
  • verifies workspace (tracked and untracked), single-commit, and range review modes.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • go test -race -count=1 ./internal/diff
  • go vet ./...
  • make build
  • make coverage (82.3% total; 91.9% for internal/diff)
  • git diff --check upstream/main...HEAD
  • make test passes locally (Git 2.49.0)
  • Manual testing (describe below)

The regression tests create real temporary Git repositories with core.quotepath=true, covering both tracked and untracked non-ASCII paths. They fail before the corresponding fix and pass after it.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • Documentation is not required for this internal bug fix
  • I have signed the CLA

Related Issues

Closes #361

Disable Git path quoting when generating diffs so parsed paths can be read back correctly. Add regression coverage for workspace, commit, and range modes.
@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 1 issue(s) in this PR.

  • ✅ Successfully posted inline: 1 comment(s)

Comment thread internal/diff/git.go
Disable Git path quoting when listing untracked files and add regression coverage for non-ASCII workspace paths.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 0ec3769 into alibaba:main Jul 15, 2026
2 checks passed
chethanuk added a commit to chethanuk/open-code-review that referenced this pull request Jul 15, 2026
Cosmetic consistency per alibaba#374, discovered in alibaba#365 review. Reorders the two
runGit calls so all option flags precede positional args, matching the file's
other diff call sites (GetDiff ranges/commit, computeMergeBase). The HEAD call
now places --end-of-options before the HEAD ref, hardening against
ref-looking filenames; --staged stays with the option flags (it is a flag,
not a ref, so no --end-of-options). Pure reordering plus one
--end-of-options addition; no flag or value changed. All diff tests pass.
chethanuk added a commit to chethanuk/open-code-review that referenced this pull request Jul 15, 2026
Cosmetic consistency per alibaba#374, discovered in alibaba#365 review. Reorders the two
runGit calls so all option flags precede positional args, matching the file's
other diff call sites (GetDiff ranges/commit, computeMergeBase). The HEAD call
now places --end-of-options before the HEAD ref, hardening against
ref-looking filenames; --staged stays with the option flags (it is a flag,
not a ref, so no --end-of-options). Pure reordering plus one
--end-of-options addition; no flag or value changed. All diff tests pass.
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.

File path parentheses escaping issue

3 participants