mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Concatenate patches to apply them all at once
This fixes the problem that patching would stop at the first file that has a conflict. We always want to patch all files. Also, it's faster for large patches, and the code is a little bit simpler too.
This commit is contained in:
@ -245,6 +245,8 @@ func (p *PatchManager) GetFileIncLineIndices(filename string) ([]int, error) {
|
||||
}
|
||||
|
||||
func (p *PatchManager) ApplyPatches(reverse bool) error {
|
||||
patch := ""
|
||||
|
||||
applyFlags := []string{"index", "3way"}
|
||||
if reverse {
|
||||
applyFlags = append(applyFlags, "reverse")
|
||||
@ -255,16 +257,10 @@ func (p *PatchManager) ApplyPatches(reverse bool) error {
|
||||
continue
|
||||
}
|
||||
|
||||
patch := p.RenderPatchForFile(filename, true, reverse)
|
||||
if patch != "" {
|
||||
err := p.applyPatch(patch, applyFlags...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
patch += p.RenderPatchForFile(filename, true, reverse)
|
||||
}
|
||||
|
||||
return nil
|
||||
return p.applyPatch(patch, applyFlags...)
|
||||
}
|
||||
|
||||
// clears the patch
|
||||
|
Reference in New Issue
Block a user