From: Junio C Hamano Date: Fri, 1 Feb 2013 20:40:16 +0000 (-0800) Subject: Merge branch 'jk/gc-auto-after-fetch' X-Git-Tag: v1.8.2-rc0~65 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4acfff9dda29ae700c8b053cf7af9d4bcdf73762?hp=-c 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 --- 4acfff9dda29ae700c8b053cf7af9d4bcdf73762 diff --combined builtin/fetch.c index 3b97fc9bc6,1ddbf0d0b1..4b6b1dfe66 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@@ -32,7 -32,7 +32,7 @@@ enum static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity; static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT; -static int tags = TAGS_DEFAULT; +static int tags = TAGS_DEFAULT, unshallow; static const char *depth; static const char *upload_pack; static struct strbuf default_rla = STRBUF_INIT; @@@ -82,9 -82,6 +82,9 @@@ static struct option builtin_fetch_opti OPT_BOOL(0, "progress", &progress, N_("force progress reporting")), OPT_STRING(0, "depth", &depth, N_("depth"), N_("deepen history of shallow clone")), + { OPTION_SET_INT, 0, "unshallow", &unshallow, NULL, + N_("convert to a complete repository"), + PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 }, { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, N_("dir"), N_("prepend this to submodule path output"), PARSE_OPT_HIDDEN }, { OPTION_STRING, 0, "recurse-submodules-default", @@@ -962,6 -959,9 +962,9 @@@ int cmd_fetch(int argc, const char **ar 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"); @@@ -973,18 -973,6 +976,18 @@@ argc = parse_options(argc, argv, prefix, builtin_fetch_options, builtin_fetch_usage, 0); + if (unshallow) { + if (depth) + die(_("--depth and --unshallow cannot be used together")); + else if (!is_repository_shallow()) + die(_("--unshallow on a complete repository does not make sense")); + else { + static char inf_depth[12]; + sprintf(inf_depth, "%d", INFINITE_DEPTH); + depth = inf_depth; + } + } + if (recurse_submodules != RECURSE_SUBMODULES_OFF) { if (recurse_submodules_default) { int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default); @@@ -1041,5 -1029,7 +1044,7 @@@ list.strdup_strings = 1; string_list_clear(&list, 0); + run_command_v_opt(argv_gc_auto, RUN_GIT_CMD); + return result; } diff --combined fetch-pack.c index f0acdf7331,b4383c6dca..6d8926a550 --- a/fetch-pack.c +++ b/fetch-pack.c @@@ -594,6 -594,9 +594,9 @@@ static int everything_local(struct fetc 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; @@@ -874,6 -877,8 +877,6 @@@ static int fetch_pack_config(const cha return git_default_config(var, value, cb); } -static struct lock_file lock; - static void fetch_pack_setup(void) { static int did_setup; @@@ -915,7 -920,6 +918,7 @@@ struct ref *fetch_pack(struct fetch_pac ref_cpy = do_fetch_pack(args, fd, ref, sought, pack_lockfile); if (args->depth > 0) { + static struct lock_file lock; struct cache_time mtime; struct strbuf sb = STRBUF_INIT; char *shallow = git_path("shallow");