[PR #593] Harden internal git profiles against non-standard diff configs #595

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

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

State: closed
Merged: Yes


Summary

  • introduce explicit internal git execution profiles (General, PatchParse, NumstatParse, RawDiffParse) and route parse-sensitive callsites through them
  • remove implicit command-name-based diff rewriting and replace it with explicit profile application at callsites
  • harden patch parsing for +++ headers to handle no-prefix/custom-prefix/mnemonic-style paths
  • add hostile diff.* config integration coverage for simple additions, diff, stats, and status
  • add centralized-spawn guard test to prevent direct internal git spawns outside approved helpers

Hardening fixes added after review

  • profile conflict stripping now only rewrites option tokens after the git subcommand and before --, so pathspec tokens are never dropped
  • NumstatParse now strips short rename/copy variants (-M*, -C*) so --no-renames cannot be overridden later in argv
  • continue_session patch-producing git show now uses PatchParse profile for stable output under hostile diff.* config

Validation

  • cargo test --lib numstat_profile_strips_short_rename_and_copy_flags
  • cargo test --lib profile_rewrite_does_not_strip_pathspec_tokens_after_double_dash
  • cargo test --tests --no-run
  • cargo test --test simple_additions test_simple_additions_with_base_commit_and_custom_diff_config -- --nocapture
  • cargo test --test diff test_diff_parsing_is_stable_under_hostile_diff_config -- --nocapture
  • cargo test --test stats test_stats_cli_range_with_hostile_diff_config -- --nocapture
  • cargo test --test status_ignore test_status_numstat_is_stable_under_hostile_diff_config -- --nocapture
  • cargo test --test internal_spawn_safety direct_git_command_spawns_are_centralized -- --nocapture
  • cargo test --test continue_session -- --nocapture
  • cargo fmt -- --check

Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/593 **State:** closed **Merged:** Yes --- ## Summary - introduce explicit internal git execution profiles (`General`, `PatchParse`, `NumstatParse`, `RawDiffParse`) and route parse-sensitive callsites through them - remove implicit command-name-based diff rewriting and replace it with explicit profile application at callsites - harden patch parsing for `+++` headers to handle no-prefix/custom-prefix/mnemonic-style paths - add hostile `diff.*` config integration coverage for simple additions, diff, stats, and status - add centralized-spawn guard test to prevent direct internal git spawns outside approved helpers ## Hardening fixes added after review - profile conflict stripping now only rewrites option tokens after the git subcommand and before `--`, so pathspec tokens are never dropped - `NumstatParse` now strips short rename/copy variants (`-M*`, `-C*`) so `--no-renames` cannot be overridden later in argv - `continue_session` patch-producing `git show` now uses `PatchParse` profile for stable output under hostile `diff.*` config ## Validation - `cargo test --lib numstat_profile_strips_short_rename_and_copy_flags` - `cargo test --lib profile_rewrite_does_not_strip_pathspec_tokens_after_double_dash` - `cargo test --tests --no-run` - `cargo test --test simple_additions test_simple_additions_with_base_commit_and_custom_diff_config -- --nocapture` - `cargo test --test diff test_diff_parsing_is_stable_under_hostile_diff_config -- --nocapture` - `cargo test --test stats test_stats_cli_range_with_hostile_diff_config -- --nocapture` - `cargo test --test status_ignore test_status_numstat_is_stable_under_hostile_diff_config -- --nocapture` - `cargo test --test internal_spawn_safety direct_git_command_spawns_are_centralized -- --nocapture` - `cargo test --test continue_session -- --nocapture` - `cargo fmt -- --check` <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/593" 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:14:04 +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#595
No description provided.