Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 984197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:58:36+00:00 2026-05-16T04:58:36+00:00

I would like to use the git pre-auto-gc hook but it doesn’t seem to

  • 0

I would like to use the git pre-auto-gc hook but it doesn’t seem to be invoked at all.

The file is executable and I tested it with git 1.7.1 and 1.5.6.5, neither of these seems to work as expected (they’re not invoking the script when git gc --auto is run).

Does anyone of you know something about it? Maybe I need to setup someting in the configuration to make git aware of this hook?

I tried to google a bit but I didn’t find anything…

Thanks :-).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:58:36+00:00Added an answer on May 16, 2026 at 4:58 am

    Okay I may have an answer.

    In the git source of gc.c, I see that the hook is run in the need_to_gc function which have two ways to squeeze it…

    static int need_to_gc(void)
    {
      /*
       * Setting gc.auto to 0 or negative can disable the
       * automatic gc.
       */
      if (gc_auto_threshold <= 0)
        return 0;
    
      /*
       * If there are too many loose objects, but not too many
       * packs, we run "repack -d -l".  If there are too many packs,
       * we run "repack -A -d -l".  Otherwise we tell the caller
       * there is no need.
       */
      if (too_many_packs())
        append_option(argv_repack,
                      prune_expire && !strcmp(prune_expire, "now") ?
                      "-a" : "-A",
                      MAX_ADD);
      else if (!too_many_loose_objects())
        return 0;
    
      if (run_hook(NULL, "pre-auto-gc", NULL))
        return 0;
      return 1;
    }
    

    IMO the first short-circuit (if gc.auto is set to 0) is okay. But the second one should not prevent the hooks to be run, maybe it should pass it a boolean argument saying if yes or no the gc is needed. Because as it is now it’s kind of frustrating that the hook isn’t run when you would want it to.

    And BTW I discovered the git source code, it’s really a pleasure to read code that much clean!

    EDIT: I tested the hook again on some old and rather big repos and the gc has never been called when the --auto option was supplied. The default auto_threshold value (which is apparently 27) might be a bit too high, or maybe the gc is needed only in extreme situation.

    Anyway, it annoys me that this hook is not invoked, so much for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use a component that exposes the datasource property, but instead
I would like to use Emacs to edit some VB6 files but Emacs does
I would like to use VB9 but am not sure what syntax to use
Im trying to use git extensions and I really like it so far, but
I would like to run git reset *.foo but this errors out. I think
I would like to use a language that I am familiar with - Java,
I would like to use something like CLR Profiles on .Net 2.0 to see
I would like to use as and is as members of an enumeration. I
I would like to use client-side Javascript to perform a DNS lookup (hostname to
I would like to use javascript to develop general-purpose GUI applications. Initially these are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.