submodule--helper: convert push_check to use struct refspec
authorBrandon Williams <bmwill@google.com>
Wed, 16 May 2018 22:57:53 +0000 (15:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 May 2018 21:19:42 +0000 (06:19 +0900)
Convert 'push_check()' to use 'struct refspec'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
index c0c4db00736597eca7c264f70b0fc82c0246ce53..88a149a2c3846cb0dc103de62a72d256e282e566 100644 (file)
@@ -1744,13 +1744,14 @@ static int push_check(int argc, const char **argv, const char *prefix)
 
        /* Check the refspec */
        if (argc > 2) {
-               int i, refspec_nr = argc - 2;
+               int i;
                struct ref *local_refs = get_local_heads();
-               struct refspec_item *refspec = parse_push_refspec(refspec_nr,
-                                                            argv + 2);
+               struct refspec refspec = REFSPEC_INIT_PUSH;
 
-               for (i = 0; i < refspec_nr; i++) {
-                       struct refspec_item *rs = refspec + i;
+               refspec_appendn(&refspec, argv + 2, argc - 2);
+
+               for (i = 0; i < refspec.nr; i++) {
+                       const struct refspec_item *rs = &refspec.items[i];
 
                        if (rs->pattern || rs->matching)
                                continue;
@@ -1777,7 +1778,7 @@ static int push_check(int argc, const char **argv, const char *prefix)
                                    rs->src);
                        }
                }
-               free_refspec(refspec_nr, refspec);
+               refspec_clear(&refspec);
        }
        free(head);