Skip to content

fix(notes): delete legacy three-level fanout paths before writes#1553

Open
jiangyq9 wants to merge 3 commits into
git-ai-project:mainfrom
jiangyq9:fix/notes-three-level-fanout
Open

fix(notes): delete legacy three-level fanout paths before writes#1553
jiangyq9 wants to merge 3 commits into
git-ai-project:mainfrom
jiangyq9:fix/notes-three-level-fanout

Conversation

@jiangyq9

@jiangyq9 jiangyq9 commented Jun 13, 2026

Copy link
Copy Markdown

What & why

notes_add_batch and notes_add_blob_batch rewrite notes into the canonical two-level fanout path, but the delete step only covered the flat path and the current two-level fanout path. Repositories that already contain an older three-level fanout note path can keep that stale note alongside the rewritten note.

That leaves two note entries for the same annotated object. git notes show may concatenate both note payloads, which breaks JSON deserialization and can make downstream stats treat commits as untracked.

Root cause

The note rewrite path removed:

  • <object-sha>
  • <aa>/<rest-of-object-sha>

but did not remove legacy three-level paths:

  • <aa>/<bb>/<rest-of-object-sha>

Change

  • Add a shared helper that resolves every supported storage path for a note object:
    • flat path
    • current two-level fanout path
    • legacy three-level fanout path
  • Use that helper when resolving note blob OIDs so legacy notes are still discoverable.
  • Delete all supported old note paths before writing the canonical two-level note path in both:
    • notes_add_batch
    • notes_add_blob_batch
  • Add unit coverage for the note-path expansion helper.

Testing

  • Not run in this environment.

Fixes #1517


Open in Devin Review

@CLAassistant

CLAassistant commented Jun 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

Bug: notes_add_batch fails to delete 3-level fanout paths, causing duplicate notes and stats deserialization failure

2 participants