Move push matching and reporting logic into transport.c
For native-protocol pushes (and other protocols as they are converted
to the new method), this moves the refspec match, tracking update, and
report message out of send-pack() and into transport_push(), where it
can be shared completely with other protocols. This also makes fetch
and push more similar in terms of what code is in what file.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Daniel Barkalow16 years agocommitted byJunio C Hamano
" --all and explicit <ref> specification are mutually exclusive.";
static struct send_pack_args args = {
/* .receivepack = */ "git-receive-pack",
};
static int feed_object(const unsigned char *sha1, int fd, int negative)
@ -31,7 +30,7 @@ static int feed_object(const unsigned char *sha1, int fd, int negative)
@@ -31,7 +30,7 @@ static int feed_object(const unsigned char *sha1, int fd, int negative)
/*
* Make a pack stream and spit it out into file descriptor fd
*/
static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *extra)
@ -422,7 +425,7 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
@@ -422,7 +425,7 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
return !!err;
}
static struct ref *get_refs_via_curl(struct transport *transport)
static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
{
struct strbuf buffer = STRBUF_INIT;
char *data, *start, *mid;
@ -439,6 +442,9 @@ static struct ref *get_refs_via_curl(struct transport *transport)
@@ -439,6 +442,9 @@ static struct ref *get_refs_via_curl(struct transport *transport)
static int set_git_option(struct transport *connection,
@ -602,20 +612,23 @@ static int set_git_option(struct transport *connection,
@@ -602,20 +612,23 @@ static int set_git_option(struct transport *connection,
return 1;
}
static int connect_setup(struct transport *transport)
static int connect_setup(struct transport *transport, int for_push, int verbose)
@ -647,7 +660,7 @@ static int fetch_refs_via_pack(struct transport *transport,
@@ -647,7 +660,7 @@ static int fetch_refs_via_pack(struct transport *transport,
@ -670,20 +683,216 @@ static int fetch_refs_via_pack(struct transport *transport,
@@ -670,20 +683,216 @@ static int fetch_refs_via_pack(struct transport *transport,
return (refs ? 0 : -1);
}
static int git_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags)
static int refs_pushed(struct ref *ref)
{
for (; ref; ref = ref->next) {
switch(ref->status) {
case REF_STATUS_NONE:
case REF_STATUS_UPTODATE:
break;
default:
return 1;
}
}
return 0;
}
static void update_tracking_ref(struct remote *remote, struct ref *ref, int verbose)
{
struct refspec rs;
if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
return;
rs.src = ref->name;
rs.dst = NULL;
if (!remote_find_tracking(remote, &rs)) {
if (verbose)
fprintf(stderr, "updating local tracking ref '%s'\n", rs.dst);