Skip to content

fix: use Git for untracked file diffs - #41

Open
iandyh wants to merge 1 commit into
wong2:mainfrom
iandyh:binary
Open

fix: use Git for untracked file diffs#41
iandyh wants to merge 1 commit into
wong2:mainfrom
iandyh:binary

Conversation

@iandyh

Copy link
Copy Markdown
Contributor

Unstaged files is shown with "binary files are not tracked" so we cannot see the changes.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:86efd86918

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadsrc/git.ts
Comment on lines +167 to +168
['diff', ...DIFF_FLAGS, '--no-index', '--', '/dev/null', file],
{ encoding: 'utf-8', maxBuffer: 50 * 1024 * 1024 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Generate untracked diffs from the repository root

When diffx is launched from a subdirectory, git ls-files returns paths relative to that directory (for example, sub-new rather than sub/sub-new), and this command preserves that shortened path in the patch headers. The server later resolves the parsed path against getRepoRoot() in getFileContent, so untracked image previews return 404 or display a different root-level file, and saved comments reference the wrong repository path. Normalize these paths and run the diff from the repository root.

Useful? React with 👍 / 👎.

Comment threadsrc/git.ts
// for this use case.
const result = spawnSync(
'git',
['diff', ...DIFF_FLAGS, '--no-index', '--', '/dev/null', file],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Force Git's default prefixes on generated patches

When the user has diff.noprefix=true, this produces headers such as diff --git file file and +++ file; the server's parseFilePaths and parseBinaryFiles require a/ and b/, so binary untracked files disappear from the UI and other per-file metadata is lost. This is a regression from the handcrafted untracked patches, which always emitted those prefixes. Git documents --default-prefix as using the default a/ and b/ prefixes, so include it here to make the output independent of user configuration.

Useful? React with 👍 / 👎.

Sign up for freeto 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.

1 participant

@iandyh