From: Junio C Hamano Date: Sun, 15 Feb 2009 09:43:57 +0000 (-0800) Subject: Merge branch 'rc/http-push' X-Git-Tag: v1.6.2-rc1~7 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c42b04bbb0cdf7618d3bdb57ed02569a5f128fe9?hp=-c Merge branch 'rc/http-push' * rc/http-push: use a hash of the lock token as the suffix for PUT/MOVE --- c42b04bbb0cdf7618d3bdb57ed02569a5f128fe9 diff --combined http-push.c index a8ae545dfb,55ad808023..30d2d34041 --- a/http-push.c +++ b/http-push.c @@@ -10,7 -10,6 +10,7 @@@ #include "exec_cmd.h" #include "remote.h" #include "list-objects.h" +#include "sigchain.h" #include @@@ -153,6 -152,7 +153,7 @@@ struct remote_loc char *url; char *owner; char *token; + char tmpfile_suffix[41]; time_t start_time; long timeout; int refreshing; @@@ -557,8 -557,7 +558,7 @@@ static void start_put(struct transfer_r request->dest = strbuf_detach(&buf, NULL); append_remote_object_url(&buf, remote->url, hex, 0); - strbuf_addstr(&buf, "_"); - strbuf_addstr(&buf, request->lock->token); + strbuf_add(&buf, request->lock->tmpfile_suffix, 41); request->url = strbuf_detach(&buf, NULL); slot = get_active_slot(); @@@ -1130,6 -1129,8 +1130,8 @@@ static void handle_lockprop_ctx(struct static void handle_new_lock_ctx(struct xml_ctx *ctx, int tag_closed) { struct remote_lock *lock = (struct remote_lock *)ctx->userData; + git_SHA_CTX sha_ctx; + unsigned char lock_token_sha1[20]; if (tag_closed && ctx->cdata) { if (!strcmp(ctx->name, DAV_ACTIVELOCK_OWNER)) { @@@ -1142,6 -1143,13 +1144,13 @@@ } else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) { lock->token = xmalloc(strlen(ctx->cdata) + 1); strcpy(lock->token, ctx->cdata); + + git_SHA1_Init(&sha_ctx); + git_SHA1_Update(&sha_ctx, lock->token, strlen(lock->token)); + git_SHA1_Final(lock_token_sha1, &sha_ctx); + + lock->tmpfile_suffix[0] = '_'; + memcpy(lock->tmpfile_suffix + 1, sha1_to_hex(lock_token_sha1), 40); } } } @@@ -1378,7 -1386,7 +1387,7 @@@ static void remove_locks(void static void remove_locks_on_signal(int signo) { remove_locks(); - signal(signo, SIG_DFL); + sigchain_pop(signo); raise(signo); } @@@ -2189,8 -2197,6 +2198,8 @@@ int main(int argc, char **argv struct ref *ref; char *rewritten_url = NULL; + git_extract_argv0_path(argv[0]); + setup_git_directory(); remote = xcalloc(sizeof(*remote), 1); @@@ -2273,7 -2279,10 +2282,7 @@@ goto cleanup; } - signal(SIGINT, remove_locks_on_signal); - signal(SIGHUP, remove_locks_on_signal); - signal(SIGQUIT, remove_locks_on_signal); - signal(SIGTERM, remove_locks_on_signal); + sigchain_push_common(remove_locks_on_signal); /* Check whether the remote has server info files */ remote->can_update_info_refs = 0;