[PR #365] fix: filter out non-existent commits in grep_ai_notes for shallow clones #427

Open
opened 2026-03-02 04:13:36 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/365

State: open
Merged: No


Fixes orphaned git notes issue where git-ai stats would fail or return 0 AI lines when some commits referenced in git notes don't exist locally.

This happens in:

  • Shallow clones (--depth=N)
  • Partial clones missing commits from other branches
  • Repos after force-push/rebase where old commits are gone

The fix:

  1. Use git cat-file -e to verify each commit exists before sorting
  2. Filter out non-existent commits from the list
  3. Only pass existing commits to git log --no-walk
  4. Handle edge cases (no commits exist, only one exists)

Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/365 **State:** open **Merged:** No --- Fixes orphaned git notes issue where git-ai stats would fail or return 0 AI lines when some commits referenced in git notes don't exist locally. This happens in: - Shallow clones (--depth=N) - Partial clones missing commits from other branches - Repos after force-push/rebase where old commits are gone The fix: 1. Use git cat-file -e to verify each commit exists before sorting 2. Filter out non-existent commits from the list 3. Only pass existing commits to git log --no-walk 4. Handle edge cases (no commits exist, only one exists) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/365" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#427
No description provided.