Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
http-push: cleanup
author
Nick Hengeveld
<nickh@reactrix.com>
Sat, 11 Mar 2006 04:18:33 +0000
(20:18 -0800)
committer
Junio C Hamano
<junkio@cox.net>
Sat, 11 Mar 2006 07:01:56 +0000
(23:01 -0800)
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>
http-push.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
197e895
)
diff --git
a/http-push.c
b/http-push.c
index 93a50b4444e3bba210f6879795979d0894ad5aaf..42b0d59e8c15dff0d72b0d3a486d0248bd767dfe 100644
(file)
--- a/
http-push.c
+++ b/
http-push.c
@@
-11,7
+11,7
@@
#include <expat.h>
static const char http_push_usage[] =
#include <expat.h>
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
enum XML_Status {
#ifndef XML_STATUS_OK
enum XML_Status {
@@
-707,8
+707,9
@@
static void finish_request(struct transfer_request *request)
}
} else if (request->state == RUN_MOVE) {
if (request->curl_result == CURLE_OK) {
}
} else if (request->state == RUN_MOVE) {
if (request->curl_result == CURLE_OK) {
- fprintf(stderr, " sent %s\n",
- sha1_to_hex(request->obj->sha1));
+ if (push_verbosely)
+ fprintf(stderr, " sent %s\n",
+ sha1_to_hex(request->obj->sha1));
request->obj->flags |= REMOTE;
release_request(request);
} else {
request->obj->flags |= REMOTE;
release_request(request);
} else {
@@
-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 packed_git *target;
{
struct transfer_request *request = request_queue_head;
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)
get_remote_object_list(obj->sha1[0]);
if (obj->flags & (REMOTE | PUSHING))
if (remote_dir_exists[obj->sha1[0]] == -1)
get_remote_object_list(obj->sha1[0]);
if (obj->flags & (REMOTE | PUSHING))
- return;
+ return
0
;
target = find_sha1_pack(obj->sha1, remote->packs);
if (target) {
obj->flags |= REMOTE;
target = find_sha1_pack(obj->sha1, remote->packs);
if (target) {
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();
step_active_slots();
fill_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;
/* Don't use the index if the pack isn't there */
struct slot_results results;
/* Don't use the index if the pack isn't there */
- url = xmalloc(strlen(remote->url) + 6
5
);
- sprintf(url, "%s
/
objects/pack/pack-%s.pack", remote->url, hex);
+ url = xmalloc(strlen(remote->url) + 6
4
);
+ sprintf(url, "%sobjects/pack/pack-%s.pack", remote->url, hex);
slot = get_active_slot();
slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
slot = get_active_slot();
slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_URL, url);
@@
-923,9
+926,9
@@
static int fetch_index(unsigned char *sha1)
if (push_verbosely)
fprintf(stderr, "Getting index for pack %s\n", hex);
if (push_verbosely)
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);
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
indexfile = fopen(tmpfile, "a");
filename = sha1_pack_index_name(sha1);
snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename);
indexfile = fopen(tmpfile, "a");
@@
-1008,9
+1011,9
@@
static int fetch_indices(void)
if (push_verbosely)
fprintf(stderr, "Getting pack list\n");
if (push_verbosely)
fprintf(stderr, "Getting pack list\n");
-
- url = xmalloc(strlen(remote->url) + 2
1
);
- sprintf(url, "%s
/
objects/info/packs", remote->url);
+
+ url = xmalloc(strlen(remote->url) + 2
0
);
+ sprintf(url, "%sobjects/info/packs", remote->url);
slot = get_active_slot();
slot->results = &results;
slot = get_active_slot();
slot->results = &results;
@@
-1298,7
+1301,7
@@
static struct remote_lock *lock_remote(char *path, long timeout)
return NULL;
}
} else {
return NULL;
}
} else {
- fprintf(stderr, "Unable to start request\n");
+ fprintf(stderr, "Unable to start
MKCOL
request\n");
free(url);
return NULL;
}
free(url);
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 object_list **p = &objects, *pending;
{
struct commit *commit;
struct object_list **p = &objects, *pending;
+ int count = 0;
while ((commit = get_revision(revs)) != NULL) {
p = process_tree(commit->tree, p, NULL, "");
commit->object.flags |= LOCAL;
if (!(commit->object.flags & UNINTERESTING))
while ((commit = get_revision(revs)) != NULL) {
p = process_tree(commit->tree, p, NULL, "");
commit->object.flags |= LOCAL;
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) {
if (!(objects->item->flags & UNINTERESTING))
while (objects) {
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 *info_ref_lock = NULL;
struct rev_info revs;
struct remote_lock *ref_lock = NULL;
struct remote_lock *info_ref_lock = NULL;
struct rev_info revs;
+ int objects_to_send;
int rc = 0;
int i;
int rc = 0;
int i;
@@
-2197,7
+2204,6
@@
int main(int argc, char **argv)
return 0;
}
return 0;
}
- int ret = 0;
int new_refs = 0;
struct ref *ref;
for (ref = remote_refs; ref; ref = ref->next) {
int new_refs = 0;
struct ref *ref;
for (ref = remote_refs; ref; ref = ref->next) {
@@
-2229,14
+2235,14
@@
int main(int argc, char **argv)
"need to pull first?",
ref->name,
ref->peer_ref->name);
"need to pull first?",
ref->name,
ref->peer_ref->name);
- r
et
= -2;
+ r
c
= -2;
continue;
}
}
memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
if (is_zero_sha1(ref->new_sha1)) {
error("cannot happen anymore");
continue;
}
}
memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
if (is_zero_sha1(ref->new_sha1)) {
error("cannot happen anymore");
- r
et
= -3;
+ r
c
= -3;
continue;
}
new_refs++;
continue;
}
new_refs++;
@@
-2283,12
+2289,15
@@
int main(int argc, char **argv)
pushing = 0;
prepare_revision_walk(&revs);
mark_edges_uninteresting(revs.commits);
pushing = 0;
prepare_revision_walk(&revs);
mark_edges_uninteresting(revs.commits);
- get_delta(&revs, ref_lock);
+
objects_to_send =
get_delta(&revs, ref_lock);
finish_all_active_slots();
/* Push missing objects to remote, this would be a
convenient time to pack them first if appropriate. */
pushing = 1;
finish_all_active_slots();
/* Push missing objects to remote, this would be a
convenient time to pack them first if appropriate. */
pushing = 1;
+ if (objects_to_send)
+ fprintf(stderr, " sending %d objects\n",
+ objects_to_send);
fill_active_slots();
finish_all_active_slots();
fill_active_slots();
finish_all_active_slots();