Skip to content

prior_context, db: unify unchanged-patch diff equivalence - #885

Merged
rgushchin merged 2 commits into
mainfrom
feat/unify-patch-diff-equivalence
Nov 12, 2026
Merged

rgushchin merged 2 commits into
mainfrom
feat/unify-patch-diff-equivalence

Conversation

@rgushchin

Copy link
Copy Markdown
Member

Follow-up on #873 to unify patch-diff equivalence across all three places where Sashiko decides whether a patch changed between revisions:

  1. prior_context: strip post-diff footers and unify interdiff equality

    • Track active @@ hunk line counts in extract_normalized_diff_lines so post-diff mail signatures (-- ), mailing-list footers, and format-patch / b4 trailers (base-commit:, prerequisite-patch-id:, prerequisite-message-id:, change-id:) are stripped outside hunks without truncating deleted hunk lines that begin with - / --.
    • Recognize plain unified / Quilt diff header triples (--- / +++ / @@ -) alongside diff --git headers.
    • Delegate the unchanged test in compute_inter_version_diff to patch_diffs_equivalent so pure hunk line-number shifts report (patch diff unchanged) and modified interdiffs do not include git-version signature diffs.
  2. db: use patch_diffs_equivalent for patch lineage status

    • Load candidate patch diffs in Database::reconcile_patch_lineage only for patches whose git_patch_id appears in both versions, and derive previous_patch_status from patch_diffs_equivalent so whitespace/indentation edits sharing a git_patch_id still link via Tier 1 while reporting "modified" instead of "unchanged".
    • Dashboard lineage badges, PriorVersionContext interdiffs, and skip_unchanged_clean review reuse now share a single definition of an unchanged patch.

patch_diffs_equivalent previously kept lines after the final diff hunk
and required a git diff header, while compute_inter_version_diff still
compared raw normalized lines with hunk line ranges intact. As a result,
rebasing a patch with a new git signature version or base-commit trailer
caused patch_diffs_equivalent to report a change, and pure hunk line
offset shifts caused compute_inter_version_diff to emit a diff instead
of reporting the patch unchanged.

Track active hunk line counts during diff normalization so post-diff
mail signatures, mailing-list footers, and format-patch metadata
trailers (base-commit, prerequisite-patch-id, prerequisite-message-id,
and change-id) are stripped outside hunks without truncating deleted
lines inside hunks that begin with dashes. Recognize plain unified and
Quilt diff header triples alongside git diff headers, and delegate the
unchanged test in compute_inter_version_diff to patch_diffs_equivalent.

Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
reconcile_patch_lineage previously classified a linked patch as
unchanged solely by comparing git_patch_id. Because git patch-id ignores
whitespace, indentation fixes in a repost received an unchanged badge in
the dashboard while patch_diffs_equivalent and clean-review reuse
treated them as modified.

Load candidate patch diffs in reconcile_patch_lineage for patches whose
git_patch_id appears in both versions, and derive previous_patch_status
from patch_diffs_equivalent so lineage badges, prior-version interdiffs,
and clean-review reuse share one definition of an unchanged patch.

Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
@sashiko-bot

sashiko-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

Sashiko review

✓ No issues found across 2 commits.

Full review log on sashiko.sashiko.dev

@rgushchin
rgushchin merged commit 4a1ee5d into main Nov 12, 2026
1 check passed
@rgushchin
rgushchin deleted the feat/unify-patch-diff-equivalence branch November 12, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant