diffpatch api doesn't accept patch for multiple files #15006

Closed
opened 2025-11-02 11:27:52 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @surya-purohit on GitHub (Oct 8, 2025).

Description

The web UI which internally calls _diffpatch API works as expected and can take multiple file patches at once but the exposed API requires SHA, when we normally talk abou the patch, it is not necessary to only update one file at a time, we can do multiple as we can do in the web API.

Gitea Version

1.24.6

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

M4 Pro

How are you running Gitea?

I'm using the docker image

Database

PostgreSQL

Originally created by @surya-purohit on GitHub (Oct 8, 2025). ### Description The web UI which internally calls `_diffpatch` API works as expected and can take multiple file patches at once but the exposed API requires SHA, when we normally talk abou the patch, it is not necessary to only update one file at a time, we can do multiple as we can do in the web API. ### Gitea Version 1.24.6 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System M4 Pro ### How are you running Gitea? I'm using the docker image ### Database PostgreSQL
GiteaMirror added the type/bug label 2025-11-02 11:27:52 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Oct 8, 2025):

The API also works like web, the API document is wrong. A copy-paste error from "Add apply-patch, basic revert and cherry-pick functionality (#17902)"

It should be ApplyDiffPatchFileOptions, then no SHA is required.

As a workaround, you can just ignore the sha field, and provide "content" field, manually.

type ApplyDiffPatchFileOptions struct {
	FileOptions
	// required: true
	Content string `json:"content"`
}
Image
@wxiaoguang commented on GitHub (Oct 8, 2025): The API also works like web, the API document is wrong. A copy-paste error from "Add apply-patch, basic revert and cherry-pick functionality (#17902)" It should be `ApplyDiffPatchFileOptions`, then no SHA is required. As a workaround, you can just ignore the sha field, and provide "content" field, manually. ``` type ApplyDiffPatchFileOptions struct { FileOptions // required: true Content string `json:"content"` } ``` <details> <img width="1660" height="1406" alt="Image" src="https://github.com/user-attachments/assets/a0181a20-c6be-4d13-95ef-557c1208a2ac" /> </details>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#15006