Thread (329 messages) 329 messages, 12 authors, 2018-03-14

Re: [PATCH v3 19/35] push: pass ref patterns when pushing

From: Stefan Beller <hidden>
Date: 2018-02-27 18:23:09

On Tue, Feb 6, 2018 at 5:12 PM, Brandon Williams [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Construct a list of ref patterns to be passed to 'get_refs_list()' from
the refspec to be used during the push.  This list of ref patterns will
be used to allow the server to filter the ref advertisement when
communicating using protocol v2.

Signed-off-by: Brandon Williams <redacted>
---
 transport.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/transport.c b/transport.c
index dfc603b36..6ea3905e3 100644
--- a/transport.c
+++ b/transport.c
@@ -1026,11 +1026,26 @@ int transport_push(struct transport *transport,
                int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
                int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
                int push_ret, ret, err;
+               struct refspec *tmp_rs;
+               struct argv_array ref_patterns = ARGV_ARRAY_INIT;
+               int i;

                if (check_push_refs(local_refs, refspec_nr, refspec) < 0)
                        return -1;

-               remote_refs = transport->vtable->get_refs_list(transport, 1, NULL);
+               tmp_rs = parse_push_refspec(refspec_nr, refspec);
+               for (i = 0; i < refspec_nr; i++) {
+                       if (tmp_rs[i].dst)
+                               argv_array_push(&ref_patterns, tmp_rs[i].dst);
+                       else if (tmp_rs[i].src && !tmp_rs[i].exact_sha1)
+                               argv_array_push(&ref_patterns, tmp_rs[i].src);
else /* !tmp_rs[i].dst && (!tmp_rs[i].src || tmp_rs[i].exact_sha1)

I would think the case of !dst && !src cannot happen, as then there is
no refspec, but what about the !!exact_sha1 case ?

I'd think that is something like

    git push origin $(git rev-parse HEAD)

for which I'd think we'd bail out anyway?
But that would happen at a different place, here we can ignore
the exact hashes for listing refs purposes.

Can you add a comment or rather explain in the commit
message to make this less confusing?

Stefan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help