Skip to content

git post-command hooks that don't exist still runs code #800

Closed

Description

@gobananasgo

When users typo a git command, the typo'd command takes a few seconds to return that there was an issue with the input.

Expected output:
When a user makes a typo or enters a command that does not exist, the response should be immediate vs a delay and unnecessary background task running.

Activity

  1. dscho commented on Sep 27, 2025

    @dscho
    Member

    Hmm. I wonder whether this is anything but by design. The pre-/post-hook commands are supposed to run so that internal telemetry can be accumulated, which should benefit from acquiring statistics about mistyped commands, no? Feel free to reach out internally if you can provide more context that way.

  2. derrickstolee commented on Sep 30, 2025

    @derrickstolee

    One important context of this bug report is that the repo is configured with postCommand.strategy=post-index-change.

    Before using that strategy, these hooks were configured to no-op if they didn't see a sentinel file written by the post-index-change hook. Now, the post-command hook runs unconditionally (because the conditional logic is in Git itself).

    The problem is likely due to Git not trying to load config when fast failing like this, leading to the strategy not being engaged. Can we consider loading config before executing a post-command hook? Can we have this only matter for repos that have a post-command hook present?

  3. dscho commented on Nov 10, 2025

    @dscho
    Member

    This was addressed by #813, correct?

  4. derrickstolee commented on Nov 10, 2025

    @derrickstolee

    This was addressed by #813, correct?

    Yes. I should have linked it from that PR.

  5. derrickstolee commented on Nov 10, 2025

    @derrickstolee

    Closed via #813.

  6. dscho commented on Nov 10, 2025

    @dscho
    Member

    This was addressed by #813, correct?

    Yes. I should have linked it from that PR.

    Funny, I thought I should have remembered and linked it ;-)

    In any case, thank you so much Derrick Stolee (@derrickstolee)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions