Merge branch 'mh/packed-ref-store' into next
[gitweb.git] / builtin / gc.c
index f484eda43ca06046924931d2055b50c2f89ea8d7..e6b84475aef6aeab05beda137fb2882f663fac0f 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include "builtin.h"
+#include "config.h"
 #include "tempfile.h"
 #include "lockfile.h"
 #include "parse-options.h"
@@ -148,7 +149,7 @@ static int too_many_loose_objects(void)
        if (!dir)
                return 0;
 
-       auto_threshold = (gc_auto_threshold + 255) / 256;
+       auto_threshold = DIV_ROUND_UP(gc_auto_threshold, 256);
        while ((ent = readdir(dir)) != NULL) {
                if (strspn(ent->d_name, "0123456789abcdef") != 38 ||
                    ent->d_name[38] != '\0')
@@ -413,8 +414,12 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
                        if (report_last_gc_error())
                                return -1;
 
+                       if (lock_repo_for_gc(force, &pid))
+                               return 0;
                        if (gc_before_repack())
                                return -1;
+                       delete_tempfile(&pidfile);
+
                        /*
                         * failure to daemonize is ok, we'll continue
                         * in foreground