"Error: patch does not apply" in console logs when pushing to repo (related to incorrect diffs shown in PRs that include non-branch changes?) #3168

Closed
opened 2025-11-02 05:02:35 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @microlancer on GitHub (Apr 10, 2019).

  • Gitea version (or commit ref): 1.7.5
  • Git version: 2.17.1
  • Operating system: Debian 9
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

server-test123_1 | error: public/media/js/components/profile/ProfileAvatar.js: already exists in index
server-test123_1 | error: public/media/js/components/security/UpdatePassword.js: already exists in index
server-test123_1 | error: patch failed: public/media/js/init.js:15 server-test123_1 | error: public/media/js/init.js: patch does not apply

Description

When doing a git push to the repo, I am getting the errors above. The push succeeds and the client doesn't get any errors. The repo also looks fine and receives the changes as expected. But, some of my PRs don't look correct. They are reporting changes in the diff for files that were changed on an unrelated branch to the PR (in my case, master changes that were pulled into the development branch). Like in the files above, they are appearing in the PR's diff as if they were added on the development branch, when in fact, they were added on master.

I can't say if conclusively the two are related. Hopefully someone can dig into it and let me know.

Originally created by @microlancer on GitHub (Apr 10, 2019). - Gitea version (or commit ref): 1.7.5 - Git version: 2.17.1 - Operating system: Debian 9 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - [ ] Not relevant - Log gist: server-test123_1 | error: public/media/js/components/profile/ProfileAvatar.js: already exists in index server-test123_1 | error: public/media/js/components/security/UpdatePassword.js: already exists in index server-test123_1 | error: patch failed: public/media/js/init.js:15 server-test123_1 | error: public/media/js/init.js: patch does not apply ## Description When doing a git push to the repo, I am getting the errors above. The push succeeds and the client doesn't get any errors. The repo also looks fine and receives the changes as expected. But, some of my PRs don't look correct. They are reporting changes in the diff for files that were changed on an unrelated branch to the PR (in my case, master changes that were pulled into the development branch). Like in the files above, they are appearing in the PR's diff as if they were added on the development branch, when in fact, they were added on master. I can't say if conclusively the two are related. Hopefully someone can dig into it and let me know.
Author
Owner

@lunny commented on GitHub (Apr 11, 2019):

Did you set any githook?

@lunny commented on GitHub (Apr 11, 2019): Did you set any githook?
Author
Owner

@microlancer commented on GitHub (Apr 11, 2019):

Nope. I think I may have found something related and that is the branch for the PR accidentally has master pulled into the branch rather than merged into the branch. I think that is causing some problems but I'm not enough of a git expert to understand.

@microlancer commented on GitHub (Apr 11, 2019): Nope. I think I may have found something related and that is the branch for the PR accidentally has master pulled into the branch rather than merged into the branch. I think that is causing some problems but I'm not enough of a git expert to understand.
Author
Owner

@zeripath commented on GitHub (Apr 12, 2019):

Ok so take a look at https://git-scm.com/docs/git-merge-base

Consider if you get multiple results for git merge-base --all or whether you agree where the suggested merge-base is where it should be.

You may need to rebase, squash and force push to fix your history and remove the weird topology. Another option, which may be valid if you were only going to squash anyway is to break out a patch strategically using git diff and push that/those on a new branch.

@zeripath commented on GitHub (Apr 12, 2019): Ok so take a look at https://git-scm.com/docs/git-merge-base Consider if you get multiple results for `git merge-base --all` or whether you agree where the suggested merge-base is where it should be. You may need to rebase, squash and force push to fix your history and remove the weird topology. Another option, which may be valid if you were only going to squash anyway is to break out a patch strategically using git diff and push that/those on a new branch.
Author
Owner

@microlancer commented on GitHub (Apr 12, 2019):

Thanks you can close this for now for me.

@microlancer commented on GitHub (Apr 12, 2019): Thanks you can close this for now for me.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3168