X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=http-push.c;h=fe925609b4024119c6171dd32350a6570bea8516;hb=5b5d4d9e1b31997b3179e6a253d47b7eea03d0fa;hp=293269395c90e5e5ec4b3bb06e02e7677da2dac5;hpb=acf59575cac330f3a505247dd7a9d6551a2a9cf8;p=git.git diff --git a/http-push.c b/http-push.c index 29326939..fe925609 100644 --- a/http-push.c +++ b/http-push.c @@ -6,8 +6,6 @@ #include "blob.h" #include "http.h" -#ifdef USE_CURL_MULTI - #include static const char http_push_usage[] = @@ -165,6 +163,7 @@ static void start_check(struct transfer_request *request) } else { request->state = ABORTED; free(request->url); + request->url = NULL; } } @@ -198,6 +197,7 @@ static void start_mkcol(struct transfer_request *request) } else { request->state = ABORTED; free(request->url); + request->url = NULL; } } @@ -244,8 +244,6 @@ static void start_put(struct transfer_request *request) request->buffer.size = stream.total_out; request->buffer.posn = 0; - if (request->url != NULL) - free(request->url); request->url = xmalloc(strlen(remote->url) + strlen(request->lock->token) + 51); strcpy(request->url, remote->url); @@ -281,6 +279,7 @@ static void start_put(struct transfer_request *request) } else { request->state = ABORTED; free(request->url); + request->url = NULL; } } @@ -306,6 +305,7 @@ static void start_move(struct transfer_request *request) } else { request->state = ABORTED; free(request->url); + request->url = NULL; } } @@ -370,6 +370,13 @@ static void finish_request(struct transfer_request *request) if (request->headers != NULL) curl_slist_free_all(request->headers); + + /* URL is reused for MOVE after PUT */ + if (request->state != RUN_PUT) { + free(request->url); + request->url = NULL; + } + if (request->state == RUN_HEAD) { if (request->http_code == 404) { request->state = NEED_PUSH; @@ -435,7 +442,8 @@ static void release_request(struct transfer_request *request) entry->next = entry->next->next; } - free(request->url); + if (request->url != NULL) + free(request->url); free(request); } @@ -575,6 +583,7 @@ static int fetch_index(unsigned char *sha1) } } else { free(url); + fclose(indexfile); return error("Unable to start request"); } @@ -775,7 +784,7 @@ static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed) strtol(ctx->cdata + 7, NULL, 10); } else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) { if (!strncmp(ctx->cdata, "opaquelocktoken:", 16)) { - lock->token = xmalloc(strlen(ctx->cdata - 15)); + lock->token = xmalloc(strlen(ctx->cdata) - 15); strcpy(lock->token, ctx->cdata + 16); } } @@ -999,9 +1008,7 @@ static int unlock_remote(struct active_lock *lock) if (lock->owner != NULL) free(lock->owner); free(lock->url); -/* Freeing the token causes a segfault... free(lock->token); -*/ free(lock); return rc; @@ -1230,6 +1237,7 @@ int main(int argc, char **argv) int rc = 0; int i; + setup_git_directory(); setup_ident(); remote = xmalloc(sizeof(*remote)); @@ -1264,6 +1272,9 @@ int main(int argc, char **argv) break; } + if (!remote->url) + usage(http_push_usage); + memset(remote_dir_exists, 0, 256); http_init(); @@ -1415,10 +1426,3 @@ int main(int argc, char **argv) return rc; } -#else /* ifdef USE_CURL_MULTI */ -int main(int argc, char **argv) -{ - fprintf(stderr, "http-push requires curl 7.9.8 or higher.\n"); - return 1; -} -#endif