mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
http-push: cleanup
More consistent usage string, condense push output, remove extra slashes in URLs, fix unused variables, include HTTP method name in failure messages. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
197e8951ab
commit
1a703cba6d
47
http-push.c
47
http-push.c
|
@ -11,7 +11,7 @@
|
||||||
#include <expat.h>
|
#include <expat.h>
|
||||||
|
|
||||||
static const char http_push_usage[] =
|
static const char http_push_usage[] =
|
||||||
"git-http-push [--complete] [--force] [--verbose] <url> <ref> [<ref>...]\n";
|
"git-http-push [--all] [--force] [--verbose] <remote> [<head>...]\n";
|
||||||
|
|
||||||
#ifndef XML_STATUS_OK
|
#ifndef XML_STATUS_OK
|
||||||
enum XML_Status {
|
enum XML_Status {
|
||||||
|
@ -707,6 +707,7 @@ static void finish_request(struct transfer_request *request)
|
||||||
}
|
}
|
||||||
} else if (request->state == RUN_MOVE) {
|
} else if (request->state == RUN_MOVE) {
|
||||||
if (request->curl_result == CURLE_OK) {
|
if (request->curl_result == CURLE_OK) {
|
||||||
|
if (push_verbosely)
|
||||||
fprintf(stderr, " sent %s\n",
|
fprintf(stderr, " sent %s\n",
|
||||||
sha1_to_hex(request->obj->sha1));
|
sha1_to_hex(request->obj->sha1));
|
||||||
request->obj->flags |= REMOTE;
|
request->obj->flags |= REMOTE;
|
||||||
|
@ -848,7 +849,7 @@ static void add_fetch_request(struct object *obj)
|
||||||
step_active_slots();
|
step_active_slots();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_send_request(struct object *obj, struct remote_lock *lock)
|
static int add_send_request(struct object *obj, struct remote_lock *lock)
|
||||||
{
|
{
|
||||||
struct transfer_request *request = request_queue_head;
|
struct transfer_request *request = request_queue_head;
|
||||||
struct packed_git *target;
|
struct packed_git *target;
|
||||||
|
@ -863,11 +864,11 @@ static void add_send_request(struct object *obj, struct remote_lock *lock)
|
||||||
if (remote_dir_exists[obj->sha1[0]] == -1)
|
if (remote_dir_exists[obj->sha1[0]] == -1)
|
||||||
get_remote_object_list(obj->sha1[0]);
|
get_remote_object_list(obj->sha1[0]);
|
||||||
if (obj->flags & (REMOTE | PUSHING))
|
if (obj->flags & (REMOTE | PUSHING))
|
||||||
return;
|
return 0;
|
||||||
target = find_sha1_pack(obj->sha1, remote->packs);
|
target = find_sha1_pack(obj->sha1, remote->packs);
|
||||||
if (target) {
|
if (target) {
|
||||||
obj->flags |= REMOTE;
|
obj->flags |= REMOTE;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->flags |= PUSHING;
|
obj->flags |= PUSHING;
|
||||||
|
@ -884,6 +885,8 @@ static void add_send_request(struct object *obj, struct remote_lock *lock)
|
||||||
|
|
||||||
fill_active_slots();
|
fill_active_slots();
|
||||||
step_active_slots();
|
step_active_slots();
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fetch_index(unsigned char *sha1)
|
static int fetch_index(unsigned char *sha1)
|
||||||
|
@ -901,8 +904,8 @@ static int fetch_index(unsigned char *sha1)
|
||||||
struct slot_results results;
|
struct slot_results results;
|
||||||
|
|
||||||
/* Don't use the index if the pack isn't there */
|
/* Don't use the index if the pack isn't there */
|
||||||
url = xmalloc(strlen(remote->url) + 65);
|
url = xmalloc(strlen(remote->url) + 64);
|
||||||
sprintf(url, "%s/objects/pack/pack-%s.pack", remote->url, hex);
|
sprintf(url, "%sobjects/pack/pack-%s.pack", remote->url, hex);
|
||||||
slot = get_active_slot();
|
slot = get_active_slot();
|
||||||
slot->results = &results;
|
slot->results = &results;
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
|
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
|
||||||
|
@ -924,7 +927,7 @@ static int fetch_index(unsigned char *sha1)
|
||||||
if (push_verbosely)
|
if (push_verbosely)
|
||||||
fprintf(stderr, "Getting index for pack %s\n", hex);
|
fprintf(stderr, "Getting index for pack %s\n", hex);
|
||||||
|
|
||||||
sprintf(url, "%s/objects/pack/pack-%s.idx", remote->url, hex);
|
sprintf(url, "%sobjects/pack/pack-%s.idx", remote->url, hex);
|
||||||
|
|
||||||
filename = sha1_pack_index_name(sha1);
|
filename = sha1_pack_index_name(sha1);
|
||||||
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
|
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
|
||||||
|
@ -1009,8 +1012,8 @@ static int fetch_indices(void)
|
||||||
if (push_verbosely)
|
if (push_verbosely)
|
||||||
fprintf(stderr, "Getting pack list\n");
|
fprintf(stderr, "Getting pack list\n");
|
||||||
|
|
||||||
url = xmalloc(strlen(remote->url) + 21);
|
url = xmalloc(strlen(remote->url) + 20);
|
||||||
sprintf(url, "%s/objects/info/packs", remote->url);
|
sprintf(url, "%sobjects/info/packs", remote->url);
|
||||||
|
|
||||||
slot = get_active_slot();
|
slot = get_active_slot();
|
||||||
slot->results = &results;
|
slot->results = &results;
|
||||||
|
@ -1298,7 +1301,7 @@ static struct remote_lock *lock_remote(char *path, long timeout)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unable to start request\n");
|
fprintf(stderr, "Unable to start MKCOL request\n");
|
||||||
free(url);
|
free(url);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1359,7 +1362,7 @@ static struct remote_lock *lock_remote(char *path, long timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unable to start request\n");
|
fprintf(stderr, "Unable to start LOCK request\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_slist_free_all(dav_headers);
|
curl_slist_free_all(dav_headers);
|
||||||
|
@ -1673,7 +1676,7 @@ static int locking_available(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unable to start request\n");
|
fprintf(stderr, "Unable to start PROPFIND request\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(out_data);
|
free(out_data);
|
||||||
|
@ -1734,16 +1737,17 @@ static struct object_list **process_tree(struct tree *tree,
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_delta(struct rev_info *revs, struct remote_lock *lock)
|
static int get_delta(struct rev_info *revs, struct remote_lock *lock)
|
||||||
{
|
{
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
struct object_list **p = &objects, *pending;
|
struct object_list **p = &objects, *pending;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
while ((commit = get_revision(revs)) != NULL) {
|
while ((commit = get_revision(revs)) != NULL) {
|
||||||
p = process_tree(commit->tree, p, NULL, "");
|
p = process_tree(commit->tree, p, NULL, "");
|
||||||
commit->object.flags |= LOCAL;
|
commit->object.flags |= LOCAL;
|
||||||
if (!(commit->object.flags & UNINTERESTING))
|
if (!(commit->object.flags & UNINTERESTING))
|
||||||
add_send_request(&commit->object, lock);
|
count += add_send_request(&commit->object, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pending = revs->pending_objects; pending; pending = pending->next) {
|
for (pending = revs->pending_objects; pending; pending = pending->next) {
|
||||||
|
@ -1770,9 +1774,11 @@ static void get_delta(struct rev_info *revs, struct remote_lock *lock)
|
||||||
|
|
||||||
while (objects) {
|
while (objects) {
|
||||||
if (!(objects->item->flags & UNINTERESTING))
|
if (!(objects->item->flags & UNINTERESTING))
|
||||||
add_send_request(objects->item, lock);
|
count += add_send_request(objects->item, lock);
|
||||||
objects = objects->next;
|
objects = objects->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int update_remote(unsigned char *sha1, struct remote_lock *lock)
|
static int update_remote(unsigned char *sha1, struct remote_lock *lock)
|
||||||
|
@ -2106,6 +2112,7 @@ int main(int argc, char **argv)
|
||||||
struct remote_lock *ref_lock = NULL;
|
struct remote_lock *ref_lock = NULL;
|
||||||
struct remote_lock *info_ref_lock = NULL;
|
struct remote_lock *info_ref_lock = NULL;
|
||||||
struct rev_info revs;
|
struct rev_info revs;
|
||||||
|
int objects_to_send;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -2197,7 +2204,6 @@ int main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
int new_refs = 0;
|
int new_refs = 0;
|
||||||
struct ref *ref;
|
struct ref *ref;
|
||||||
for (ref = remote_refs; ref; ref = ref->next) {
|
for (ref = remote_refs; ref; ref = ref->next) {
|
||||||
|
@ -2229,14 +2235,14 @@ int main(int argc, char **argv)
|
||||||
"need to pull first?",
|
"need to pull first?",
|
||||||
ref->name,
|
ref->name,
|
||||||
ref->peer_ref->name);
|
ref->peer_ref->name);
|
||||||
ret = -2;
|
rc = -2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
|
memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
|
||||||
if (is_zero_sha1(ref->new_sha1)) {
|
if (is_zero_sha1(ref->new_sha1)) {
|
||||||
error("cannot happen anymore");
|
error("cannot happen anymore");
|
||||||
ret = -3;
|
rc = -3;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
new_refs++;
|
new_refs++;
|
||||||
|
@ -2283,12 +2289,15 @@ int main(int argc, char **argv)
|
||||||
pushing = 0;
|
pushing = 0;
|
||||||
prepare_revision_walk(&revs);
|
prepare_revision_walk(&revs);
|
||||||
mark_edges_uninteresting(revs.commits);
|
mark_edges_uninteresting(revs.commits);
|
||||||
get_delta(&revs, ref_lock);
|
objects_to_send = get_delta(&revs, ref_lock);
|
||||||
finish_all_active_slots();
|
finish_all_active_slots();
|
||||||
|
|
||||||
/* Push missing objects to remote, this would be a
|
/* Push missing objects to remote, this would be a
|
||||||
convenient time to pack them first if appropriate. */
|
convenient time to pack them first if appropriate. */
|
||||||
pushing = 1;
|
pushing = 1;
|
||||||
|
if (objects_to_send)
|
||||||
|
fprintf(stderr, " sending %d objects\n",
|
||||||
|
objects_to_send);
|
||||||
fill_active_slots();
|
fill_active_slots();
|
||||||
finish_all_active_slots();
|
finish_all_active_slots();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue