Skip to content

Disable text conversion in empty-tree index diffs - #2359

Merged
Byron merged 1 commit into
mainfrom
fix-index-diff
Nov 24, 2026
Merged

Byron merged 1 commit into
mainfrom
fix-index-diff

Conversation

@Byron

@Byron Byron commented Nov 24, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Motivation

Library-owned diffs should produce raw results and patches without invoking repository-configured text conversion programs. A review of the diff entry points found that IndexFile.diff() compares against the empty tree using git diff --cached, which enables text conversion by default.

The empty-tree path now passes --no-textconv for raw and patch output, matching the existing behavior of Diffable.diff.

Validation

The four regression cases failed before the fix and now pass. They cover both empty-tree arguments and both output modes. The index, diff, and CLI safety test modules passed on each backend with 187 tests and two skips.

`IndexFile.diff()` compares the index to the empty tree through
`git diff --cached`. Git enables text conversion by default in
porcelain `git diff`, as documented in `Documentation/diff-options.adoc`.
The direct empty-tree path lacked the flag used by `Diffable.diff`.

Pass `--no-textconv` for raw and patch output so this path follows
GitPython's existing diff safety behavior.

The command-argument regression failed for both empty-tree spellings
and both output modes before the fix. The index, diff and CLI safety
suites passed with 187 tests and two skips on each backend.

Agent-Model: unknown
Copilot AI balanced review requested due to automatic review settings November 24, 2026 04:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T04:35:52.306015Z 7641ef9 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the change disabling text conversion in empty-tree index comparisons.

No open issues 🎉

What changed in this PR

This PR makes empty-tree comparisons in IndexFile.diff() disable repository-configured text conversion, matching the existing behavior of Diffable.diff.

Changes:

  • Adds --no-textconv to the empty-tree diff command for raw and patch output.
  • Adds four regression cases covering both empty-tree arguments and both output modes.
File Description
test/​test_cli_safety.py Verifies empty-tree index diffs pass --no-textconv in all four cases.
git/​index/​base.py Disables text conversion for empty-tree index comparisons.

Review effort: Balanced

@Byron
Byron merged commit f961374 into main Nov 24, 2026
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants