-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix git apply error during applying custom patch #4521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Man page of `git apply` says that: --unidiff-zero By default, git apply expects that the patch being applied is a unified diff with at least one line of context. This provides good safety measures, but breaks down when applying a diff generated with --unified=0. To bypass these checks use --unidiff-zero. Note, for the reasons stated above, the usage of context-free patches is discouraged. Lazygit always render custom patch with zero context, so this --unidiff-zero option is needed when pass such patch to `git apply`. Check https://github.com/black-desk/lazygit-bug-report-2025-04-29 for details.
This is not true; it only does this if you set your diff context size to 0 (by pressing I don't think we should use the |
Oh, but I do not remember I have done this before. Is it defaults to zero?
|
No, that would be very weird. It defaults to 3. It is stored in state.yml, so if you do set it to 0, this gets remembered across restarts of lazygit. |
I think might we should make sure it to be at least 1, as 0 is discouraged by git and will somehow make git apply do not work. Or at least print something useful in log? I have been troubled by this issue for months. |
It used to be limited to at least 1, but we changed it deliberately to allow 0 as well (in version 0.45, see #4050) because some people wanted this.
Not in the log, but show an error panel; that's what I suggested above. Here's a PR that does this: #4522 |
Thanks. |
Man page of
git apply
says that:Lazygit always render custom patch with zero context,
so this --unidiff-zero option is needed when pass such patch to
git apply
.Check https://github.com/black-desk/lazygit-bug-report-2025-04-29
for details.
go generate ./...
)