[PR #451] fix: preserve AI attribution for files committed in batches #477

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

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

State: closed
Merged: Yes


Summary

Fixes #356 - AI attribution is lost when committing files in batches.

The bug: When AI edits multiple files and they are committed separately, files in the second (and later) commits lose their AI
attribution.

Root cause: The pathspecs passed to to_authorship_log_and_initial_working_log only included committed files from
filtered_working_log. This meant uncommitted files were completely ignored when computing INITIAL attributions.

Fix: Include ALL files from checkpoints and INITIAL attributions in pathspecs, not just the files being committed. This ensures:

  1. During the first commit, uncommitted files get proper INITIAL attributions
  2. During subsequent commits, files from previous INITIAL files are processed

The fix is a minimal change in pathspec construction in post_commit.rs:

  • Use parent_working_log (all checkpoint files) instead of filtered_working_log (only committed files)
  • Also include files from existing INITIAL attributions

Cleanup: After this fix, filtered_working_log and the filter_untracked_files function became dead code and were removed. The filtering logic is now handled internally by to_authorship_log_and_initial_working_log, which correctly splits committed changes into the authorship log and uncommitted changes into INITIAL attributions.

Test plan

  • Added two new test cases that reproduce issue #356:
    • test_multi_file_batch_commits_preserve_attribution - AI creates new files, commits separately
    • test_multi_file_batch_commits_modifications - AI modifies existing files, commits separately
  • Both tests were failing before the fix (red) and pass after (green)
  • Full cargo test --test simple_additions passes (26/26 tests)

Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/451 **State:** closed **Merged:** Yes --- ## Summary Fixes #356 - AI attribution is lost when committing files in batches. **The bug:** When AI edits multiple files and they are committed separately, files in the second (and later) commits lose their AI attribution. **Root cause:** The `pathspecs` passed to `to_authorship_log_and_initial_working_log` only included committed files from `filtered_working_log`. This meant uncommitted files were completely ignored when computing INITIAL attributions. **Fix:** Include ALL files from checkpoints and INITIAL attributions in pathspecs, not just the files being committed. This ensures: 1. During the first commit, uncommitted files get proper INITIAL attributions 2. During subsequent commits, files from previous INITIAL files are processed The fix is a minimal change in pathspec construction in `post_commit.rs`: - Use `parent_working_log` (all checkpoint files) instead of `filtered_working_log` (only committed files) - Also include files from existing INITIAL attributions **Cleanup:** After this fix, `filtered_working_log` and the `filter_untracked_files` function became dead code and were removed. The filtering logic is now handled internally by `to_authorship_log_and_initial_working_log`, which correctly splits committed changes into the authorship log and uncommitted changes into INITIAL attributions. ## Test plan - [x] Added two new test cases that reproduce issue #356: - `test_multi_file_batch_commits_preserve_attribution` - AI creates new files, commits separately - `test_multi_file_batch_commits_modifications` - AI modifies existing files, commits separately - [x] Both tests were failing before the fix (red) and pass after (green) - [x] Full `cargo test --test simple_additions` passes (26/26 tests) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/451" 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 -->
kerem 2026-03-02 04:13:44 +03:00
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#477
No description provided.