1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

better interface for ApplyPatch function

This commit is contained in:
Jesse Duffield
2019-11-05 18:44:46 +11:00
parent db8c398fa3
commit 72fe770974
4 changed files with 16 additions and 17 deletions

View File

@ -13,7 +13,7 @@ type fileInfo struct {
diff string
}
type applyPatchFunc func(patch string, reverse bool, cached bool, extraFlags string) error
type applyPatchFunc func(patch string, flags ...string) error
// PatchManager manages the building of a patch for a commit to be applied to another commit (or the working tree, or removed from the current commit)
type PatchManager struct {
@ -177,11 +177,11 @@ func (p *PatchManager) ApplyPatches(reverse bool) error {
continue
}
applyFlags := []string{"index", "3way"}
reverseOnGenerate := false
reverseOnApply := false
if reverse {
if info.mode == WHOLE {
reverseOnApply = true
applyFlags = append(applyFlags, "reverse")
} else {
reverseOnGenerate = true
}
@ -194,7 +194,7 @@ func (p *PatchManager) ApplyPatches(reverse bool) error {
if patch == "" {
continue
}
if err = p.ApplyPatch(patch, reverseOnApply, false, "--index --3way"); err != nil {
if err = p.ApplyPatch(patch, applyFlags...); err != nil {
continue
}
break