7 static struct ref *get_refs(struct walker *walker, const char *url)
9 struct strbuf buffer = STRBUF_INIT;
10 char *data, *start, *mid;
16 struct ref *refs = NULL;
17 struct ref *ref = NULL;
18 struct ref *last_ref = NULL;
20 refs_url = xmalloc(strlen(url) + 11);
21 sprintf(refs_url, "%s/info/refs", url);
23 http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
27 case HTTP_MISSING_TARGET:
28 die("%s not found: did you run git update-server-info on the"
29 " server?", refs_url);
31 http_error(refs_url, http_ret);
32 die("HTTP request failed");
38 while (i < buffer.len) {
44 if (data[i] == '\n') {
47 ref = xmalloc(sizeof(struct ref) +
48 strlen(ref_name) + 1);
49 memset(ref, 0, sizeof(struct ref));
50 strcpy(ref->name, ref_name);
51 get_sha1_hex(start, ref->old_sha1);
62 strbuf_release(&buffer);
64 ref = alloc_ref("HEAD");
65 if (!walker->fetch_ref(walker, ref) &&
66 !resolve_remote_symref(ref, refs)) {
73 strbuf_release(&buffer);
78 int main(int argc, const char **argv)
80 struct remote *remote;
81 struct strbuf buf = STRBUF_INIT;
83 struct walker *walker = NULL;
85 setup_git_directory();
87 fprintf(stderr, "Remote needed\n");
91 remote = remote_get(argv[1]);
100 if (strbuf_getline(&buf, stdin, '\n') == EOF)
102 if (!prefixcmp(buf.buf, "fetch ")) {
103 char *obj = buf.buf + strlen("fetch ");
105 walker = get_http_walker(url, remote);
107 walker->get_tree = 1;
108 walker->get_history = 1;
109 walker->get_verbosely = 0;
110 walker->get_recover = 0;
111 if (walker_fetch(walker, 1, &obj, NULL, NULL))
112 die("Fetch failed.");
115 } else if (!strcmp(buf.buf, "list")) {
119 walker = get_http_walker(url, remote);
120 refs = get_refs(walker, url);
121 for (posn = refs; posn; posn = posn->next) {
123 printf("@%s %s\n", posn->symref, posn->name);
125 printf("%s %s\n", sha1_to_hex(posn->old_sha1), posn->name);
129 } else if (!strcmp(buf.buf, "capabilities")) {