diff mbox series

[10/13] url-parse: validate all given git URLs

Message ID 15d355a43cbedc16f420066e50e02041c8e1626d.1714343461.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series builtin: implement, document and test url-parse | expand

Commit Message

Matheus Afonso Martins Moreira April 28, 2024, 10:30 p.m. UTC
From: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>

Parse all the git URLs given as input on the command line.
Die if an URL cannot be parsed.

Signed-off-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
---
 builtin/url-parse.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/builtin/url-parse.c b/builtin/url-parse.c
index 03030035b4f..ab996eadf38 100644
--- a/builtin/url-parse.c
+++ b/builtin/url-parse.c
@@ -101,10 +101,18 @@  static char *extract(enum url_component component, struct url_info *info)
 
 int cmd_url_parse(int argc, const char **argv, const char *prefix)
 {
+	struct url_info info;
+	int i;
+
 	argc = parse_options(argc, argv, prefix,
 		builtin_url_parse_options,
 		builtin_url_parse_usage,
 		0);
 
+	for (i = 0; i < argc; ++i) {
+		parse_or_die(argv[i], &info);
+		free(info.url);
+	}
+
 	return 0;
 }