Merge branch 'maint'
[gitweb.git] / upload-pack.c
index 3a466c6a3e66fdde2bb20b580db841c0600190bb..804bbb6c9eb788714afb493e331341206cebaaf3 100644 (file)
@@ -455,7 +455,7 @@ static int get_common_commits(void)
                        continue;
                }
                len = strip(line, len);
-               if (!strncmp(line, "have ", 5)) {
+               if (!prefixcmp(line, "have ")) {
                        switch (got_sha1(line+5, sha1)) {
                        case -1: /* they have what we do not */
                                if (multi_ack && ok_to_give_up())
@@ -502,7 +502,7 @@ static void receive_needs(void)
                if (!len)
                        break;
 
-               if (!strncmp("shallow ", line, 8)) {
+               if (!prefixcmp(line, "shallow ")) {
                        unsigned char sha1[20];
                        struct object *object;
                        use_thin_pack = 0;
@@ -515,7 +515,7 @@ static void receive_needs(void)
                        add_object_array(object, NULL, &shallows);
                        continue;
                }
-               if (!strncmp("deepen ", line, 7)) {
+               if (!prefixcmp(line, "deepen ")) {
                        char *end;
                        use_thin_pack = 0;
                        depth = strtol(line + 7, &end, 0);
@@ -523,7 +523,7 @@ static void receive_needs(void)
                                die("Invalid deepen: %s", line);
                        continue;
                }
-               if (strncmp("want ", line, 5) ||
+               if (prefixcmp(line, "want ") ||
                    get_sha1_hex(line+5, sha1_buf))
                        die("git-upload-pack: protocol error, "
                            "expected to get sha, not '%s'", line);
@@ -656,7 +656,7 @@ int main(int argc, char **argv)
                        strict = 1;
                        continue;
                }
-               if (!strncmp(arg, "--timeout=", 10)) {
+               if (!prefixcmp(arg, "--timeout=")) {
                        timeout = atoi(arg+10);
                        continue;
                }
@@ -672,7 +672,8 @@ int main(int argc, char **argv)
 
        if (!enter_repo(dir, strict))
                die("'%s': unable to chdir or not a git archive", dir);
-
+       if (is_repository_shallow())
+               die("attempt to fetch/clone from a shallow repository");
        upload_pack();
        return 0;
 }