Skip to content

Commit 721e422

Browse files
zeripathKN4CK3R
andauthored
Correctly handle moved files in apply patch (#22118) (#22136)
Backport #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 #22083 Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
1 parent 6f323d1 commit 721e422

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: services/pull/patch.go

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

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

0 commit comments

Comments
 (0)