Skip to content

Commit 9748fd0

Browse files
committed
Correctly handle moved files in apply patch (go-gitea#22118)
Backport go-gitea#22118 Moved files in a patch will result in git apply returning: ``` error: {filename}: No such file or directory ``` This wasn't handled by the git apply patch code. This PR adds handling for this. Fix go-gitea#22083 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 1409b34 commit 9748fd0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

services/pull/patch.go

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ var patchErrorSuffices = []string{
5353
": patch does not apply",
5454
": already exists in working directory",
5555
"unrecognized input",
56+
": No such file or directory",
57+
": does not exist in index",
5658
}
5759

5860
// TestPatch will test whether a simple patch will apply
@@ -416,6 +418,7 @@ func checkConflicts(ctx context.Context, pr *issues_model.PullRequest, gitRepo *
416418
scanner := bufio.NewScanner(stderrReader)
417419
for scanner.Scan() {
418420
line := scanner.Text()
421+
log.Trace("PullRequest[%d].testPatch: stderr: %s", pr.ID, line)
419422
if strings.HasPrefix(line, prefix) {
420423
conflict = true
421424
filepath := strings.TrimSpace(strings.Split(line[len(prefix):], ":")[0])

0 commit comments

Comments
 (0)