alpha
Login
or
Join now
4uffin.bsky.social
/
core
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
My own copy of Tangled :)
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
knotserver: git: support format-patch
author
Anirudh Oppiliappan
committer
Akshay
date
1 year ago
(Apr 21, 2025, 8:06 AM +0100)
commit
c8b4100f
c8b4100fd6b3a783614454b75fa8cf1c8fb80895
parent
b229a0ea
b229a0eadfd6a0c4a847ba6fb894cea462ceaa39
+17
-1
1 changed file
Expand all
Collapse all
Unified
Split
knotserver
git
merge.go
+17
-1
knotserver/git/merge.go
Reviewed
···
10
10
11
11
"github.com/go-git/go-git/v5"
12
12
"github.com/go-git/go-git/v5/plumbing"
13
13
+
"tangled.sh/tangled.sh/core/patchutil"
13
14
)
14
15
15
16
type ErrMerge struct {
···
85
86
func (g *GitRepo) applyPatch(tmpDir, patchFile string, checkOnly bool, opts *MergeOptions) error {
86
87
var stderr bytes.Buffer
87
88
var cmd *exec.Cmd
89
89
+
var formatPatch = false
90
90
+
91
91
+
if patchutil.IsFormatPatch(patchFile) {
92
92
+
formatPatch = true
93
93
+
}
88
94
89
95
if checkOnly {
90
96
cmd = exec.Command("git", "-C", tmpDir, "apply", "--check", "-v", patchFile)
91
97
} else {
92
92
-
exec.Command("git", "-C", tmpDir, "config", "advice.mergeConflict", "false").Run()
98
98
+
// if patch is a format-patch, apply using 'git am'
99
99
+
if formatPatch {
100
100
+
amCmd := exec.Command("git", "-C", tmpDir, "am", patchFile)
101
101
+
amCmd.Stderr = &stderr
102
102
+
if err := amCmd.Run(); err != nil {
103
103
+
return fmt.Errorf("patch application failed: %s", stderr.String())
104
104
+
}
105
105
+
return nil
106
106
+
}
93
107
108
108
+
// else, apply using 'git apply' and commit it manually
109
109
+
exec.Command("git", "-C", tmpDir, "config", "advice.mergeConflict", "false").Run()
94
110
if opts != nil {
95
111
applyCmd := exec.Command("git", "-C", tmpDir, "apply", patchFile)
96
112
applyCmd.Stderr = &stderr