+static int receive_needs(void)
+{
+ static char line[1000];
+ int len, needs;
+
+ needs = 0;
+ for (;;) {
+ len = packet_read_line(0, line, sizeof(line));
+ if (!len)
+ return needs;
+
+ /*
+ * This is purely theoretical right now: git-fetch-pack only
+ * ever asks for a single HEAD
+ */
+ if (needs >= MAX_NEEDS)
+ die("I'm only doing a max of %d requests", MAX_NEEDS);
+ if (strncmp("want ", line, 5) || get_sha1_hex(line+5, needs_sha1[needs]))
+ die("git-upload-pack: protocol error, expected to get sha, not '%s'", line);
+ needs++;
+ }
+}
+