···
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
13
+
"tangled.sh/tangled.sh/core/patchutil"
···
func (g *GitRepo) applyPatch(tmpDir, patchFile string, checkOnly bool, opts *MergeOptions) error {
89
+
var formatPatch = false
91
+
if patchutil.IsFormatPatch(patchFile) {
cmd = exec.Command("git", "-C", tmpDir, "apply", "--check", "-v", patchFile)
92
-
exec.Command("git", "-C", tmpDir, "config", "advice.mergeConflict", "false").Run()
98
+
// if patch is a format-patch, apply using 'git am'
100
+
amCmd := exec.Command("git", "-C", tmpDir, "am", patchFile)
101
+
amCmd.Stderr = &stderr
102
+
if err := amCmd.Run(); err != nil {
103
+
return fmt.Errorf("patch application failed: %s", stderr.String())
108
+
// else, apply using 'git apply' and commit it manually
109
+
exec.Command("git", "-C", tmpDir, "config", "advice.mergeConflict", "false").Run()
applyCmd := exec.Command("git", "-C", tmpDir, "apply", patchFile)
applyCmd.Stderr = &stderr