From: Junio C Hamano Date: Thu, 8 Apr 2021 20:23:25 +0000 (-0700) Subject: Merge branch 'll/clone-reject-shallow' X-Git-Tag: v2.32.0-rc0~99 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22eee7f4554e777de93134c0ae06ee611bd570a4;p=thirdparty%2Fgit.git Merge branch 'll/clone-reject-shallow' "git clone --reject-shallow" option fails the clone as soon as we notice that we are cloning from a shallow repository. * ll/clone-reject-shallow: builtin/clone.c: add --reject-shallow option --- 22eee7f4554e777de93134c0ae06ee611bd570a4 diff --cc builtin/clone.c index 952fe3d8fc,2a5485b724..f6b0c48bed --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -963,11 -970,12 +970,12 @@@ static int path_exists(const char *path int cmd_clone(int argc, const char **argv, const char *prefix) { int is_bundle = 0, is_local; + int reject_shallow = 0; const char *repo_name, *repo, *work_tree, *git_dir; - char *path, *dir, *display_repo = NULL; + char *path = NULL, *dir, *display_repo = NULL; int dest_exists, real_dest_exists = 0; const struct ref *refs, *remote_head; - const struct ref *remote_head_points_at; + struct ref *remote_head_points_at = NULL; const struct ref *our_head_points_at; struct ref *mapped_refs; const struct ref *ref; diff --cc fetch-pack.c index c80eaee769,40392692ad..6e68276aa3 --- a/fetch-pack.c +++ b/fetch-pack.c @@@ -1113,15 -1129,16 +1113,17 @@@ static struct ref *do_fetch_pack(struc if (args->deepen) setup_alternate_shallow(&shallow_lock, &alternate_shallow_file, NULL); - else if (si->nr_ours || si->nr_theirs) + else if (si->nr_ours || si->nr_theirs) { + if (args->reject_shallow_remote) + die(_("source repository is shallow, reject to clone.")); alternate_shallow_file = setup_temporary_shallow(si->shallow); - else + } else alternate_shallow_file = NULL; if (get_pack(args, fd, pack_lockfiles, NULL, sought, nr_sought, - &gitmodules_oids)) + &fsck_options.gitmodules_found)) die(_("git fetch-pack: fetch failed.")); - fsck_gitmodules_oids(&gitmodules_oids); + if (fsck_finish(&fsck_options)) + die("fsck failed"); all_done: if (negotiator)