Skip to content

Commit 5e9b2fc

Browse files
fix(scripts): use patch --forward to skip already-applied hunks
XanMod already incorporates the zen patches, so applying them again produces "already applied" hunks. patch --merge treated these as conflicts and left markers in the tree. Switch to patch --forward which exits 0 for already-applied hunks; only fail on genuine rejects (.rej files).
1 parent db99e2e commit 5e9b2fc

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

scripts/apply-patches.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,18 @@ apply_series() {
6565
continue
6666
fi
6767

68-
# Try to apply; on failure, attempt 3-way merge before aborting
69-
if ! patch -p1 --dry-run -d "${KERNEL_SRC}" < "${patch_path}" &>/dev/null; then
70-
log WARN "patch does not apply cleanly, attempting 3-way merge: ${line}"
71-
if ! patch -p1 --merge -d "${KERNEL_SRC}" < "${patch_path}"; then
72-
log ERROR "patch failed (conflict markers left in tree): ${line}"
68+
# --forward skips hunks already present in the tree (exit 0).
69+
# Only fail on genuine conflicts (exit 1 with rejects).
70+
if ! patch -p1 --forward -d "${KERNEL_SRC}" < "${patch_path}" 2>/dev/null; then
71+
# Check whether any .rej files were created (genuine conflict)
72+
if find "${KERNEL_SRC}" -name '*.rej' -newer "${patch_path}" | grep -q .; then
73+
log ERROR "patch failed with rejects: ${line}"
7374
log ERROR "Resolve conflicts in ${KERNEL_SRC}, then re-run with --no-fetch."
7475
exit 1
7576
fi
76-
else
77-
patch -p1 -d "${KERNEL_SRC}" < "${patch_path}"
77+
log WARN "patch already applied (skipped): ${line}"
78+
(( skipped++ )) || true
79+
continue
7880
fi
7981
(( applied++ )) || true
8082
done < "${series_file}"

0 commit comments

Comments
 (0)