Code

attribute macro support
[git.git] / upload-pack.c
index d1be07fb9efccb8244df1c130a6401a02c0a2ebf..d3a09e78d56642db9b1fb1b1ead34ff60dd8c923 100644 (file)
@@ -10,7 +10,7 @@
 #include "revision.h"
 #include "list-objects.h"
 
-static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] [--no-progress] <dir>";
+static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
 
 /* bits #0..7 in revision.h, #8..10 in commit.c */
 #define THEY_HAVE      (1u << 11)
@@ -119,6 +119,7 @@ static void create_pack_file(void)
                int i;
                struct rev_info revs;
 
+               close(lp_pipe[0]);
                pack_pipe = fdopen(lp_pipe[1], "w");
 
                if (create_full_pack)
@@ -465,7 +466,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())
@@ -512,7 +513,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;
@@ -525,7 +526,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);
@@ -533,7 +534,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);
@@ -547,6 +548,8 @@ static void receive_needs(void)
                        use_sideband = LARGE_PACKET_MAX;
                else if (strstr(line+45, "side-band"))
                        use_sideband = DEFAULT_PACKET_MAX;
+               if (strstr(line+45, "no-progress"))
+                       no_progress = 1;
 
                /* We have sent all our refs already, and the other end
                 * should have chosen out of them; otherwise they are
@@ -615,7 +618,7 @@ static void receive_needs(void)
 static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
        static const char *capabilities = "multi_ack thin-pack side-band"
-               " side-band-64k ofs-delta shallow";
+               " side-band-64k ofs-delta shallow no-progress";
        struct object *o = parse_object(sha1);
 
        if (!o)
@@ -666,14 +669,10 @@ int main(int argc, char **argv)
                        strict = 1;
                        continue;
                }
-               if (!strncmp(arg, "--timeout=", 10)) {
+               if (!prefixcmp(arg, "--timeout=")) {
                        timeout = atoi(arg+10);
                        continue;
                }
-               if (!strcmp(arg, "--no-progress")) {
-                       no_progress = 1;
-                       continue;
-               }
                if (!strcmp(arg, "--")) {
                        i++;
                        break;