]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'll/clone-reject-shallow'
authorJunio C Hamano <gitster@pobox.com>
Thu, 8 Apr 2021 20:23:25 +0000 (13:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Apr 2021 20:23:25 +0000 (13:23 -0700)
"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

1  2 
builtin/clone.c
fetch-pack.c
transport.c

diff --cc builtin/clone.c
index 952fe3d8fc8829b7167fb8da78844fa5caa228d7,2a5485b72499658ca76d4a65b29efb6123931db2..f6b0c48beda5fe32fab4d4ab65802f1e5dc9a09f
@@@ -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 c80eaee769401ed86d7ebc5e91ca179d2f2f7f35,40392692ad07b2e530152c409b248f4357cbd0a8..6e68276aa3a2969ac3f13d93fe29d64e89d04463
@@@ -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)
diff --cc transport.c
Simple merge