gitea
gitea copied to clipboard
PR merge commit fails with large message
Description
When merging PR 500 error is returned and log contains entries:
apr 04 12:52:03 git1 gitea[3331652]: 2024/04/04 12:52:03 ...pull/merge_squash.go:79:doMergeStyleSquash() [E] git commit <PullRequest [45982]lx/demo#224[develop...renovate/node-20.x]>: fork/exec /usr/bin/git: argument list too long
apr 04 12:52:03 git1 gitea[3331652]: 2024/04/04 12:52:03 ...ers/web/repo/pull.go:1302:MergePullRequest() [E] Merge: git commit [lx/demo:renovate/node-20.x -> lx/demo:develop]: fork/exec /usr/bin/git: argument list too long
Should check limit in route handler and return valid error + limit max size in UI
Gitea Version
1.21.10
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
2.25.1
Operating System
Ubuntu 22.04
How are you running Gitea?
Binary
Database
PostgreSQL
What kind of arguments are passed here? ARG_MAX is 2097152 on a typical linux system, I think we are doing something wrong if we pass such long arguments to git.
It seems another issue has reported this issue.
It's #28584
Some command line tools have options to circumvent argument length limit, like passing args via stdin or a file. Maybe git has something like that too.
I guess one solution is to use the -r option of git ls-tree and only provide the top-level directories and files as arguments. Won't work in a repo with a million files in root, but I guess no one does that.
git ls-tree -r HEAD web_src
Imho we should just limit commit message length (warn/trim?)