Skip to content

fix(gitread): answer a diff with a type change - #784

Merged
ThomasK33 merged 1 commit into
mainfrom
diff-type-change
Nov 8, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
diff-type-change

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Why

A diff with a type change answers 500 on main: "diff --patch has 2 file headers, want 1". A type change is a file that becomes a symlink or a submodule, or a symlink or submodule that becomes a file (git's status T). git gives it one --raw record and one --numstat record, but --patch splits it into a deletion and an addition, two diff --git sections. mergePatches wanted one section per file. #780's root verifier found it on repos/diff and branches/diff.

What changes

  • mergePatches counts two --patch sections for a T entry, and that file's Patch holds both, its deletion then its addition. Every other file keeps its own section.
  • The gitread README says so.

Verification

  • TestDiffTypeChange (gitread): a commit turns typefile into a symlink and filetosub into a submodule, and changes keep. Both directions give three entries: two T entries with 1 addition and 1 deletion each, whose patch is the deletion (deleted file mode ...) then the addition (new file mode ...), and keep as M with its own one section. The patches apply (git apply --cached --check). On main both directions fail with "diff --patch has 5 file headers, want 3".
  • TestDiffTypeChange (api, PostgreSQL and SQLite): repos/diff by commit ids and branches/diff, to the symlink and submodule and back again, answer 200 with typefile and filetosub as T: 4 bytes (the symlink target keep, no trailing newline) and 0 bytes (a submodule), and back, 4 bytes each with a trailing newline. On main they answer 500.
  • Mutant checks (each fails a test): a file's patch starting one section late, and a type change's patch ending one section early.
  • At 6b0b4d2, with -race: build, vet (also GOOS=darwin go vet of internal/api and internal/gitread), golangci-lint (0 issues), the doc-link check and both --fingerprints-only checks pass. internal/gitread/... passes, and internal/api and cmd/openstorage pass on PostgreSQL (-tags=openstorage_viewcheck), SQLite and S3-WAL.

Size

191 changed lines: 27 of production Go, 163 of tests and 1 of docs.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

A diff with a type change (a file that becomes a symlink or a
submodule, or back) answered 500: "diff --patch has 2 file headers,
want 1". --raw and --numstat give a type change one record, and
--patch splits it into a deletion and an addition. mergePatches now
counts two sections for a T entry, and that file's patch holds both.

Found by the #780 root verifier.

Change-Id: Ic78a86450eba7f54279165c199c07090341f1df0
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
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-08T18:15:38.078269Z 6b0b4d2 Manual request
🔒 Security Review ✅ Completed 2026-11-08T18:17:40.085600Z 6b0b4d2 Manual request
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 6b0b4d2765

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: 6b0b4d2765

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ThomasK33
ThomasK33 added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 4a505d0 Nov 8, 2026
10 checks passed
@ThomasK33
ThomasK33 deleted the diff-type-change branch November 8, 2026 19:38
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.

1 participant