{"thread":{"id":"29155","subject":"[PATCH 1/2] set_ref_status_for_push(): use transport-flags abstraction","startedAt":"2011-12-13T23:26:31Z","lastAt":"2011-12-14T10:32:17Z","messageCount":2,"participants":["Junio C Hamano","Thomas Adam"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"181096","messageId":"7vsjkot5nc.fsf@alter.siamese.dyndns.org","threadId":"29155","inReplyTo":null,"subject":"[PATCH 1/2] set_ref_status_for_push(): use transport-flags abstraction","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-13T23:26:31Z","receivedAt":"2011-12-13T23:26:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It does not make much sense to have separate \"int\" parameters to\nthis function with two callsites (why do we need to to begin with?\nbut that is a separate issue) and having to update them every time\nwe need to touch it.\n\nConsolidate them into a single \"flags\" parameter to make it easier\nto extend later.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * A preparatory step for the next one\n\n builtin/send-pack.c |   10 ++++++++--\n remote.c            |    6 ++++--\n remote.h            |    3 +--\n transport.c         |    4 +---\n 4 files changed, 14 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex e0b8030..ec107ed 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -404,6 +404,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \tint send_all = 0;\n \tconst char *receivepack = \"git-receive-pack\";\n \tint flags;\n+\tunsigned transport_flags;\n \tint nonfastforward = 0;\n \n \targv++;\n@@ -512,8 +513,13 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)\n \tif (match_push_refs(local_refs, &remote_refs, nr_refspecs, refspecs, flags))\n \t\treturn -1;\n \n-\tset_ref_status_for_push(remote_refs, args.send_mirror,\n-\t\targs.force_update);\n+\ttransport_flags = 0;\n+\tif (args.send_mirror)\n+\t\ttransport_flags |= TRANSPORT_PUSH_MIRROR;\n+\tif (args.force_update)\n+\t\ttransport_flags |= TRANSPORT_PUSH_FORCE;\n+\n+\tset_ref_status_for_push(remote_refs, transport_flags);\n \n \tret = send_pack(&args, fd, conn, remote_refs, &extra_have);\n \ndiff --git a/remote.c b/remote.c\nindex 6655bb0..95d7f37 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -7,6 +7,7 @@\n #include \"dir.h\"\n #include \"tag.h\"\n #include \"string-list.h\"\n+#include \"transport.h\"\n \n static struct refspec s_tag_refspec = {\n \t0,\n@@ -1223,10 +1224,11 @@ int match_push_refs(struct ref *src, struct ref **dst,\n \treturn 0;\n }\n \n-void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n-\tint force_update)\n+void set_ref_status_for_push(struct ref *remote_refs, unsigned flags)\n {\n \tstruct ref *ref;\n+\tint send_mirror = flags & TRANSPORT_PUSH_MIRROR;\n+\tint force_update = flags & TRANSPORT_PUSH_FORCE;\n \n \tfor (ref = remote_refs; ref; ref = ref->next) {\n \t\tif (ref->peer_ref)\ndiff --git a/remote.h b/remote.h\nindex b395598..0cf3c07 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -98,8 +98,7 @@ char *apply_refspecs(struct refspec *refspecs, int nr_refspec,\n \n int match_push_refs(struct ref *src, struct ref **dst,\n \t\t    int nr_refspec, const char **refspec, int all);\n-void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n-\tint force_update);\n+void set_ref_status_for_push(struct ref *remote_refs, unsigned flags);\n \n /*\n  * Given a list of the remote refs and the specification of things to\ndiff --git a/transport.c b/transport.c\nindex 51814b5..95556da 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -1031,9 +1031,7 @@ int transport_push(struct transport *transport,\n \t\t\treturn -1;\n \t\t}\n \n-\t\tset_ref_status_for_push(remote_refs,\n-\t\t\tflags & TRANSPORT_PUSH_MIRROR,\n-\t\t\tflags & TRANSPORT_PUSH_FORCE);\n+\t\tset_ref_status_for_push(remote_refs, flags);\n \n \t\tif ((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) && !is_bare_repository()) {\n \t\t\tstruct ref *ref = remote_refs;\n-- \n1.7.8.249.gb1b73\n"},{"id":"181126","messageId":"CA+39Oz55Ag5c7pfDYpHixk0=UdwuWfRMc+k3uC40jabUpynDXg@mail.gmail.com","threadId":"29155","inReplyTo":"7vsjkot5nc.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/2] set_ref_status_for_push(): use transport-flags abstraction","fromName":"Thomas Adam","fromEmail":"thomas@xteddy.org","sentAt":"2011-12-14T10:32:17Z","receivedAt":"2011-12-14T10:32:17Z","isPatch":true,"sender":{"key":"thomas@xteddy.org","avatar":"https://gravatar.com/avatar/e7256db4738e501e5d2e84f00bb0bd99503165729573848a03330301fc2adc4a?d=mp&s=160"},"body":"On 13 December 2011 23:26, Junio C Hamano <gitster@pobox.com> wrote:\n> It does not make much sense to have separate \"int\" parameters to\n> this function with two callsites (why do we need to to begin with?\n\nThis last bit should read:\n\n\"Why do we need two to begin with?\"\n\nKindly,\n\n-- Thomas Adam\n"}]}