cmd[i] = NULL;
}
-static int need_to_gc(void)
+static int too_many_loose_objects(void)
{
/*
* Quickly check if a "gc" is needed, by estimating how
int num_loose = 0;
int needed = 0;
- /*
- * Setting gc.auto to 0 or negative can disable the
- * automatic gc
- */
- if (gc_auto_threshold <= 0)
- return 0;
-
if (sizeof(path) <= snprintf(path, sizeof(path), "%s/17", objdir)) {
warning("insanely long object directory %.*s", 50, objdir);
return 0;
return needed;
}
+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;
+
+ return too_many_loose_objects();
+}
+
int cmd_gc(int argc, const char **argv, const char *prefix)
{
int i;
if (run_command_v_opt(argv_rerere, RUN_GIT_CMD))
return error(FAILED_RUN, argv_rerere[0]);
+ if (auto_gc && too_many_loose_objects())
+ warning("There are too many unreachable loose objects; "
+ "run 'git prune' to remove them.");
+
return 0;
}