Repository navigation
Optimizations to git integration - #134
Conversation
📝 WalkthroughWalkthroughRefactors git integration by introducing normalized path comparison, per-root repository path indexing for faster resolution, replacing status porcelain queries with diff-based unmerged detection, and implementing batch-based git-cat-file operations for three-way merge version retrieval with fallback mechanisms. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~55 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/gitIntegration.ts (1)
759-971: Batchcat-file --batchreader is well implemented, with one small consistency nit.The streaming parser correctly handles the git batch protocol (header parsing, content+trailing-LF extraction,
missingresponses) and the byte-level buffer queue avoids unnecessary copies. ThecanUseBatchStageReadguard for newline-containing paths and the fallback to per-stage reads is a nice resilience pattern.Minor nit: Line 963 uses
stdin.on('error', ...)while all other event handlers (stdout.on('data'),gitShow.once(...)) use.once()for lifecycle events. Consider usingstdin.once('error', ...)for consistency—although functionally harmless sincerejectis a no-op after the first call.Consistency fix
- stdin.on('error', (error) => { + stdin.once('error', (error) => { reject(error); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/gitIntegration.ts` around lines 759 - 971, In readGitShowFromStages, make the error handler on the git child stdin consistent with the other one-time handlers by replacing stdin.on('error', ...) with stdin.once('error', ...) so the error callback is registered exactly once (match the style used for gitShow.once and keep rejection behavior unchanged).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/gitIntegration.ts`:
- Around line 1024-1041: In queryUnmergedFilesForRoot, do not hardcode status:
'UU' for entries coming from streamGitUnmergedPaths; instead inspect the index
stages via git ls-files -u (or parse its output) to determine the actual
conflict type per repoPath and set status accordingly (e.g., UU, AU, DU, etc.),
while keeping isUnmerged: true; if you intentionally want a simplified marker,
update the inline comment near status in queryUnmergedFilesForRoot to state that
the status is a simplified placeholder and not the real index-stage-derived
conflict type so downstream consumers are aware.
---
Nitpick comments:
In `@src/gitIntegration.ts`:
- Around line 759-971: In readGitShowFromStages, make the error handler on the
git child stdin consistent with the other one-time handlers by replacing
stdin.on('error', ...) with stdin.once('error', ...) so the error callback is
registered exactly once (match the style used for gitShow.once and keep
rejection behavior unchanged).
Summary by CodeRabbit
Performance
Bug Fixes