[PR #476] Respect Ctrl+C during git-ai hooks #498

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

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

State: closed
Merged: Yes


Ctrl+C during long-running pre/post hooks does not terminate git-ai promptly, unlike when proxying git directly. The goal is immediate exit on interrupt.

  • Interrupt-aware hook flow
    • Skip post-hook processing when the proxied git command exits due to Ctrl+C so git-ai terminates immediately.
  • Cross-platform interrupt detection
    • Unix: SIGINT detection.
    • Windows: NTSTATUS STATUS_CONTROL_C_EXIT comparison using unsigned reinterpretation.
  • Targeted unit coverage
    • Added Unix and Windows tests for interrupt detection (including non-interrupt cases).
#[cfg(windows)]
fn exit_status_was_interrupted(status: &std::process::ExitStatus) -> bool {
    // Reinterpret the signed exit code as u32 to compare against the NTSTATUS value.
    status.code().map(|code| code as u32) == Some(NTSTATUS_CONTROL_C_EXIT)
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Ensure that git-ai respects ctrl+c interrupts during pre/post hooks</issue_title>
<issue_description>I noticed that ctrl+c doesn't exit git-ai during slow pre/post hooks the same way that it does when git-ai is proxying git. The expected behavior is that git-ai should quit immediately when interrupted.

➜  git-ai git:(feat/blame-plugin) git pull                        
[git-ai] started fetching authorship notes from remote: origin
[git-ai] fetching authorship notes for remote 'origin' to tracking ref 'refs/notes/ai-remote/origin'
[git-ai] ls-remote command: ["-C", "/Users/svarlamov/projects/git-ai", "--no-pager", "ls-remote", "origin", "refs/notes/ai"]
[git-ai] pull pre-hook: rebase=false, autostash=false, has_changes=false
^C^C^C^C^C^C^C^C^C^C^C^C^C[git-ai] failed to check for authorship notes on remote 'origin': Git CLI (-C /Users/svarlamov/projects/git-ai --no-pager ls-remote origin refs/notes/ai) failed with exit code 128: fatal: unable to access 'https://github.com/acunniffe/git-ai/': Recv failure: Operation timed out

[git-ai] authorship fetch failed: Git CLI (-C /Users/svarlamov/projects/git-ai --no-pager ls-remote origin refs/notes/ai) failed with exit code 128: fatal: unable to access 'https://github.com/acunniffe/git-ai/': Recv failure: Operation timed out

^C^C^C^C^C^C^C^C^C^C^C^Cfatal: unable to access 'https://github.com/acunniffe/git-ai/': Recv failure: Operation timed out
[git-ai] Pull failed, skipping post-pull authorship restoration
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/476 **State:** closed **Merged:** Yes --- Ctrl+C during long-running pre/post hooks does not terminate git-ai promptly, unlike when proxying git directly. The goal is immediate exit on interrupt. - **Interrupt-aware hook flow** - Skip post-hook processing when the proxied git command exits due to Ctrl+C so git-ai terminates immediately. - **Cross-platform interrupt detection** - Unix: SIGINT detection. - Windows: NTSTATUS STATUS_CONTROL_C_EXIT comparison using unsigned reinterpretation. - **Targeted unit coverage** - Added Unix and Windows tests for interrupt detection (including non-interrupt cases). ```rust #[cfg(windows)] fn exit_status_was_interrupted(status: &std::process::ExitStatus) -> bool { // Reinterpret the signed exit code as u32 to compare against the NTSTATUS value. status.code().map(|code| code as u32) == Some(NTSTATUS_CONTROL_C_EXIT) } ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Ensure that git-ai respects ctrl+c interrupts during pre/post hooks</issue_title> > <issue_description>I noticed that ctrl+c doesn't exit git-ai during slow pre/post hooks the same way that it does when git-ai is proxying git. The expected behavior is that git-ai should quit immediately when interrupted. > > ```bash > ➜ git-ai git:(feat/blame-plugin) git pull > [git-ai] started fetching authorship notes from remote: origin > [git-ai] fetching authorship notes for remote 'origin' to tracking ref 'refs/notes/ai-remote/origin' > [git-ai] ls-remote command: ["-C", "/Users/svarlamov/projects/git-ai", "--no-pager", "ls-remote", "origin", "refs/notes/ai"] > [git-ai] pull pre-hook: rebase=false, autostash=false, has_changes=false > ^C^C^C^C^C^C^C^C^C^C^C^C^C[git-ai] failed to check for authorship notes on remote 'origin': Git CLI (-C /Users/svarlamov/projects/git-ai --no-pager ls-remote origin refs/notes/ai) failed with exit code 128: fatal: unable to access 'https://github.com/acunniffe/git-ai/': Recv failure: Operation timed out > > [git-ai] authorship fetch failed: Git CLI (-C /Users/svarlamov/projects/git-ai --no-pager ls-remote origin refs/notes/ai) failed with exit code 128: fatal: unable to access 'https://github.com/acunniffe/git-ai/': Recv failure: Operation timed out > > ^C^C^C^C^C^C^C^C^C^C^C^Cfatal: unable to access 'https://github.com/acunniffe/git-ai/': Recv failure: Operation timed out > [git-ai] Pull failed, skipping post-pull authorship restoration > ```</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes git-ai-project/git-ai#312 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/git-ai-project/git-ai/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/476" 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:48 +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#498
No description provided.