X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-gc.c;h=a2014388dad65fab8c7d32baf275295a0e36b210;hb=e80f97e20c8122f79450e1f40f569df0b52773e9;hp=7af65bb31bfbf3e9a0e47901d44168389d736d20;hpb=8b745e3ffdabe6ef110dc064af46b0ba993941e0;p=git.git diff --git a/builtin-gc.c b/builtin-gc.c index 7af65bb31..a2014388d 100644 --- a/builtin-gc.c +++ b/builtin-gc.c @@ -131,19 +131,9 @@ static int too_many_packs(void) prepare_packed_git(); for (cnt = 0, p = packed_git; p; p = p->next) { - char path[PATH_MAX]; - size_t len; - int keep; - if (!p->pack_local) continue; - len = strlen(p->pack_name); - if (PATH_MAX <= len + 1) - continue; /* oops, give up */ - memcpy(path, p->pack_name, len-5); - memcpy(path + len - 5, ".keep", 6); - keep = access(p->pack_name, F_OK) && (errno == ENOENT); - if (keep) + if (p->pack_keep) continue; /* * Perhaps check the size of the pack and count only @@ -154,34 +144,6 @@ static int too_many_packs(void) return gc_auto_pack_limit <= cnt; } -static int run_hook(void) -{ - const char *argv[2]; - struct child_process hook; - int ret; - - argv[0] = git_path("hooks/pre-auto-gc"); - argv[1] = NULL; - - if (access(argv[0], X_OK) < 0) - return 0; - - memset(&hook, 0, sizeof(hook)); - hook.argv = argv; - hook.no_stdin = 1; - hook.stdout_to_stderr = 1; - - ret = start_command(&hook); - if (ret) { - warning("Could not spawn %s", argv[0]); - return ret; - } - ret = finish_command(&hook); - if (ret == -ERR_RUN_COMMAND_WAITPID_SIGNAL) - warning("%s exited due to uncaught signal", argv[0]); - return ret; -} - static int need_to_gc(void) { /* @@ -198,11 +160,13 @@ static int need_to_gc(void) * there is no need. */ if (too_many_packs()) - append_option(argv_repack, "-A", MAX_ADD); + append_option(argv_repack, + !strcmp(prune_expire, "now") ? "-a" : "-A", + MAX_ADD); else if (!too_many_loose_objects()) return 0; - if (run_hook()) + if (run_hook(NULL, "pre-auto-gc", NULL)) return 0; return 1; } @@ -253,7 +217,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix) "run \"git gc\" manually. See " "\"git help gc\" for more information.\n"); } else - append_option(argv_repack, "-A", MAX_ADD); + append_option(argv_repack, + !strcmp(prune_expire, "now") ? "-a" : "-A", + MAX_ADD); if (pack_refs && run_command_v_opt(argv_pack_refs, RUN_GIT_CMD)) return error(FAILED_RUN, argv_pack_refs[0]);