git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] gc: config option for running --auto in background

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Feb 10, 2014, 11:03 UTC
Message-ID
<CABPQNSb3=i8F+vPEG3RmH+snZVZ-xrPtcVY2Nx9uvyTCLXcy6g@mail.gmail.com>
In-Reply-To
<1391843332-20583-2-git-send-email-pclouds@gmail.com>
On Sat, Feb 8, 2014 at 8:08 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 73 quoted lines
> `gc --auto` takes time and can block the user temporarily (but not any
> less annoyingly). Make it run in background on systems that support
> it. The only thing lost with running in background is printouts. But
> gc output is not really interesting. You can keep it in foreground by
> changing gc.autodetach.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  Documentation/config.txt |  4 ++++
>  builtin/gc.c             | 23 ++++++++++++++++++-----
>  t/t5400-send-pack.sh     |  1 +
>  3 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 5f4d793..4781773 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1167,6 +1167,10 @@ gc.autopacklimit::
>         --auto` consolidates them into one larger pack.  The
>         default value is 50.  Setting this to 0 disables it.
>
> +gc.autodetach::
> +       Make `git gc --auto` return immediately andrun in background
> +       if the system supports it. Default is true.
> +
>  gc.packrefs::
>         Running `git pack-refs` in a repository renders it
>         unclonable by Git versions prior to 1.5.1.2 over dumb
> diff --git a/builtin/gc.c b/builtin/gc.c
> index c19545d..ed5cc3c 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -29,6 +29,7 @@ static int pack_refs = 1;
>  static int aggressive_window = 250;
>  static int gc_auto_threshold = 6700;
>  static int gc_auto_pack_limit = 50;
> +static int detach_auto = 1;
>  static const char *prune_expire = "2.weeks.ago";
>
>  static struct argv_array pack_refs_cmd = ARGV_ARRAY_INIT;
> @@ -73,6 +74,10 @@ static int gc_config(const char *var, const char *value, void *cb)
>                 gc_auto_pack_limit = git_config_int(var, value);
>                 return 0;
>         }
> +       if (!strcmp(var, "gc.autodetach")) {
> +               detach_auto = git_config_bool(var, value);
> +               return 0;
> +       }
>         if (!strcmp(var, "gc.pruneexpire")) {
>                 if (value && strcmp(value, "now")) {
>                         unsigned long now = approxidate("now");
> @@ -301,11 +306,19 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
>                  */
>                 if (!need_to_gc())
>                         return 0;
> -               if (!quiet)
> -                       fprintf(stderr,
> -                                       _("Auto packing the repository for optimum performance. You may also\n"
> -                                       "run \"git gc\" manually. See "
> -                                       "\"git help gc\" for more information.\n"));
> +               if (!quiet) {
> +                       if (detach_auto)
> +                               fprintf(stderr, _("Auto packing the repository in background for optimum performance.\n"));
> +                       else
> +                               fprintf(stderr, _("Auto packing the repository for optimum performance.\n"));
> +                       fprintf(stderr, _("See \"git help gc\" for manual housekeeping.\n"));
> +               }
> +               if (detach_auto)
> +                       /*
> +                        * failure to daemonize is ok, we'll continue
> +                        * in foreground
> +                        */
> +                       daemonize();
While I agree that it should be OK, shouldn't we warn the user?
Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 14 of 30 in “bug? git push triggers auto pack when gc.auto = 0”
  1. chrisFeb 4, 2014
  2. Duy NguyenFeb 4, 2014
  3. chrisFeb 4, 2014
  4. Duy NguyenFeb 4, 2014
  5. 1/2 receive-pack: update $GIT_DIR/info before auto garbage collectionNguyễn Thái Ngọc Duy, Feb 4, 2014
  6. 2/2 receive-pack: hint that the user can stop "git push" at auto gc timeNguyễn Thái Ngọc Duy, Feb 4, 2014
  7. Junio C HamanoFeb 4, 2014
  8. Junio C HamanoFeb 4, 2014
  9. chrisFeb 7, 2014
  10. Duy NguyenFeb 7, 2014
  11. chrisFeb 7, 2014
  12. 1/2 daemon: move daemonize() to libgit.aNguyễn Thái Ngọc Duy, Feb 8, 2014
  13. 2/2 gc: config option for running --auto in backgroundNguyễn Thái Ngọc Duy, Feb 8, 2014
  14. Erik Faye-LundFeb 10, 2014
  15. Duy NguyenFeb 10, 2014
  16. Erik Faye-LundFeb 10, 2014
  17. Junio C HamanoFeb 10, 2014
  18. Junio C HamanoFeb 10, 2014
  19. Duy NguyenFeb 12, 2014
  20. Junio C HamanoFeb 12, 2014
  21. Erik Faye-LundFeb 10, 2014
  22. Junio C HamanoFeb 10, 2014
  23. Duy NguyenFeb 10, 2014
  24. Junio C HamanoFeb 11, 2014
  25. chrisFeb 4, 2014
  26. David KastrupFeb 4, 2014
  27. chrisFeb 4, 2014
  28. David KastrupFeb 4, 2014
  29. chrisFeb 4, 2014
  30. David KastrupFeb 4, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.