Skip to content

fix(pull): show changed files of pull requests without merge base - #39228

Open
4RH1T3CT0R7 wants to merge 1 commit into
go-gitea:mainfrom
4RH1T3CT0R7:fix-compare-unrelated-histories
Open

fix(pull): show changed files of pull requests without merge base#39228
4RH1T3CT0R7 wants to merge 1 commit into
go-gitea:mainfrom
4RH1T3CT0R7:fix-compare-unrelated-histories

Conversation

@4RH1T3CT0R7

Copy link
Copy Markdown
Contributor

When a pull request's head and base have no merge base, GetCompareInfo leaves CompareBase empty and viewPullFiles looks up an empty commit ID, so the Files Changed tab returns 404 (400 on older releases). Such pull requests are still created through the API, or appear when a branch is rewritten after the pull request was opened.

Without a merge base, the pull request brings in the whole head tree, so the files view now diffs against the empty tree, and gitdiff accepts the empty tree SHA as a diff base instead of loading it as a commit. Only the files tab changes: the commits tab still lists no commits for such pull requests and merging them is unaffected. Covered by a new integration test that fails on main and passes with this change.

Fixes #36644

When head and base have no merge base, GetCompareInfo leaves
CompareBase empty and viewPullFiles looked up an empty commit ID,
so the files tab returned 404 (400 on older releases). Diff against
the empty tree instead, and let gitdiff accept the empty tree as a
diff base rather than loading it as a commit.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 3, 2026
@4RH1T3CT0R7

Copy link
Copy Markdown
Contributor Author

Assisted-by: Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T17:50:30.921494Z 3112efb 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.

@github-actions github-actions Bot added topic/pr Issues related to pull requests type/bug labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. topic/pr Issues related to pull requests type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gitea doesn't work with PRs that merge unrelated histories

2 participants