]> git.ipfire.org Git - thirdparty/git.git/blobdiff - fetch-pack.c
builtin/clone.c: add --reject-shallow option
[thirdparty/git.git] / fetch-pack.c
index fb04a76ca263042b145b40adf1577a81c6d7e12d..40392692ad07b2e530152c409b248f4357cbd0a8 100644 (file)
@@ -1129,9 +1129,11 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
        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))
@@ -1498,10 +1500,12 @@ static void receive_shallow_info(struct fetch_pack_args *args,
                 * rejected (unless --update-shallow is set); do the same.
                 */
                prepare_shallow_info(si, shallows);
-               if (si->nr_ours || si->nr_theirs)
+               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;
        } else {
                alternate_shallow_file = NULL;