From de6ce24d8d176af3729e7d3dfef1c71c7d2f2932 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 3 May 2025 10:55:16 +0100 Subject: [PATCH] patchutil: handle nil-able combined patches this was a known issue, but just ignored until now. when a patch reverts all changes from an older patch, the combined patch for that file is nil. --- patchutil/combinediff.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/patchutil/combinediff.go b/patchutil/combinediff.go index 091ec88c..5637d7cd 100644 --- a/patchutil/combinediff.go +++ b/patchutil/combinediff.go @@ -122,7 +122,11 @@ func combineTwo(patch1, patch2 []*gitdiff.File) []*gitdiff.File { fmt.Println(err) } - result = append(result, combined) + // combined can be nil commit 2 reverted all changes from commit 1 + if combined != nil { + result = append(result, combined) + } + } else { // only in patch1; add as-is result = append(result, f1) -- 2.51.2