fetch-pack: do not remove .git/shallow file when --depth is not specified
[gitweb.git] / fetch-pack.c
index 6b5467c6dec9645f53d83cdad2467a158db622c0..76190a8fbd58f2ada7f073f1035003823f55fbdb 100644 (file)
@@ -888,6 +888,8 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
                packet_flush(fd[1]);
        if (args->depth > 0)
                setup_alternate_shallow();
+       else
+               alternate_shallow_file = NULL;
        if (get_pack(args, fd, pack_lockfile))
                die("git fetch-pack: fetch failed.");
 
@@ -978,7 +980,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
        }
        ref_cpy = do_fetch_pack(args, fd, ref, sought, nr_sought, pack_lockfile);
 
-       if (alternate_shallow_file) {
+       if (args->depth > 0 && alternate_shallow_file) {
                if (*alternate_shallow_file == '\0') { /* --unshallow */
                        unlink_or_warn(git_path("shallow"));
                        rollback_lock_file(&shallow_lock);