set_ref_status_for_push(): use transport-flags abstraction
PATCH 1/2 set_ref_status_for_push(): use transport-flags abstraction
It does not make much sense to have separate "int" parameters to this function with two callsites (why do we need to to begin with? but that is a separate issue) and having to update them every time we need to touch it.
Consolidate them into a single "flags" parameter to make it easier to extend later.
Signed-off-by Junio C Hamano <[email protected]>
---
* A preparatory step for the next one
builtin/send-pack.c | 10 ++++++++-- remote.c | 6 ++++-- remote.h | 3 +-- transport.c | 4 +--- 4 files changed, 14 insertions(+), 9 deletions(-)
builtin/send-pack.c +8 -2
@@ -404,6 +404,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)int send_all =0 ;const char *receivepack ="git-receive-pack" ;int flags; +unsigned transport_flags;int nonfastforward =0 ; argv++;
@@ -512,8 +513,13 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)if (match_push_refs (local_refs, &remote_refs, nr_refspecs, refspecs, flags))return -1 ; -set_ref_status_for_push (remote_refs, args.send_mirror, - args.force_update); + transport_flags =0 ; +if (args.send_mirror) + transport_flags |=TRANSPORT_PUSH_MIRROR ; +if (args.force_update) + transport_flags |=TRANSPORT_PUSH_FORCE ; + +set_ref_status_for_push (remote_refs, transport_flags); ret =send_pack (&args, fd, conn, remote_refs, &extra_have);
remote.c +4 -2
@@ -7,6 +7,7 @@#include "dir.h" #include "tag.h" #include "string-list.h" +#include "transport.h" static struct refspec s_tag_refspec = {0 ,
@@ -1223,10 +1224,11 @@ int match_push_refs(struct ref *src, struct ref **dst,return 0 ; } -void set_ref_status_for_push (struct ref *remote_refs,int send_mirror, -int force_update) +void set_ref_status_for_push (struct ref *remote_refs,unsigned flags) {struct ref *ref; +int send_mirror = flags &TRANSPORT_PUSH_MIRROR ; +int force_update = flags &TRANSPORT_PUSH_FORCE ;for (ref = remote_refs; ref; ref = ref->next) {if (ref->peer_ref)
remote.h +1 -2
@@ -98,8 +98,7 @@ char *apply_refspecs(struct refspec *refspecs, int nr_refspec,int match_push_refs (struct ref *src,struct ref **dst,int nr_refspec,const char **refspec,int all); -void set_ref_status_for_push (struct ref *remote_refs,int send_mirror, -int force_update); +void set_ref_status_for_push (struct ref *remote_refs,unsigned flags);/* * Given a list of the remote refs and the specification of things to
transport.c +1 -3
@@ -1031,9 +1031,7 @@ int transport_push(struct transport *transport,return -1 ; } -set_ref_status_for_push (remote_refs, - flags &TRANSPORT_PUSH_MIRROR , - flags &TRANSPORT_PUSH_FORCE ); +set_ref_status_for_push (remote_refs, flags);if ((flags &TRANSPORT_RECURSE_SUBMODULES_CHECK ) && !is_bare_repository ()) {struct ref *ref = remote_refs;
Signature · 1 line
1.7.8.249.gb1b73
Quoted 2 lines · Junio C Hamano
It does not make much sense to have separate "int" parameters to this function with two callsites (why do we need to to begin with?
This last bit should read:
"Why do we need two to begin with?"
Kindly,
-- Thomas Adam