[PATCH 05/13] url-parse: enumerate possible URL components
- From
Matheus Afonso Martins Moreira via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Apr 28, 2024, 22:30 UTC
- Message-ID
- <0bf83ee1228130df6069206190b97f1d0329794e.1714343461.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1715.git.git.1714343461.gitgitgadget@gmail.com>
From: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Create an enumeration containing all possible git URL components which may be selected by the user. The URL_NONE component is used when the user did not request the parsing of any component. In this case, the command will return successfully if the URL parses.
Signed-off-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com> --- builtin/url-parse.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/builtin/url-parse.c b/builtin/url-parse.c index 933e63aaa0a..d250338422e 100644 --- a/builtin/url-parse.c +++ b/builtin/url-parse.c @@ -13,6 +13,16 @@ #include "gettext.h" #include "urlmatch.h" +enum url_component { + URL_NONE = 0, + URL_PROTOCOL, + URL_USER, + URL_PASSWORD, + URL_HOST, + URL_PORT, + URL_PATH, +}; + static void parse_or_die(const char *url, struct url_info *info) { if (url_parse(url, info)) {
-- gitgitgadget