mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-29 23:17:32 +02:00
Remove the keepOriginalHeader retry loop
The loop is pointless for two reasons: - git apply --3way has this fallback built in already. If it can't do a three-way merge, it will fall back to applying the patch normally. - However, the only situation where it does this is when it can't do a 3-way merge at all because it can't find the necessary ancestor blob. This can only happen if you transfer a patch between different repos that don't have the same blobs available; we are applying the patch to the same repo that is was just generated from, so a 3-way merge is always possible. (Now that we fixed the bug in the previous commit, that is.) But the retry loop is not only pointless, it was actually harmful, because when a 3-way patch fails with a conflict, git will put conflict markers in the patched file and then exit with a non-zero exit status. So the retry loop would try to patch the already patched file again, and this almost certainly fails, but with a cryptic error message such as "error: main.go: does not exist in index".
This commit is contained in:
parent
9cc33c479b
commit
5d692e8961
@ -255,21 +255,12 @@ func (p *PatchManager) ApplyPatches(reverse bool) error {
|
||||
continue
|
||||
}
|
||||
|
||||
var err error
|
||||
// first run we try with the original header, then without
|
||||
for _, keepOriginalHeader := range []bool{true, false} {
|
||||
patch := p.RenderPatchForFile(filename, true, false, reverse, keepOriginalHeader)
|
||||
if patch == "" {
|
||||
continue
|
||||
patch := p.RenderPatchForFile(filename, true, false, reverse, true)
|
||||
if patch != "" {
|
||||
err := p.applyPatch(patch, applyFlags...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = p.applyPatch(patch, applyFlags...); err != nil {
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user