struct alt_base
{
- const char *base;
- int path_len;
+ char *base;
int got_indices;
struct packed_git *packs;
struct alt_base *next;
SHA1_Init(&obj_req->c);
- url = xmalloc(strlen(obj_req->repo->base) + 50);
- obj_req->url = xmalloc(strlen(obj_req->repo->base) + 50);
+ url = xmalloc(strlen(obj_req->repo->base) + 51);
+ obj_req->url = xmalloc(strlen(obj_req->repo->base) + 51);
strcpy(url, obj_req->repo->base);
posn = url + strlen(obj_req->repo->base);
- strcpy(posn, "objects/");
- posn += 8;
+ strcpy(posn, "/objects/");
+ posn += 9;
memcpy(posn, hex, 2);
posn += 2;
*(posn++) = '/';
SHA1_Init(&obj_req->c);
if (prev_posn>0) {
prev_posn = 0;
- lseek(obj_req->local, SEEK_SET, 0);
+ lseek(obj_req->local, 0, SEEK_SET);
ftruncate(obj_req->local, 0);
}
}
int serverlen = 0;
struct alt_base *newalt;
char *target = NULL;
- char *path;
if (data[i] == '/') {
/* This counts
* http://git.host/pub/scm/linux.git/
newalt->base = target;
newalt->got_indices = 0;
newalt->packs = NULL;
- path = strstr(target, "//");
- if (path) {
- path = strchr(path+2, '/');
- if (path)
- newalt->path_len = strlen(path);
- }
while (tail->next != NULL)
tail = tail->next;
case 'P':
i++;
if (i + 52 <= buffer.posn &&
- !strncmp(data + i, " pack-", 6) &&
- !strncmp(data + i + 46, ".pack\n", 6)) {
+ !prefixcmp(data + i, " pack-") &&
+ !prefixcmp(data + i + 46, ".pack\n")) {
get_sha1_hex(data + i + 6, sha1);
setup_index(repo, sha1);
i += 51;
}
unlink(obj_req->tmpfile);
if (obj_req->slot) {
- release_active_slot(obj_req->slot);
+ release_active_slot(obj_req->slot);
obj_req->slot = NULL;
}
release_object_request(obj_req);
int len, baselen, ch;
baselen = strlen(base);
- len = baselen + 6; /* "refs/" + NUL */
+ len = baselen + 7; /* "/refs/" + NUL */
for (cp = ref; (ch = *cp) != 0; cp++, len++)
if (needs_quote(ch))
len += 2; /* extra two hex plus replacement % */
qref = xmalloc(len);
memcpy(qref, base, baselen);
- memcpy(qref + baselen, "refs/", 5);
- for (cp = ref, dp = qref + baselen + 5; (ch = *cp) != 0; cp++) {
+ memcpy(qref + baselen, "/refs/", 6);
+ for (cp = ref, dp = qref + baselen + 6; (ch = *cp) != 0; cp++) {
if (needs_quote(ch)) {
*dp++ = '%';
*dp++ = hex((ch >> 4) & 0xF);
const char **write_ref = NULL;
char **commit_id;
const char *url;
- char *path;
+ char *s;
int arg = 1;
int rc = 0;
no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
alt = xmalloc(sizeof(*alt));
- alt->base = url;
+ alt->base = xmalloc(strlen(url) + 1);
+ strcpy(alt->base, url);
+ for (s = alt->base + strlen(alt->base) - 1; *s == '/'; --s)
+ *s = 0;
alt->got_indices = 0;
alt->packs = NULL;
alt->next = NULL;
- path = strstr(url, "//");
- if (path) {
- path = strchr(path+2, '/');
- if (path)
- alt->path_len = strlen(path);
- }
if (pull(commits, commit_id, write_ref, url))
rc = 1;