http-fetch: don't use double-slash as directory separator in URLs
Please see http://bugs.debian.org/409887 http-fetch expected the URL given at the command line to have a trailing slash anyway, and then added '/objects...' when requesting objects files from the http server. Now it doesn't require the trailing slash in <url> anymore, and strips trailing slashes if given nonetheless. Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Gerrit Pape committed
Mar 28, 2007 at 09:46 UTC
2afea3bcd2a2b3327d7e8bdabc9aebd6bef24c6e
3 files changed
+14
-11
git-clone.sh
+1
-1
@@ -60,7 +60,7 @@ Perhaps git-update-server-info needs to be run there?"
60
else
61
tname=$name
62
fi
63
- git-http-fetch $v -a -w "$tname" "$name" "$1/" || exit 1
63
+ git-http-fetch $v -a -w "$tname" "$name" "$1" || exit 1
64
done <"$clone_tmp/refs"
65
rm -fr "$clone_tmp"
66
http_fetch "$1/HEAD" "$GIT_DIR/REMOTE_HEAD" ||
git-fetch.sh
+1
-1
@@ -248,7 +248,7 @@ fetch_per_ref () {
248
expr "z$head" : "z$_x40\$" >/dev/null ||
249
die "No such ref $remote_name at $remote"
250
echo >&2 "Fetching $remote_name from $remote using $proto"
251
- git-http-fetch -v -a "$head" "$remote/" || exit
251
+ git-http-fetch -v -a "$head" "$remote" || exit
252
;;
253
rsync://*)
254
test -n "$shallow_depth" &&
http-fetch.c
+12
-9
@@ -16,7 +16,7 @@ static struct curl_slist *no_pragma_header;
16
17
struct alt_base
18
{
19
- const char *base;
19
+ char *base;
20
int path_len;
21
int got_indices;
22
struct packed_git *packs;
@@ -158,12 +158,12 @@ static void start_object_request(struct object_request *obj_req)
158
159
SHA1_Init(&obj_req->c);
160
161
- url = xmalloc(strlen(obj_req->repo->base) + 50);
162
- obj_req->url = xmalloc(strlen(obj_req->repo->base) + 50);
161
+ url = xmalloc(strlen(obj_req->repo->base) + 51);
162
+ obj_req->url = xmalloc(strlen(obj_req->repo->base) + 51);
163
strcpy(url, obj_req->repo->base);
164
posn = url + strlen(obj_req->repo->base);
165
- strcpy(posn, "objects/");
166
- posn += 8;
165
+ strcpy(posn, "/objects/");
166
+ posn += 9;
167
memcpy(posn, hex, 2);
168
posn += 2;
169
*(posn++) = '/';
@@ -938,14 +938,14 @@ static char *quote_ref_url(const char *base, const char *ref)
938
int len, baselen, ch;
939
940
baselen = strlen(base);
941
- len = baselen + 6; /* "refs/" + NUL */
941
+ len = baselen + 7; /* "/refs/" + NUL */
942
for (cp = ref; (ch = *cp) != 0; cp++, len++)
943
if (needs_quote(ch))
944
len += 2; /* extra two hex plus replacement % */
945
qref = xmalloc(len);
946
memcpy(qref, base, baselen);
947
- memcpy(qref + baselen, "refs/", 5);
948
- for (cp = ref, dp = qref + baselen + 5; (ch = *cp) != 0; cp++) {
947
+ memcpy(qref + baselen, "/refs/", 6);
948
+ for (cp = ref, dp = qref + baselen + 6; (ch = *cp) != 0; cp++) {
949
if (needs_quote(ch)) {
950
*dp++ = '%';
951
*dp++ = hex((ch >> 4) & 0xF);
@@ -1044,7 +1044,10 @@ int main(int argc, const char **argv)
1044
no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
1045
1046
alt = xmalloc(sizeof(*alt));
1047
- alt->base = url;
1047
+ alt->base = xmalloc(strlen(url) + 1);
1048
+ strcpy(alt->base, url);
1049
+ for (path = alt->base + strlen(alt->base) - 1; *path == '/'; --path)
1050
+ *path = 0;
1051
alt->got_indices = 0;
1052
alt->packs = NULL;
1053
alt->next = NULL;