From ec0cb496553ac82f97205a415ca77618406b30e3 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 16 May 2018 15:57:48 -0700 Subject: refspec: move refspec parsing logic into its own file In preparation for performing a refactor on refspec related code, move the refspec parsing logic into its own file. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin/submodule--helper.c') diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index c2403a915f..6ab032acb1 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -12,6 +12,7 @@ #include "run-command.h" #include "remote.h" #include "refs.h" +#include "refspec.h" #include "connect.h" #include "revision.h" #include "diffcore.h" -- cgit v1.2.3 From 0ad4a5ff50dbc839ae26aa60c03b55bf416b6000 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 16 May 2018 15:57:49 -0700 Subject: refspec: rename struct refspec to struct refspec_item In preparation for introducing an abstraction around a collection of refspecs (much like how a 'struct pathspec' is a collection of 'struct pathspec_item's) rename the existing 'struct refspec' to 'struct refspec_item'. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/submodule--helper.c') diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 6ab032acb1..c0c4db0073 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1746,11 +1746,11 @@ static int push_check(int argc, const char **argv, const char *prefix) if (argc > 2) { int i, refspec_nr = argc - 2; struct ref *local_refs = get_local_heads(); - struct refspec *refspec = parse_push_refspec(refspec_nr, + struct refspec_item *refspec = parse_push_refspec(refspec_nr, argv + 2); for (i = 0; i < refspec_nr; i++) { - struct refspec *rs = refspec + i; + struct refspec_item *rs = refspec + i; if (rs->pattern || rs->matching) continue; -- cgit v1.2.3 From 9c8361b289dea10dcb8d2f0cd7c95840340455dd Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Wed, 16 May 2018 15:57:53 -0700 Subject: submodule--helper: convert push_check to use struct refspec Convert 'push_check()' to use 'struct refspec'. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'builtin/submodule--helper.c') diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index c0c4db0073..88a149a2c3 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -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); -- cgit v1.2.3