Merge branch 'jk/gc-auto-after-fetch'
authorJunio C Hamano <gitster@pobox.com>
Fri, 1 Feb 2013 20:40:16 +0000 (12:40 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Feb 2013 20:40:16 +0000 (12:40 -0800)
Help "fetch only" repositories that do not trigger "gc --auto"
often enough.

* jk/gc-auto-after-fetch:
fetch-pack: avoid repeatedly re-scanning pack directory
fetch: run gc --auto after fetching

builtin/fetch.c
fetch-pack.c
index 3b97fc9bc64fb170bc512cc9054a1a3574a322ba..4b6b1dfe66952a7e3fb1516e7e14473febde3d2d 100644 (file)
@@ -962,6 +962,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        struct string_list list = STRING_LIST_INIT_NODUP;
        struct remote *remote;
        int result = 0;
+       static const char *argv_gc_auto[] = {
+               "gc", "--auto", NULL,
+       };
 
        packet_trace_identity("fetch");
 
@@ -1041,5 +1044,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        list.strdup_strings = 1;
        string_list_clear(&list, 0);
 
+       run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+
        return result;
 }
index f0acdf7331eeaf7a55ad09309a788c5971fe9b7f..6d8926a5504a6cd93e19860f85d58816bdd5c222 100644 (file)
@@ -594,6 +594,9 @@ static int everything_local(struct fetch_pack_args *args,
        for (ref = *refs; ref; ref = ref->next) {
                struct object *o;
 
+               if (!has_sha1_file(ref->old_sha1))
+                       continue;
+
                o = parse_object(ref->old_sha1);
                if (!o)
                        continue;