Skip to content

Commit 4acfff9

Browse files
committed
Merge branch 'jk/gc-auto-after-fetch'
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
2 parents 97fbc23 + 012a1bb commit 4acfff9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

builtin/fetch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
962962
struct string_list list = STRING_LIST_INIT_NODUP;
963963
struct remote *remote;
964964
int result = 0;
965+
static const char *argv_gc_auto[] = {
966+
"gc", "--auto", NULL,
967+
};
965968

966969
packet_trace_identity("fetch");
967970

@@ -1041,5 +1044,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
10411044
list.strdup_strings = 1;
10421045
string_list_clear(&list, 0);
10431046

1047+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
1048+
10441049
return result;
10451050
}

fetch-pack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,9 @@ static int everything_local(struct fetch_pack_args *args,
594594
for (ref = *refs; ref; ref = ref->next) {
595595
struct object *o;
596596

597+
if (!has_sha1_file(ref->old_sha1))
598+
continue;
599+
597600
o = parse_object(ref->old_sha1);
598601
if (!o)
599602
continue;

0 commit comments

Comments
 (0)