Skip to content

Commit 012a1bb

Browse files
committed
Merge branch 'jk/maint-gc-auto-after-fetch' into jk/gc-auto-after-fetch
* jk/maint-gc-auto-after-fetch: fetch-pack: avoid repeatedly re-scanning pack directory fetch: run gc --auto after fetching
2 parents 5d41784 + b495697 commit 012a1bb

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
@@ -959,6 +959,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
959959
struct string_list list = STRING_LIST_INIT_NODUP;
960960
struct remote *remote;
961961
int result = 0;
962+
static const char *argv_gc_auto[] = {
963+
"gc", "--auto", NULL,
964+
};
962965

963966
packet_trace_identity("fetch");
964967

@@ -1026,5 +1029,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
10261029
list.strdup_strings = 1;
10271030
string_list_clear(&list, 0);
10281031

1032+
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
1033+
10291034
return result;
10301035
}

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)