From patchwork Sun Apr 28 22:30:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646141 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D21D4411 for ; Sun, 28 Apr 2024 22:31:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343467; cv=none; b=I08rwr+2DO1WRvGlxFp8HTST5NuWTxRFYY/h7FEfogdG2BFTYJASN+h7QI+i2arOqFHA74a0OYk6wvXG3v+tZx4/RCQg7liPQxobm7rWKJK86KK7rs+sthVdlGG0DQs9m8mc8FQMXBK7WuvxRqbxBwseu9ZCYhJcjuqT3cyiF64= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343467; c=relaxed/simple; bh=e1VdIs0x1zqylEX+ZJoRXEypXAHuc/PAxev/iCDL48M=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=rscWC357aVuXo2+AHzMI6vHe7qsmSI2V1KSAK1+xZufEo2yiArRc62Zwd61dVZtxJ8nGoblbRNU02QfVh/P7IK3Kwx39fbDT7DvACaLsQJJbhJozZERKBBHpFMIMQgl+eoRmROInE5TATBmT6SrXPoyB3Nk4lRheu6eKlQD8SFU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dNHkEEXG; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dNHkEEXG" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-346406a5fb9so3291028f8f.1 for ; Sun, 28 Apr 2024 15:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343464; x=1714948264; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=aqAWfie3RQGeBBg1kL6q7Vb50rUPGbPDDp8b3lM21Yc=; b=dNHkEEXGuJb0sMd8qjoTvBnAm9PRf07dopyXvaX+/jla86RstwZwP3/JGPV2YERp+p 4frNUAauJfNe6YKBCECxU9veOj6jWHlr66FE7kkaZU/rpTpomylY4poOuW+wxCGnl00p bPQf8R31BZi44uH7oywv+UW2D8dZGJ1TJC7wOwbesOMwr/KvWw4bSt3ugkVbK89D3S0t jBX9mi+GTJbBVReNnvogRz81DU0fD1WzGHqiqGdhmDWMywHz711iNqPR3lJ5aIAs9VwI Heb/QTYPPhkOgLtu0v0ybsw/3UNSIdU/TJcDfhMOSIXVd/vQrBKMWTKYwXiNNUaVOu8q zxWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343464; x=1714948264; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aqAWfie3RQGeBBg1kL6q7Vb50rUPGbPDDp8b3lM21Yc=; b=U0NCvr5Vjm5eGivnwobMEcKgoD58xMizZaFI52g/hhNKfVTFpZeOW0Jc1BiYdEBaEi T61qYjsyYEgpHccRzCJQ/z1w2HeKR8+awbJf4qOP2dgX42vc50AKWU828ZR3vjUnwRor zhfSguEbf/a+2MQphxksRHFOmDnSkkzsvyOfnywq8Yrqa+0QRLg2fqQrsH0ne9dZrIj7 W09Zy6A8MFN1O7ZawE0CJnAaXPesl1kl0bDM1+I/uS4U1uqa77SVXP8DyWeBSqpFCLaV uXqJVWAz0jmaNjQN1Y5muTgf78fQVGOmtSaH9y/M4MtCzOl/XplJHRN09blwwca2synH +v4A== X-Gm-Message-State: AOJu0Ywi4Z9v9B5U5UfSoNElIgpEDMhwPAug+Sn0h3FPCzwqc1UEzkGn +tSUZ+iHLHwBaMloexRue1yR8pM3HGxxeb3FauSVpm4ToD9PRpbpaD+HcA== X-Google-Smtp-Source: AGHT+IG0G4fGqKw+58kwRdcIzTLgnAqhQ76mCTR6CYxKBvRT5iKoWmgOH3Ehk1gs3jlve8RWsVeONg== X-Received: by 2002:adf:e90a:0:b0:34c:601b:1083 with SMTP id f10-20020adfe90a000000b0034c601b1083mr4367202wrm.65.1714343463937; Sun, 28 Apr 2024 15:31:03 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g4-20020adff3c4000000b00343c1cd5aedsm27873803wrp.52.2024.04.28.15.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:03 -0700 (PDT) Message-Id: <42eb0cbf68a4f7ee46041687277d529fe981df6b.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:49 +0000 Subject: [PATCH 01/13] url: move helper function to URL header and source Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira It will be used in more places so it should be placed in url.h. Signed-off-by: Matheus Afonso Martins Moreira --- connect.c | 8 -------- connect.h | 1 - remote.c | 1 + url.c | 8 ++++++++ url.h | 2 ++ 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/connect.c b/connect.c index 0d77737a536..0cd9439501b 100644 --- a/connect.c +++ b/connect.c @@ -693,14 +693,6 @@ enum protocol { PROTO_GIT }; -int url_is_local_not_ssh(const char *url) -{ - const char *colon = strchr(url, ':'); - const char *slash = strchr(url, '/'); - return !colon || (slash && slash < colon) || - (has_dos_drive_prefix(url) && is_valid_path(url)); -} - static const char *prot_name(enum protocol protocol) { switch (protocol) { diff --git a/connect.h b/connect.h index 1645126c17f..8d84f6656b1 100644 --- a/connect.h +++ b/connect.h @@ -13,7 +13,6 @@ int git_connection_is_socket(struct child_process *conn); int server_supports(const char *feature); int parse_feature_request(const char *features, const char *feature); const char *server_feature_value(const char *feature, size_t *len_ret); -int url_is_local_not_ssh(const char *url); struct packet_reader; enum protocol_version discover_version(struct packet_reader *reader); diff --git a/remote.c b/remote.c index 2b650b813b7..2425dbc4660 100644 --- a/remote.c +++ b/remote.c @@ -5,6 +5,7 @@ #include "gettext.h" #include "hex.h" #include "remote.h" +#include "url.h" #include "urlmatch.h" #include "refs.h" #include "refspec.h" diff --git a/url.c b/url.c index 282b12495ae..c36818c3037 100644 --- a/url.c +++ b/url.c @@ -119,3 +119,11 @@ void str_end_url_with_slash(const char *url, char **dest) free(*dest); *dest = strbuf_detach(&buf, NULL); } + +int url_is_local_not_ssh(const char *url) +{ + const char *colon = strchr(url, ':'); + const char *slash = strchr(url, '/'); + return !colon || (slash && slash < colon) || + (has_dos_drive_prefix(url) && is_valid_path(url)); +} diff --git a/url.h b/url.h index 2a27c342776..867d3af6691 100644 --- a/url.h +++ b/url.h @@ -21,4 +21,6 @@ char *url_decode_parameter_value(const char **query); void end_url_with_slash(struct strbuf *buf, const char *url); void str_end_url_with_slash(const char *url, char **dest); +int url_is_local_not_ssh(const char *url); + #endif /* URL_H */ From patchwork Sun Apr 28 22:30:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646142 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A604B676 for ; Sun, 28 Apr 2024 22:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343468; cv=none; b=n2UhOa8Uy6eD8lc0+8E+G0h0rp+OIG2x8sGa8GKOJKaI/LbSaBkGkCiI3tXnMSpKUVSiMUvPJttuFc26/MV/T234tdHQmJ5glvjwIannJ0d5MEWLwWy+ZEL6ypxCteVR7FzV5AOkbbZMQ9luWZIcVonPwXWfhIV24zlZHU8hT+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343468; c=relaxed/simple; bh=ZcZUn5zFaPW9YL/tD/2XoOuIlZG6UyMgqSh6qkEv8Z8=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=TTj4R7/gSW4GvrAoxDvoIiTyb3Ezk3XVWpIrlpeeDRfvuGVBMo69UgK8GKKdp2jkZQxyGM+BpWEyXyApFmZcEDK7UJxcFPIRvqYSA4e8hf44rJONIQRZyAgPRZxNLoCJM1NH4eD8fsNGBaXhnd3wX/xwMJP0+AKSCVjGOb3/vSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XHFWITwH; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XHFWITwH" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-41ba1ba55e8so17319145e9.1 for ; Sun, 28 Apr 2024 15:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343464; x=1714948264; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=liInQRHJsrHlb1bwMwRyD6EgSrZWZ0aVkEQS5W47Hoo=; b=XHFWITwHnzcG3MrSp7Cc+NM7FwHWfjtMWAw62zPkDJ+bLhZCGrnAOujRTqz9Rlp66d MxneoMY7jGyQEkCbh5l2r3E1LnhEnfN6yT53qjfp42x+l7AYkJm8JM/9idOSDUeie4y4 oGxPfTXdPrZuoycJUOLmQUEVyKHAiCh7rE8cR1zE0bUVVor2Eq2KOtk2M7aKU1fb4Kcd QY+0rRJGfq8gc1e6oftoZB3NlLu0PQwin811xK9rVw9t9PS2jca8zk4m8KJ15rDGSOBI Ss5ij3SoaWuE0EQ4pbqWY4ZWJT33zOW9vNMpDTgiBGsYqDYOJHBbzl7IhSYRYkJed/5L DOog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343464; x=1714948264; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=liInQRHJsrHlb1bwMwRyD6EgSrZWZ0aVkEQS5W47Hoo=; b=OjTuYxRJ6IXo7Qb7G96Za5LFBNUjxcqkyHgaa8cgzMsXK/EAiUYaodZA0HWCqePve4 Mw/Z9taesBo3Ez6nlKwj7dybl62ynoghOz3fROUe40k6o2z8hj8KcK3T+rX2x7WSUhvf AodtEvps61mt+uiEAmJGXIXcKKKCUSTr481Lj4uH51pgEaRZDM13vvNOOdhTiYu7FqpH CZuXXG2Y9seT9Z5ai7bjmnZstMD1c58NMjnKojiO2C1ASKoI1pMSx8RDEpQWkF4k83N4 C80kytbedLELkuSZA+R+L9WDImgXjfzXaAas69Gww8etkgGJILx/RbLCfaA/MEKof6Lr OAeA== X-Gm-Message-State: AOJu0YwXzuMeJwRkyIOSItmofaaUIDS1f7g2DbRZ7rUu3mm1RcR3Lwno vHY8LbRjoBAiVanren2Bo4w2nQpqwRy1CFg1aRhFKExezHoVUciqxBAD3Q== X-Google-Smtp-Source: AGHT+IEv4Ll7nHczZOQQawtSw3Gm9nk4mmwbBEEjzSmC65h95Y9+d6p3+aQmcNbK6/fB/mBCY2qxxA== X-Received: by 2002:a05:600c:4f08:b0:418:5ed2:5aa6 with SMTP id l8-20020a05600c4f0800b004185ed25aa6mr6701492wmq.31.1714343464586; Sun, 28 Apr 2024 15:31:04 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s8-20020a05600c45c800b0041be9cb540esm6027261wmo.18.2024.04.28.15.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:04 -0700 (PDT) Message-Id: <13b81b8aa06cfd63a5fd9d1acbaf21a8b388ff47.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:50 +0000 Subject: [PATCH 02/13] urlmatch: define url_parse function Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira Define general parsing function that supports all Git URLs including scp style URLs such as hostname:~user/repo. Has the same interface as the URL normalization function and uses the same data structures, facilitating its use. It's adapted from the algorithm used to process URLs in connect.c, so it should support the same inputs. Signed-off-by: Matheus Afonso Martins Moreira --- urlmatch.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ urlmatch.h | 1 + 2 files changed, 91 insertions(+) diff --git a/urlmatch.c b/urlmatch.c index 1d0254abacb..5a442e31fa2 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -3,6 +3,7 @@ #include "hex-ll.h" #include "strbuf.h" #include "urlmatch.h" +#include "url.h" #define URL_ALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" #define URL_DIGIT "0123456789" @@ -438,6 +439,95 @@ char *url_normalize(const char *url, struct url_info *out_info) return url_normalize_1(url, out_info, 0); } +enum protocol { + PROTO_UNKNOWN = 0, + PROTO_LOCAL, + PROTO_FILE, + PROTO_SSH, + PROTO_GIT, +}; + +static enum protocol url_get_protocol(const char *name, size_t n) +{ + if (!strncmp(name, "ssh", n)) + return PROTO_SSH; + if (!strncmp(name, "git", n)) + return PROTO_GIT; + if (!strncmp(name, "git+ssh", n)) /* deprecated - do not use */ + return PROTO_SSH; + if (!strncmp(name, "ssh+git", n)) /* deprecated - do not use */ + return PROTO_SSH; + if (!strncmp(name, "file", n)) + return PROTO_FILE; + return PROTO_UNKNOWN; +} + +char *url_parse(const char *url_orig, struct url_info *out_info) +{ + struct strbuf url; + char *host, *separator; + char *detached, *normalized; + enum protocol protocol = PROTO_LOCAL; + struct url_info local_info; + struct url_info *info = out_info? out_info : &local_info; + bool scp_syntax = false; + + if (is_url(url_orig)) { + url_orig = url_decode(url_orig); + } else { + url_orig = xstrdup(url_orig); + } + + strbuf_init(&url, strlen(url_orig) + sizeof("ssh://")); + strbuf_addstr(&url, url_orig); + + host = strstr(url.buf, "://"); + if (host) { + protocol = url_get_protocol(url.buf, host - url.buf); + host += 3; + } else { + if (!url_is_local_not_ssh(url.buf)) { + scp_syntax = true; + protocol = PROTO_SSH; + strbuf_insertstr(&url, 0, "ssh://"); + host = url.buf + 6; + } + } + + /* path starts after ':' in scp style SSH URLs */ + if (scp_syntax) { + separator = strchr(host, ':'); + if (separator) { + if (separator[1] == '/') + strbuf_remove(&url, separator - url.buf, 1); + else + *separator = '/'; + } + } + + detached = strbuf_detach(&url, NULL); + normalized = url_normalize(detached, info); + free(detached); + + if (!normalized) { + return NULL; + } + + /* point path to ~ for URL's like this: + * + * ssh://host.xz/~user/repo + * git://host.xz/~user/repo + * host.xz:~user/repo + * + */ + if (protocol == PROTO_GIT || protocol == PROTO_SSH) { + if (normalized[info->path_off + 1] == '~') + info->path_off++; + } + + return normalized; +} + static size_t url_match_prefix(const char *url, const char *url_prefix, size_t url_prefix_len) diff --git a/urlmatch.h b/urlmatch.h index 5ba85cea139..6b3ce428582 100644 --- a/urlmatch.h +++ b/urlmatch.h @@ -35,6 +35,7 @@ struct url_info { }; char *url_normalize(const char *, struct url_info *); +char *url_parse(const char *, struct url_info *); struct urlmatch_item { size_t hostmatch_len; From patchwork Sun Apr 28 22:30:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646143 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9393111BB for ; Sun, 28 Apr 2024 22:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343469; cv=none; b=Fs7mZrrmdWFEeD2iQujqoUC3PgatvAWDC3UoPkL9jdcqf72Nq8AHNJFZjjdhRqtAzmcKK9EtjNgdYMgSRE8BGXw5t1BvGp7ovKpcBuQcbOkAUhYxrULYIIRvCFknXC2lG7iKTOyQQLrSaSV3g3eKNBO1xplrJM7e94d9NUa9skg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343469; c=relaxed/simple; bh=YzF6nQgP7KUyHf9cAcLl8MWtV7azejRejAKM6N9aN+U=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=fv9iOmQ/u1FMF43d54MYn5swDH2f9sGT5LERpkWIIryywL9olsX04NM1QjkEIdCj+yp8kJ808zo9zMyy5p0jXV+kiMCUOIwxCBp6p91rp2wGLQfp22/Ybmj66ycuagiRQRLXdhGU7kwWYk/LD4KDlGs6MupLFMP591sJCv3/XrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N4co39wc; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N4co39wc" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-34c0f5f5cd0so3120623f8f.2 for ; Sun, 28 Apr 2024 15:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343466; x=1714948266; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=yzuacz24RkQLzVJk3LE2c4+sz1xjIlAMNjLoUa8zGSA=; b=N4co39wclxchVruokvb+UKpI2PhS6Hd4bYYRIvUFn0y+1Vga4HqWuSScHxgZC4RYIj Yws1i9a74CpeA9/mN/IP1YwoetYy4qlq1bOH4bFt/X7F7Bs3KueAsVE43qRZ0kkPhQIs TxCZZTFrFsNno6Xzfyz5T+ig3NmVxfJ+Kb1HDihCc5gia+Q/0KGB5sugMFF2bMmoOeXN MZMet8abZ0QsXqXAsFDEJKXbIW8igb0PEQEzp0yr3DNSLRxwmQmDlvFQb+KpYnuHuVi8 YX1HP+XMmx5PA6M/DggX5f6w7UOdmauVAKD9IPYkqZNGogds2Ly9pBKrJHguPdgcobmu 8f8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343466; x=1714948266; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yzuacz24RkQLzVJk3LE2c4+sz1xjIlAMNjLoUa8zGSA=; b=eTLiVL8mISacL+QyemCzq8SgAePDkEarkwVRKEbI4A/5R+Iiwogv862c9syvHo99pE u8GJAhhU2F1TS96gQF7ePAwNQgWoDlqgvtccer9wfek03WJo7e1ljo4oH/Shln0+cNDD OuwmTLLLmH1Gp97beDkaQy004QddYo0AJA4wdftUCRdy2UydC6NzKAhxnt+VReMeE3zK yr2gQ0qrxul2mO1VKRqfyPWl/qJ9ZXXR4Zugh+2gbbUH1SMZK+ID4fW186ZF8vPBp3pP Q6zfGKEewhWI3nXw0T2o3kE/p1dpPcVHeVW1dPudo/grxL9EXODkXe6qBv6XixspADj8 WORQ== X-Gm-Message-State: AOJu0YwCnkObA8BQr4HXIeX4AnMltc7Ho1wlLlqpoRVDUeLY6rCo1EdZ ein8kAHABTOtXob2hgZk5QaXdvHakitxp0Z2FxzBPpmxrSb9E7WctOo+ZA== X-Google-Smtp-Source: AGHT+IFXQ6V5NVenn4AuqLwnQp8N0smsoKWVad30H5+fh854D8VYM/S1YllrudiYaRyRhBU5x/SoQA== X-Received: by 2002:a05:6000:1447:b0:34d:354:b9ba with SMTP id v7-20020a056000144700b0034d0354b9bamr1522934wrx.30.1714343465443; Sun, 28 Apr 2024 15:31:05 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g4-20020adff3c4000000b00343c1cd5aedsm27873834wrp.52.2024.04.28.15.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:05 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:51 +0000 Subject: [PATCH 03/13] builtin: create url-parse command Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira Git commands can accept a rather wide variety of URLs syntaxes. The range of accepted inputs might expand even more in the future. This makes the parsing of URL components difficult since standard URL parsers cannot be used. Extracting the components of a git URL would require implementing all the schemes that git itself supports, not to mention tracking its development continuously in case new URL schemes are added. The url-parse builtin command is designed to solve this problem by exposing git's native URL parsing facilities as a plumbing command. Other programs can then call upon git itself to parse the git URLs and extract their components. This should be quite useful for scripts. Signed-off-by: Matheus Afonso Martins Moreira --- .gitignore | 1 + Makefile | 1 + builtin.h | 1 + builtin/url-parse.c | 18 ++++++++++++++++++ command-list.txt | 1 + git.c | 1 + 6 files changed, 23 insertions(+) create mode 100644 builtin/url-parse.c diff --git a/.gitignore b/.gitignore index 612c0f6a0ff..4f8dde600a5 100644 --- a/.gitignore +++ b/.gitignore @@ -174,6 +174,7 @@ /git-update-server-info /git-upload-archive /git-upload-pack +/git-url-parse /git-var /git-verify-commit /git-verify-pack diff --git a/Makefile b/Makefile index 1e31acc72ec..b6054b5c1f4 100644 --- a/Makefile +++ b/Makefile @@ -1326,6 +1326,7 @@ BUILTIN_OBJS += builtin/update-ref.o BUILTIN_OBJS += builtin/update-server-info.o BUILTIN_OBJS += builtin/upload-archive.o BUILTIN_OBJS += builtin/upload-pack.o +BUILTIN_OBJS += builtin/url-parse.o BUILTIN_OBJS += builtin/var.o BUILTIN_OBJS += builtin/verify-commit.o BUILTIN_OBJS += builtin/verify-pack.o diff --git a/builtin.h b/builtin.h index 28280636da8..e8858808943 100644 --- a/builtin.h +++ b/builtin.h @@ -240,6 +240,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix); int cmd_upload_archive(int argc, const char **argv, const char *prefix); int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix); int cmd_upload_pack(int argc, const char **argv, const char *prefix); +int cmd_url_parse(int argc, const char **argv, const char *prefix); int cmd_var(int argc, const char **argv, const char *prefix); int cmd_verify_commit(int argc, const char **argv, const char *prefix); int cmd_verify_tag(int argc, const char **argv, const char *prefix); diff --git a/builtin/url-parse.c b/builtin/url-parse.c new file mode 100644 index 00000000000..994ccec4b2e --- /dev/null +++ b/builtin/url-parse.c @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only + * + * url-parse - parses git URLs and extracts their components + * + * Copyright © 2024 Matheus Afonso Martins Moreira + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2. + */ + +#include "builtin.h" +#include "gettext.h" + +int cmd_url_parse(int argc, const char **argv, const char *prefix) +{ + return 0; +} diff --git a/command-list.txt b/command-list.txt index c4cd0f352b8..6d89b6c4dc6 100644 --- a/command-list.txt +++ b/command-list.txt @@ -196,6 +196,7 @@ git-update-ref plumbingmanipulators git-update-server-info synchingrepositories git-upload-archive synchelpers git-upload-pack synchelpers +git-url-parse plumbinginterrogators git-var plumbinginterrogators git-verify-commit ancillaryinterrogators git-verify-pack plumbinginterrogators diff --git a/git.c b/git.c index 654d615a188..7aac812d9d4 100644 --- a/git.c +++ b/git.c @@ -625,6 +625,7 @@ static struct cmd_struct commands[] = { { "upload-archive", cmd_upload_archive, NO_PARSEOPT }, { "upload-archive--writer", cmd_upload_archive_writer, NO_PARSEOPT }, { "upload-pack", cmd_upload_pack }, + { "url-parse", cmd_url_parse, NO_PARSEOPT }, { "var", cmd_var, RUN_SETUP_GENTLY | NO_PARSEOPT }, { "verify-commit", cmd_verify_commit, RUN_SETUP }, { "verify-pack", cmd_verify_pack }, From patchwork Sun Apr 28 22:30:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646144 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C7751B94D for ; Sun, 28 Apr 2024 22:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343470; cv=none; b=vGLGk412KstCRHXjApufmZ/NwTFKxDLqvfMTtBJfL0jilXvW5B1fmEKaZ3GfNeoeBL3KLYEi74EKTmINAy0frliGI5Iuf8Lb963t/TfC/sIxCe+XySfJQ/GEQq2pAfw6JQ7J0APET7cMh1CHWXoO+HiGyZDJnWlz2fD8YqJgEbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343470; c=relaxed/simple; bh=6P//f8JMEH8kLtXWu/dfRvih0SIvjcrQJAOjp3bWXIQ=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=t0vWRsaFIBo2tdFPAY+MCxwOLMt2Idsti3MyssuZTkxLHXjmpi9OpI2pWpITmvmepGP76qdiKX6AS4+0YigHXp9W8sz9C1ZPS5pH0/fP4H1rksYd/E6xu4osDL9kFSzJSwk13pC827CglxyrWsXd8vY+LTf8vNEQwznaOkXoUqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nmUMT5+w; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nmUMT5+w" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-41c011bb920so3945045e9.1 for ; Sun, 28 Apr 2024 15:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343466; x=1714948266; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=8RX1x/NHM/U5P1n5FRlp0kF2LnyrqYseRMqXH2pCSpk=; b=nmUMT5+wK1orS/3d60q91DVw02ezV5zZ9CF7IegYRFzm9KZQcLGW9RksiXTL6Z1w6Y aSD3quMbczfYj5HIGJKSOWRJbGAnP9iE8IkXFgCw84bhaBasvBq+ZqYKrmQ3E2bK84BE 96fRg65HJq43M563xfwExnWj6vTcCIGOc1RjPmG01+27XUuuBgLYIqPJIGDsTBwinQQp V5AwcIZ0BKdOGNxA/JYa+uKzmcN1m+U1cI3Cuv/ly84ALPB7BJXaFhb7FsAVw7yc8S6h F7nAby60ziBHZFbX4v4WHxdyHu1eHJQVR13+NfCrPTytqurYco55Ka0kMNy/87XX9uXg Np0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343466; x=1714948266; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8RX1x/NHM/U5P1n5FRlp0kF2LnyrqYseRMqXH2pCSpk=; b=CYaTistU9adUbf75r2IrIU3DIg5V3MasDmMZMS2d1BozPjX/43z0hAHVhnrr3vneBk ebqiYdQBSnWoBABnXII6mp1rkz/gOXKOgj+Xe/r1cfaRgHjiLDzTA+silvM3Sfk25P3l 3sYeELxdkmdyjoyzq6Nh9zzFrHcJmnfQumtos4X3T0FiUUFAhiIKlhwN8mI+DEQGZQmw iY4t2mSxAfc8pTo2SSGQaYI9ZEndYphW//czr3vZ5/+fJ1MGM84/HtdfDwRlIbIUtr1V c2eaDNFYD39xqRkCIyjVUwUi37G9fLFWjTzhkhcSyDpXpS62xNWcCaWEMUFxC9sj5U6G OVcw== X-Gm-Message-State: AOJu0YzEBXthH+2RBwihnro5J5PSt2YFKtCUiF1XOTAEReGM0OFzyvK5 AtUi+K5bqJGYb8WYapbZ5Fphlo79n+paPshcJnynlBZIqOYAlz5bcrQXFA== X-Google-Smtp-Source: AGHT+IEDyLnVRFpzLC5sfEyJt3W9ytdLIappAdHPBj+62/9X5woj/iftbRdSsfskxx8E1aIz9uvDDg== X-Received: by 2002:a05:600c:1c26:b0:41a:56b7:eb37 with SMTP id j38-20020a05600c1c2600b0041a56b7eb37mr6724368wms.20.1714343466009; Sun, 28 Apr 2024 15:31:06 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l16-20020a05600c4f1000b0041a1fee2854sm28364198wmq.17.2024.04.28.15.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:05 -0700 (PDT) Message-Id: <1e0895651cb77759e983b365eda0e7546bf7453d.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:52 +0000 Subject: [PATCH 04/13] url-parse: add URL parsing helper function Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira This function either successfully parses an URL or dies with an error message. Since this is a plumbing command, the error message is not translated. Signed-off-by: Matheus Afonso Martins Moreira --- builtin/url-parse.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/builtin/url-parse.c b/builtin/url-parse.c index 994ccec4b2e..933e63aaa0a 100644 --- a/builtin/url-parse.c +++ b/builtin/url-parse.c @@ -11,6 +11,16 @@ #include "builtin.h" #include "gettext.h" +#include "urlmatch.h" + +static void parse_or_die(const char *url, struct url_info *info) +{ + if (url_parse(url, info)) { + return; + } else { + die("invalid git URL '%s', %s", url, info->err); + } +} int cmd_url_parse(int argc, const char **argv, const char *prefix) { From patchwork Sun Apr 28 22:30:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646145 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3D4BB676 for ; Sun, 28 Apr 2024 22:31:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343471; cv=none; b=q5sXM1yptl7j+csLuUA0Qb5DWI1MsHlj5Wcvej4mk6I7SCa4x3RnKgE8tLkp3uHHONFkEB/kq/EGyCYQmcinXcuyTLMukmnyE/JMoBNNT3brH/8/h6wL4B2Umio8FXoNSHLxbNynNLjYiia1k99TS+ytaOdbYE+0SBuGg7MKPkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343471; c=relaxed/simple; bh=VHI805M6NWFA8IDzt3PG+C/jJX8I7ahLOwXoCNyHpdE=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=UOPJIYbd3i3qYQ0ckkAUdVX4ZUMkmmsJOVWz2uXLp2k8T7o/o7Zllk93EmobcGJ0Eq1kvhoefyMX4U+46fCOqxUm8bd7mmr4PCeuvVR/aAc4YXcL7ly+Cnbun/woLvdVUbZdoM8gKS9VdZbHL3bs4g1c4NFXxCb/PJc1yWF5UYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l2j23+dX; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l2j23+dX" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-34cd9f50ffaso586283f8f.3 for ; Sun, 28 Apr 2024 15:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343467; x=1714948267; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=d5tSEDb6eAbJWENaTudCJguvaLlO/g7f92082XapFMI=; b=l2j23+dXIFW6f5G9KK+8WVRluEjHlK6+tRVk6ousytY9er8fmYMRiI4qxMq7pY0Ahr LJcfElQPAR/XtuSQI1SbdZZfupKXpUp+LvcZdYGgdArpQ0StzOlehTp5zh8YMa+eUn2P BI/gEWVbcX5jg+JryBb2hb3HD5uJmmrEsFJALs4Fwyaq9UA0HTY/08UsHTm6w//tD0on LFslmxjdJvukABkX2THKqAeZlCD4THIxCLY17MPIcoEjdOqdC0wqq8WsWAoSbQCp9rvZ IQCV388MAzhKBT8lpCY2ArEhCKytGs1jow1HkRKSvEUS+Js+5ylIiGPclTbtZo4Nw9FI 8X2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343467; x=1714948267; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d5tSEDb6eAbJWENaTudCJguvaLlO/g7f92082XapFMI=; b=ceiIIxkAaTkp7lDhMXcI3E3f+NgB4YezKBfQx2q28n+9cOAwS3ipI8L0a2bBzkV2IS riuDks+tBVqsvxhK6+AsOHm+PuWIYdfa0oac1dKe2InhIF9mjZ897N3qNSX1MBTe90fU tGka6HGPhikiNqpWWotze/OHgDRNhf+vQZOonfeowyo7GZkFAn0rRSgEoA5PwOrDoy4t 5g9saQTieZ8xzISfon9ZDEol67Ne9FeCe2FDaInATo+OJWs6tUsbjVWd0eYNFSsBRV/B R+UwRYOZjYNK7qgQga3nLSf7vfGGFlH1J427Nrzw95tcPAw6qzFtoiWh7STR1fjuJVC2 U42Q== X-Gm-Message-State: AOJu0YznWs9sJYyNakeUuzyVFjQBbBsINgDJnAK1mEYFl5UnU5t9Kf19 noZA81IiWxk1Xc1kMMGgF+KfF5J7I9mvxPCQQ/0rNTfpeA2JXgIFoz16iQ== X-Google-Smtp-Source: AGHT+IE7TMz0sAGL1pq5EY+TIiC8Y7LRLIwtZnn7nDRhcybJ06NA17JysFGaUWHm4PL9v0VxEm5Bkw== X-Received: by 2002:a5d:64c3:0:b0:34c:ca8d:ab94 with SMTP id f3-20020a5d64c3000000b0034cca8dab94mr2359577wri.23.1714343467616; Sun, 28 Apr 2024 15:31:07 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d1-20020adfef81000000b0034a7a95c8cfsm24210608wro.9.2024.04.28.15.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:06 -0700 (PDT) Message-Id: <0bf83ee1228130df6069206190b97f1d0329794e.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:53 +0000 Subject: [PATCH 05/13] url-parse: enumerate possible URL components Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira 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 --- 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)) { From patchwork Sun Apr 28 22:30:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646146 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1247D23770 for ; Sun, 28 Apr 2024 22:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343472; cv=none; b=TfzEuE2hOwIAAH1rnqfVfkjDJRG4FyOfXvpIBVgfPqFj91hkYUFUTmFNIp+w6igNJJL/9OhNeowTvJRoAA3fj58fAiheAODwLaR65FvXtwG5gzYdSIBHCc5r53cGBDuFRxp7H/9UMIDFjol/Cl0Cxvl/MPNejNfNSCHE+wOZ2/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343472; c=relaxed/simple; bh=blfrgL1shA6DGJXD5/gNPeLe3M+Xm5SezQWs8vxBCic=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=lzjKlyJrELVVTAv6UtqcEnkCFtdgwlwZwrY/BlN9p7PYyNNJhm/ymTcSmNGUmAJ3i/Yez7zATbq6cXv7rcGnmmzMbannSArY+UFvHDli4Ltz9xCSQKsReTVWv570zNd5fdxNpsptycHWRKd+ZNrxIVMmCvu6Bb8oJ3BgDYO+VhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cQrEsdCS; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cQrEsdCS" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-34d13789e2fso266853f8f.3 for ; Sun, 28 Apr 2024 15:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343469; x=1714948269; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=qtb/oxmyiu258YJvwAQ3i8cFUBEs6IaObiXGc9l2sn0=; b=cQrEsdCSR7tFGXMLr32zf/17gCD+277MRQhBFI+swuBcAygrciyUWcPg3k42MXPwJS 3xbi/zgdrQDS1jURqfIfFaAdpWDnkw4E8PKdP0uUMP26xUwvA3UoaaxC2t6Pl9/2/Cea yzvSrlao+qCGIeYIpg9oPGFHm65GXoo3RyE5yOnOtKVIm3+ZstYTTp3Gpl13/LwjknwY 9HcadRBooOHGpyLpVsqGKU0YeJBTTfBxlTxMyvScqboaWgyyDICiGFp7OfWY+Lm9KYfG OLTsnkHFjInSHG4SBuZx8p6wJyZE7zxRwhgttPSabKicL6YNx+EimoMyde1xJ3eSIQLv cV6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343469; x=1714948269; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qtb/oxmyiu258YJvwAQ3i8cFUBEs6IaObiXGc9l2sn0=; b=pXJuRIdXKNH6qwhpe2CnOlnDJfm83np73FmT4CRpFr5hdeJJUVPPwnICha2S4cWa57 xGEVhnYWdY6F5TCs5WCBOcAMrLzF6BufiGhB/px+ZPqfaWQlAwu4fKFLPq3pjcemoUmk szq4zVEKMg28QzMXaxEtTcnK5R9uJ2i3PfchsTEp3j9L5Mtl7H6M97r5G6ZbopDUYnJ1 snqyvGBrC1CoW7mhexVeK6zXqemJsgCZBCh5mbMQK7ksTRwpfLdalZ3d6lmd9vNk1SKn ufglzY6s2amvA16mXBlmAJgPbE1uOVhBy9u/Rb5iVXD5V5FcFyvU0ukUwonBR/KTo2Av f7Hw== X-Gm-Message-State: AOJu0YxrogAaMYs0fWe5rv9BwYPBKa2Of+rVMOKrWU+hq0JscZba2urP CU4WEU8+Sq/dsZFoHWVtpW7kNvxfZg2m2hcRJgQRg7tko+F2LBMiz/ULwA== X-Google-Smtp-Source: AGHT+IHwbAJ/hxQKmk6EsJjVycF34vYk7VCFvk9xQeoiYvvVmuD+Cp0zS/jDHCzwgIIBKj1dZy5aWg== X-Received: by 2002:a5d:5549:0:b0:34c:a56b:e980 with SMTP id g9-20020a5d5549000000b0034ca56be980mr3561481wrw.47.1714343468871; Sun, 28 Apr 2024 15:31:08 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l2-20020a5d5602000000b0034d117df264sm1046225wrv.114.2024.04.28.15.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:08 -0700 (PDT) Message-Id: <149c476b1ed74897ffbdf711754b9804fa679467.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:54 +0000 Subject: [PATCH 06/13] url-parse: define component extraction helper fn Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira The extract function returns a newly allocated string whose contents are the specified git URL component. The string must be freed later. Signed-off-by: Matheus Afonso Martins Moreira --- builtin/url-parse.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/builtin/url-parse.c b/builtin/url-parse.c index d250338422e..b8ac46dcdeb 100644 --- a/builtin/url-parse.c +++ b/builtin/url-parse.c @@ -32,6 +32,42 @@ static void parse_or_die(const char *url, struct url_info *info) } } +static char *extract(enum url_component component, struct url_info *info) +{ + size_t offset, length; + + switch (component) { + case URL_PROTOCOL: + offset = 0; + length = info->scheme_len; + break; + case URL_USER: + offset = info->user_off; + length = info->user_len; + break; + case URL_PASSWORD: + offset = info->passwd_off; + length = info->passwd_len; + break; + case URL_HOST: + offset = info->host_off; + length = info->host_len; + break; + case URL_PORT: + offset = info->port_off; + length = info->port_len; + break; + case URL_PATH: + offset = info->path_off; + length = info->path_len; + break; + case URL_NONE: + return NULL; + } + + return xstrndup(info->url + offset, length); +} + int cmd_url_parse(int argc, const char **argv, const char *prefix) { return 0; From patchwork Sun Apr 28 22:30:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646147 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84B6124B33 for ; Sun, 28 Apr 2024 22:31:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343473; cv=none; b=E5ko1t/65Jn1XBbJ/PxEukQM3IoSuCD0uJ4Fb5s7HY5UvRBWGTWmUvy3rpoUWw90CP/ELk5eq0+qB+uYGulVwXhep8s7tDE5qJtWN1TyFfuUJ2QbfheR5K1zLI8uHd2hKid0VdzTdELD+S3D59S8jq5LqfaJjPUTknB6uOEjkvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343473; c=relaxed/simple; bh=nhPC/OVyEJnhdpdQA8wfXn6c1YSIdXh+KJCi1cvtJCQ=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=ZoBe6M9Ft1RpjdViCNBciM0yBFtF4WebmTKrg9GUN3P6RU/sWbM0h3Cl7RntulFUvEW0S5E55ZLtEOp3WaYlD7EQFAkfbdOKLyoZ4nSSl2N5Hxp+s6LXYTDdYG8k/w/pxmnqJecPPMtwfM5RpIwkIMxsWP0dkI1F7SNgKTAkX2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hvK9f2Vp; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hvK9f2Vp" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-34c90082dd7so1435950f8f.1 for ; Sun, 28 Apr 2024 15:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343470; x=1714948270; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=q/Iybmms7U4YfPv6VSfCySdUklGSldkATf01Kvk/SdQ=; b=hvK9f2VpoF9UFnPvRhNa4Q5e4uXt/iamUM2TBlogG6IkTTimpwM3gvJMiaeuuaFXWU CtIX6+AtQkwMFBSM33aekvAPAoXoQoWMXeiJxrah0uJ/Zb9Ml6WcxKP4AAe/8jD158mb WpSIhcEI4Gi34lKWTejrR9CkheOMONpg+Twig+rHlNS1GZAt3xb+AaTeJB8ovpElZ1sw DMfdy1k+0uxTvfW6PupNov6MmiDJwkwABEgHaWOCIf4nVxK/k7/laHVjW1PmMEH+egp+ Dna9Ce+mPnQxwbptW9ISMMJ3qrxB3tsrpeNP1ijfWroqKYrBAOOI1wuad5xlieotdFn8 y5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343470; x=1714948270; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q/Iybmms7U4YfPv6VSfCySdUklGSldkATf01Kvk/SdQ=; b=e9stz1UuTrGqW8GdHUlT24oMjoMEmB65E04yKmnXa++AlqXnVz5XXMnRQRev3gMowO FG58Phhdgmfv3IjG7XbRp+LbH92yuqQJaWr+Do44o28JSsHzJO56o24mPSj9yqaxeSRe 3SPlqlPRxQV17scho5zmUsLFce02aKFd2D/hFYgq8VlyK7XAK2cJFGkr4Pa4ofHpw/qR gOX6X7e0fnh/6CxPd5iGg7hbPPZW+6UVQMQ5NzRdXCGxqxYprzgPNdtSfQqTQGoDtaC9 pQvyie8RW7PHntLCQ5c2+6DJY80ZiWNdj+l3zYzR6BKvJXpYENj5dQrMMY2YxRS9NraZ XJ1A== X-Gm-Message-State: AOJu0YxiJMFw64BBnlr4oIvkjt+MuQmdrqe5bjDD4tm1lbFN3DakgVem 68ifVEvTq0KZP5PnjFaxiEMBTSoW3DVWa6hFGDoeaPyyzb692cGmV3R6Kw== X-Google-Smtp-Source: AGHT+IHzn3ojuGUAaCl2494dQiO+bMvox0zMVkOfgiO8Sws/Q+u9d2s6k3Uev2ifEjfXu+dx38AcfQ== X-Received: by 2002:a05:6000:11d0:b0:34d:118f:21ee with SMTP id i16-20020a05600011d000b0034d118f21eemr799666wrx.28.1714343469685; Sun, 28 Apr 2024 15:31:09 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k6-20020a5d6286000000b0034c124b80f7sm9562216wru.61.2024.04.28.15.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:09 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:55 +0000 Subject: [PATCH 07/13] url-parse: define string to component converter fn Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira Converts a git URL component name to its corresponding enumeration value so that it can be conveniently used internally by the url-parse command. Signed-off-by: Matheus Afonso Martins Moreira --- builtin/url-parse.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/builtin/url-parse.c b/builtin/url-parse.c index b8ac46dcdeb..15923460a78 100644 --- a/builtin/url-parse.c +++ b/builtin/url-parse.c @@ -32,6 +32,23 @@ static void parse_or_die(const char *url, struct url_info *info) } } +static enum url_component get_component_or_die(const char *arg) +{ + if (!strcmp("path", arg)) + return URL_PATH; + if (!strcmp("host", arg)) + return URL_HOST; + if (!strcmp("protocol", arg)) + return URL_PROTOCOL; + if (!strcmp("user", arg)) + return URL_USER; + if (!strcmp("password", arg)) + return URL_PASSWORD; + if (!strcmp("port", arg)) + return URL_PORT; + die("invalid git URL component '%s'", arg); +} + static char *extract(enum url_component component, struct url_info *info) { size_t offset, length; From patchwork Sun Apr 28 22:30:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646148 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C532CB676 for ; Sun, 28 Apr 2024 22:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343474; cv=none; b=GcyfDGcWlqM2qbIPK/k4vDnleMtg2x82xSnli6E+XcrJ6C4vJa4siLfTk40KNMlF1t/yce7I3MMtZ6ZHfj79chcVqa0rTAR+TtxkMF7qvYaydXIvgBQ2yGrnDLNBs/rrc1HpDUjaLXMaZpxDwf7v5369bkGNK9cdpDdg4qZ4lcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343474; c=relaxed/simple; bh=gPQW1182XW+A/k/6EdV3XLrwR5Xatsjgvi4Z45ts/Es=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=NPKtgBjBp83EjFtueLZNUSOcEszmL648B8lMGWIWYLTRWtqdRsil1YCrrLaQalaz71qAEYFI+KZYSgrqJyxk8LQKZWdwreR/0iGdaAlhvN5wNhdC4HpGZP6CIeK+/dIMvvyzCW4+DhHwayZp1UTjacnoGnISQm4LhDXhikDw7io= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PoivdMOf; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PoivdMOf" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-41b2119da94so32001965e9.0 for ; Sun, 28 Apr 2024 15:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343470; x=1714948270; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=A2J5CGbkoKSJ0e9rVf0Ut0etUwKNENSPNV4ltbSnlQo=; b=PoivdMOf5Y6yXmgw08wohKhcWCfLjGQhHrzjMQCW6UH2YIf4MFLpUAZRS0t5V/JnXw dXC+ziawyt64NF77io+KaXWDmx6SArmtcC3d3IVL+hnOGwDlKNBzNgyMcsE59sQP73ma 9LwY/5P8FEubgMC8AsNLnnIT4gBPe6UUK7hRFHwr9J8a6tdhcvu6eowZfnnr78b1C03W IWIlLVSLi6WozikQtlI3Dsi98boDNTya4w1vhbWq8lh448VQbb/eYZUu7N0Ei42EjZly n+XQUkVvD0T+cbfTNv3xn9sG0ch7kTBitUzeVMjpazBTYVObJIKRj7PSc8UozwryzXJf XXDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343470; x=1714948270; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A2J5CGbkoKSJ0e9rVf0Ut0etUwKNENSPNV4ltbSnlQo=; b=m/Hxv7mRPI5yHX/mLIyGbgaULP+OQ0lMkf3crzBSNN8gXbC0mmNMJ9Bl1ZAtqF+F6O pPBMTw7+pn8Lizlz3SZd4A1MUvs1X7ZJo7WCEc3PlQqNxkKZIgjHI6eVLiZIYe322e7n QwVHDSiNakfhsWbhn+pNgtSQykWLMyE1BEMuzJ7gxXw5BGYL7sx9QtvHqlk8RTREgMhN DMD+XL+/6SSFOlRfbYciYOdBMIrSy2C8Y7vMth4TjNyiHZRp1b8lecZyLbiBjiwbG8jD w1ZP34rgjajMEr37hUh51KeN1q1Pw8n1Lx/cqyX91Pkyd0RBhjPGq0Uz+bMPFRr14ouQ EB9w== X-Gm-Message-State: AOJu0YxVXSEa2h8c1jTmw2pACsbmCuo7cvpPKd437oxrjg/vr6cyJdRH SLnMM2IrnyQkzH6SR71Yu4gzKF/oPT+Df4BK5zwSs1ajoz+0XEYImwCYjw== X-Google-Smtp-Source: AGHT+IH6yrUXoXi2ggxO4UhD9a2K+Zq8exM1+MAvykSnQXnOw+7zuKZ8EPYkKQB1FD2sjEtjGzXScw== X-Received: by 2002:a05:600c:3508:b0:418:dbad:c57d with SMTP id h8-20020a05600c350800b00418dbadc57dmr5469817wmq.28.1714343470587; Sun, 28 Apr 2024 15:31:10 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r21-20020a05600c35d500b0041bf45c0665sm5324457wmq.15.2024.04.28.15.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:09 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:56 +0000 Subject: [PATCH 08/13] url-parse: define usage and options Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira Create the data structures expected by the git option parser. Signed-off-by: Matheus Afonso Martins Moreira --- builtin/url-parse.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/builtin/url-parse.c b/builtin/url-parse.c index 15923460a78..c6095b37ede 100644 --- a/builtin/url-parse.c +++ b/builtin/url-parse.c @@ -11,8 +11,22 @@ #include "builtin.h" #include "gettext.h" +#include "parse-options.h" #include "urlmatch.h" +static const char * const builtin_url_parse_usage[] = { + N_("git url-parse [] [--] ..."), + NULL +}; + +static char *component_arg = NULL; + +static struct option builtin_url_parse_options[] = { + OPT_STRING('c', "component", &component_arg, "", \ + N_("which URL component to extract")), + OPT_END(), +}; + enum url_component { URL_NONE = 0, URL_PROTOCOL, From patchwork Sun Apr 28 22:30:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646149 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C49FE10A3B for ; Sun, 28 Apr 2024 22:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343475; cv=none; b=EHxex6zUdfNiqbDupAZfF2KaP5v1/ZfOp+seEvcDEB7p4jJUb9Wn4iGP4BUA1y4sjVqk+XNpcMTSNL4ZyJJKYdZyWPqXvJN9DQdc3x6lDecxVZBITs4s+A0ytkZG76KWpE5cR0pqY2qjgsD2MaD+zuT90mZfosrgnIlodERPlJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343475; c=relaxed/simple; bh=tHk2T77Rs5E324KFwRwEYaV9LBcZlx53SROJvyVatuM=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=Pf5N4zAHDErvPnVV4vqAiaESKgVWbZvkW8NTjESEbjrXmJx4eZ6FRqWkhQzkGkU7irfgGCtsqqKp3xeRFBX1HILqG21Joi06LekhdsaoNdJTVXGgOpY/o5z05BUl80DRQ46oS2+aJy3s/bCDrjtHdJSfmAif3Nc+sIorifOfqaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EpzmM/pt; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EpzmM/pt" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-34d0aa589a4so337463f8f.1 for ; Sun, 28 Apr 2024 15:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343472; x=1714948272; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=lMSBnx5sk4mLWZi14pSEtOGXQe3nHFbwwTnjv9+JGgI=; b=EpzmM/pty5aGUtsBFyZOpNTAXBS4FqYagwBkP7gyOtdiLeviuRla2+kEdj0ZVfhO1u L1OCBALRXuhFSF49QHpyrSh+Ys6Ez1ujFObChk69kRhA7DJwewcjvMQT95jjLNjrbyXY NUxAE+wzIn3TjxtoyVL7CO19QKIXcAppFZn0b3OwuN3tbXEe7fFJTDtgSFnIy/oKipBS A8fU8qFWqy0rcOsQnD79U/ZGMx/A20s29MX5NHNxxvm6ifu9EgiIVmiNU91POIqDBpf3 nfgkGcDeRzPmebNVlukGdjDK8j0451B1k8uLULHcAN+AnIJ3OjNteuSCv4HWCDbhTSp2 GjHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343472; x=1714948272; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lMSBnx5sk4mLWZi14pSEtOGXQe3nHFbwwTnjv9+JGgI=; b=DtujQfwSeInAaaQ5U4JAZ29JBwa0vRF4c38iIWO9zzixtXHvuIzRQzbYfpNP7F4NJc /Tn27ExodBB4cy7ZUBSzwRNNXX4QGj1dOiPRKhS14HA4e5O9D3BpC9tsCL94FVdgqQMl n9rwMMWlYsiZxy3ez1NI671IdZD6gjmkYU4OmM5YFq27xfcFR3EtU9giuym59MCGhHFf mIKFO19idDbvYLdCWhkP9Cn5MBFb7ceDukTWSGaThxq07Et7pSs4TomUJuZ9NRvVluB3 6OdWkTnqILMazo1uVkGP9WPTo/F39r/bXAX7yq/PT1GGauId1nPq5HW/KlIo0wLPtxmy 4RrQ== X-Gm-Message-State: AOJu0Yztfo4giRDsSA9DZC04ZRYpPGAUkings50pdaaNt+v8xq1Fp3ZG 6xQ49sFX0IrQJky/HmRCx7igTMbY2rVy20TKg5FXZ9AYingm0iICu1bMrA== X-Google-Smtp-Source: AGHT+IHknQJ8bPJ4A058KWVjUil2FMyBVlESPCcO12UaOBR6YF/oI8V1wzqW+XzFgMV3C0F4uuM7+g== X-Received: by 2002:a5d:4712:0:b0:34c:eae9:7650 with SMTP id y18-20020a5d4712000000b0034ceae97650mr2086780wrq.46.1714343471862; Sun, 28 Apr 2024 15:31:11 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d15-20020adffbcf000000b0034b1bd76d30sm18182165wrs.28.2024.04.28.15.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:11 -0700 (PDT) Message-Id: <5de00324fb7011549da066068a4d102b9bfcddd2.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:57 +0000 Subject: [PATCH 09/13] url-parse: parse options given on the command line Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira Prepare to handle input by parsing the command line options and removing them from the arguments vector. Signed-off-by: Matheus Afonso Martins Moreira --- builtin/url-parse.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/url-parse.c b/builtin/url-parse.c index c6095b37ede..03030035b4f 100644 --- a/builtin/url-parse.c +++ b/builtin/url-parse.c @@ -101,5 +101,10 @@ static char *extract(enum url_component component, struct url_info *info) int cmd_url_parse(int argc, const char **argv, const char *prefix) { + argc = parse_options(argc, argv, prefix, + builtin_url_parse_options, + builtin_url_parse_usage, + 0); + return 0; } From patchwork Sun Apr 28 22:30:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646150 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CE3724B33 for ; Sun, 28 Apr 2024 22:31:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343476; cv=none; b=l4jN23fQ/T3aPGy3R3S70ge8MgGTUXDvMUr2JFGh9rz+xRaevQn3BerFPMrTVkK0Iqk+UROXfYXpn+JpZyPeB/c1hjmNlqiBaANEC7T5T+/bec012lylbHKbf0n06Z78TKSbh6QYsm5/5F7E+OxYrhKVlh/mv6wgNBLmD1RH6jY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343476; c=relaxed/simple; bh=iN5EUWnfhQfCqPLThpA39n8mG1zY6X+aALSb+Ykp5Kk=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=Rx0ineyqVFVMB0fk9uK57C/fSVSZaZgq+ZwWpdaRL/4An3MuW+DdFMqx2NnH1ZpnJfzuVbPeIv3yamRcjcU6RRV/Fd1C506dS0nJZMJcU46hEXK7RaG32LFTU03tisTalsCZA6oiyEIpLIeYEndDEELGgFrs3woIdqMimYCNsNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QAGS9Lui; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QAGS9Lui" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-343c891bca5so3107844f8f.2 for ; Sun, 28 Apr 2024 15:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343473; x=1714948273; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=T6AiBVs52Hi/6kNMCH42koxPIPHGce3AzF6yEOX3Vrw=; b=QAGS9LuiF04A+jHKuCl5kLr67uTsvIpvwf1jFj412IVtEplSY5ulsD9ibvln/T0g5t Nqikb9huGHTV1wNiiA8w+BFDtS0f57xLuQE8hZb9eGrcMOd51bsuC1lKue9X5FC61jOS Lnk2p8plhs18TitJk58EyeMcjnIXdyd7vSUaqmX3R5ua1AlZdYoFOkx5OGhsCoTAXrWH 4lxqC9F5o2lCX1WFmlaqo/JET8PVJkUNxvW9+mJGgGYh/rfxTTvy8rPHetdZAPoiqlgZ E1nNRJgfawU2y/revbTibUW2fuxrl3yiK0g3n28MyfKiKJZVeEKvJG8gCd9EMMMJ56c5 0Mqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343473; x=1714948273; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T6AiBVs52Hi/6kNMCH42koxPIPHGce3AzF6yEOX3Vrw=; b=LUAaYztyb4n1NUoCSMJDeiORP69zMhfO2qO+ma7MEPUSRP89axJW+O5ZxYQiOHhfsD yWD73N7CDZ/D50gAIYYy4G0iMu7OpaXV8CzsN24kpi7KapGsr804UMUJRcgRH5Hv/Zh9 HkNT4KA8uQtkfppOtwsK9O1q1jkqGgpo/wwKgnFr/gkz5zkR2mH19a3OrMldXchvhj9J SmPE8jAaWZwi5ssG+FQz+YSfxMuYMff4FhFozHpiIKqB5Nc/cABWlgYR/gfW95qcL8Uq Sxo2Q0SUgrI+uzDpMiFfOvddeDDZgQ4zCBN1VDrY5Jn7BvBNpfvNGA3bjLMtv0ItVfZn TKhQ== X-Gm-Message-State: AOJu0Yx/LG8VuFEXxDelCQvBJJ1c3JrdEAaKTP2yDkUoanywYJ4wzOkP dukxLkX8J0PkMXd1ZHiAyGiunwqvYIMAmfj7QzI/PHOla0v7dGBc3fS59w== X-Google-Smtp-Source: AGHT+IF/XJ/GmaAg74xbDro2EL0gu0NGbbHw4Rl6W4GsrqpGvqqJD4VicHwCTVj150QtY5xbBBF7bw== X-Received: by 2002:adf:e950:0:b0:34a:bfdb:23f1 with SMTP id m16-20020adfe950000000b0034abfdb23f1mr6615205wrn.42.1714343472794; Sun, 28 Apr 2024 15:31:12 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u4-20020a5d6ac4000000b0034c3d1e1391sm7929295wrw.42.2024.04.28.15.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:12 -0700 (PDT) Message-Id: <15d355a43cbedc16f420066e50e02041c8e1626d.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:58 +0000 Subject: [PATCH 10/13] url-parse: validate all given git URLs Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira 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 --- builtin/url-parse.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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; } From patchwork Sun Apr 28 22:30:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646152 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 966E1B676 for ; Sun, 28 Apr 2024 22:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343477; cv=none; b=s5SLfJvw5H5tF5a18eQSoYHYmE4lzFpT6ITNliqkvZ+gnaJvgs6b0m3mqqzJ+zu9MLaxqOGuNt/yb8gtzBKwlZ/MVBGJ4GasW2iGoAgeHC1e2ZKzJkhBnkJbfhHSl2VGXzXazlTuajPZsyU3Isb1av833HLNYEdEUsGT1xetl7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343477; c=relaxed/simple; bh=QEYhxqdV06ATiUnQf2zTq+U70dw8TJKii5arvMzgZIY=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=QpvRzzPgVG5hmfYFfE0tk9KN1ebDnivMlhGeUoqmgUH4RY3TX5hPPNzoFHPuTftC9H5RwjRAc2ZYa6ciW/nzh/Wklat+ppaeyx2oXecEpoEvn/8Ml1yXptNYaI78gPPfjWekUzrW2KEGPXJnkW77LpYjqXX7c1+QcZAoOkgZ1+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eY7l/Z8t; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eY7l/Z8t" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-41ba1ba55e9so17789175e9.3 for ; Sun, 28 Apr 2024 15:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343474; x=1714948274; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=mgsaR/idZFjMkK+l/iXfIWqvhrgquolw9lHdh+k4HVg=; b=eY7l/Z8tHK2EZZpfi7iR/Tlwb+70WzfUe/qAzzh5Lh3taoSYBArpIOZqKng7XAO95r FFGTd9dylpxuPtyrlY4vkkpY2E+rBspLULoGJTW0NDS5HEoxZ06LsW7+jK3jheVOQb3y KikmV0xtPGoi+iiQmm1qKcf9VmGbqI13gDGAQBa9KfsdzOckfgwG0GJKZFxMu49n0Fbh p7RVtVjVf3ug3I40BkgglceSm2pk/VqQCxjE3c6n9v80TJb+qHciOZA2VDtdOMn451VB 7LiCIYYHRDHsDmjZb/JmDb2Bu/IG4KbHiJG0GJ9CbdCK5eCM+/iwibWb9Bvo5hpsTPGU +baA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343474; x=1714948274; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mgsaR/idZFjMkK+l/iXfIWqvhrgquolw9lHdh+k4HVg=; b=ZoCvxGt54vnqSc0+EBliIxs51wVbJc5Whx1JHnN9mPu+eFBFted22YZ1jkl3ECHYva 4J7/IwYhGmd1+Hre8L9Xp5mRqZIPtaPgEkvyFPDO5Q5dmuw7cXhHOPp+A4mslYX8/43S hmbON3MBQCSP+JCrq939rjSh7VdMKTAT4Ve6ixcB+G/Q50s1mxTSRSbe6miO7Rbgcrq/ tD9o7c0TGXqvxJqNCeZBm1dxWMSIcgjlpV6zAMTbPLwGSJ87NjoiZOjO2spGg48UAYnZ pYm9k0ou9gvYnHCfNcPW09mRmfPrENifCOEAbRc5MG0Nxup5UpZ6uYGNuUsprIhIw+Tk K2JA== X-Gm-Message-State: AOJu0YxkS70dUKyR57iV5g9+8WUuYApOoOiEzM2k8cjPGEPg8SjgNoGp nYmXxdMia4BwdjkkChmFwCy8S1QOX2Xyozp8XWdRMTYSjAckZ01aaTCFcw== X-Google-Smtp-Source: AGHT+IFirLY1romzUbho7mMFbFaZxv8DJb+BsaDYw9I9y0MQKg42iGPKLs3E49xDDqBZ3Cpbm+nvFw== X-Received: by 2002:a05:600c:3ba1:b0:41c:97e:20b9 with SMTP id n33-20020a05600c3ba100b0041c097e20b9mr2538813wms.14.1714343473688; Sun, 28 Apr 2024 15:31:13 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h15-20020a05600c350f00b00418d68df226sm39997172wmq.0.2024.04.28.15.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:13 -0700 (PDT) Message-Id: <4e93509c80f944b2d10c6d62853cecb78aa6a464.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:30:59 +0000 Subject: [PATCH 11/13] url-parse: output URL components selected by user Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira Parse the specified git URL component from each of the given git URLs and print them to standard output, one per line. Signed-off-by: Matheus Afonso Martins Moreira --- builtin/url-parse.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/builtin/url-parse.c b/builtin/url-parse.c index ab996eadf38..6c1a8676bad 100644 --- a/builtin/url-parse.c +++ b/builtin/url-parse.c @@ -102,6 +102,8 @@ 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; + enum url_component selected = URL_NONE; + char *extracted; int i; argc = parse_options(argc, argv, prefix, @@ -109,8 +111,20 @@ int cmd_url_parse(int argc, const char **argv, const char *prefix) builtin_url_parse_usage, 0); + if (component_arg) + selected = get_component_or_die(component_arg); + for (i = 0; i < argc; ++i) { parse_or_die(argv[i], &info); + + if (selected != URL_NONE) { + extracted = extract(selected, &info); + if (extracted) { + puts(extracted); + free(extracted); + } + } + free(info.url); } From patchwork Sun Apr 28 22:31:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646151 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70DCC381C7 for ; Sun, 28 Apr 2024 22:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343477; cv=none; b=RIR37SCpez9Xpo2UQP15yBZbB5Ko4OHAVQxal6ah1edd3J/7fn1eaq7U+XfTCc4KCSgL3FVw0Lu+9coORz7Kvwon89609GqQymy6CMz+pzNuYpKkEL4M73j/qywzz/PyiXTPzS87J4MLdTEt+wU9S73NgulmiuliBV+Qv0JoUcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343477; c=relaxed/simple; bh=tdzpHmTKkZ24KvC3xTC7FnONi0Z/QV8MVeUyetSmH50=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=hj9bWP1P0p86Ut+mY8a1TFSc5BLlS7tVROXr0Wtw7M/w0QgmkTg/NkwRCgxlOr93FsViH0AW/G4Kt3TYhm7eJ6Sa7b6N3S/WI++heoKq0uwl86y+cxk6HdcEA3kQ4H6B+oXbqicLcjlIEgA7Q0hQis3evXsOp1dsu+Mi+RAGGvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TWOCITQl; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TWOCITQl" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-34b64b7728cso3206405f8f.0 for ; Sun, 28 Apr 2024 15:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343474; x=1714948274; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=fEr1tDLxI7cdJtH9InmwvzeqtnIvZlPqbs8ciueP0vg=; b=TWOCITQlGDzHBaxSjlCnaCPj+WBzNaYrvyTe+lfkEQ8/Yz4mCtxRSQBauxCKjHf22b UV64tcCY5mbySh8/5rEM4SuojDlFcq32jVc1IrSjr5GlBOx3s0x6jgH1SwwrLhQn2HSy qq+H5veKKW8806z06nvoS9gPgWJGSzjpGJ5rYNZT2Z0Wa0VYbWvBwjMvbM60y2JuObcV ZoJXfL4klUyxrdj17zBk7HtQ3gwRVgg02AT6mmI0lDlnl1bRV9kCXVr7AdW9m/K7T0d+ nEYybu+9TcCspa9UUGi4ML9731U2aUrnyA3OXkhiFvteZpM7kV1wu4NJJ5DvMxZ/7iNo j9Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343474; x=1714948274; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fEr1tDLxI7cdJtH9InmwvzeqtnIvZlPqbs8ciueP0vg=; b=U6+ogxeGhZx5539LruZr7ZzWzgv5zHPA1CP0dBCH165iYcoZmuAWOLxXHiBcGSPZ3O zTcgkeD/HuToVCbW4rO/enFtQOg0cRb4F/4Jw6cL1ag+ZN8csy2ew0J9XfknjqYVzvEh l4s5jgAXJY+0YbzIHiH6lJqYctgt4+r1Jhe0h+Q36yJyJViCj9/emgdMktfcwID1xGm5 90bsIzcOntJgdwcUDJrcyBNuIkVl8T7qa5gsiifj8LOn/DPVLIaVre8f6FJBO6oEbQl3 Mx6nzTSVU31cukWq/eICLE4nOeMOKHTSTaR/cK3aHUchc7vz9+9OesT5P6sJn3qMdCjD Rm6A== X-Gm-Message-State: AOJu0Yz0GaoOma5JZ85/rpmR/Y2unk+eQoxB2LekMADp2UMnqDujsqyy VNwakW8fBatwG8txAvIOWrYUV3HwpuwwPLxXOTFOs1qePvhCx/V6ArP2cw== X-Google-Smtp-Source: AGHT+IFeNI2Mbjkr9XcnDXO2Q4cOqIufmkpHwtJz33bvQRqPwHsi8DQO/wtXDIc7tWGTmXtfqalBUA== X-Received: by 2002:a5d:6da3:0:b0:34c:f507:1f54 with SMTP id u3-20020a5d6da3000000b0034cf5071f54mr2033108wrs.25.1714343474621; Sun, 28 Apr 2024 15:31:14 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y17-20020a056000109100b0034c85919609sm5602534wrw.41.2024.04.28.15.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:14 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Sun, 28 Apr 2024 22:31:00 +0000 Subject: [PATCH 12/13] Documentation: describe the url-parse builtin Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira The new url-parse builtin validates git URLs and optionally extracts their components. Signed-off-by: Matheus Afonso Martins Moreira --- Documentation/git-url-parse.txt | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/git-url-parse.txt diff --git a/Documentation/git-url-parse.txt b/Documentation/git-url-parse.txt new file mode 100644 index 00000000000..bfbbad6c033 --- /dev/null +++ b/Documentation/git-url-parse.txt @@ -0,0 +1,59 @@ +git-url-parse(1) +================ + +NAME +---- +git-url-parse - Parse and extract git URL components + +SYNOPSIS +-------- +[verse] +'git url-parse' [] [--] ... + +DESCRIPTION +----------- + +Git supports many ways to specify URLs, some of them non-standard. +For example, git supports the scp style [user@]host:[path] format. +This command eases interoperability with git URLs by enabling the +parsing and extraction of the components of all git URLs. + +OPTIONS +------- + +-c :: +--component :: + Extract the `` component from the given git URLs. + `` can be one of: + `protocol`, `user`, `password`, `host`, `port`, `path`. + +EXAMPLES +-------- + +* Print the host name: ++ +------------ +$ git url-parse --component host https://example.com/user/repo +example.com +------------ + +* Print the path: ++ +------------ +$ git url-parse --component path https://example.com/user/repo +/usr/repo +$ git url-parse --component path example.com:~user/repo +~user/repo +$ git url-parse --component path example.com:user/repo +/user/repo +------------ + +* Validate URLs without outputting anything: ++ +------------ +$ git url-parse https://example.com/user/repo example.com:~user/repo +------------ + +GIT +--- +Part of the linkgit:git[1] suite From patchwork Sun Apr 28 22:31:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matheus Afonso Martins Moreira X-Patchwork-Id: 13646153 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6586D2E3F2 for ; Sun, 28 Apr 2024 22:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343479; cv=none; b=tkwRu1bIT9OGTNEdEC4fL7Cmpou6Qg8SHhneapnCAm6tASI2LdsTfouwQXgXGvkrlF5mzJv0TVQart+QOqgaPBRL9ObgdW7vaqIOb0VUSA1HmI8bRHs15Ce5nGaSt7T2GI4CjakHq4UihemBI9oTCKp8KCNwc+BtKUY/kBiDlcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714343479; c=relaxed/simple; bh=mXdyuW9SpuwPoHN3LZsafvlv7UN+oGgmHHavu4/rZIM=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=qygHLSCyI9hLIfk4F7nPWVvWRRG7enuEK1ScJ1jetcy3ZuO4hzYVRMpzuhNSnw/AZPP7NCBBO1cwUd9kLc/vhXN2xaNltjtbVaNqbPhaFoRtNgx+ETY3Yds+oDi4WfqwG2JFZZebmm9A6HhVSnoAX08K6z94jdzl+TO5wKdhLes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=F1rOjaUy; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F1rOjaUy" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-41bca450fa3so11650765e9.2 for ; Sun, 28 Apr 2024 15:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714343475; x=1714948275; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=osBKKwwpR/+9hL2wkALs6vJuDNYhp8UoHBeiito79xI=; b=F1rOjaUykdX/i2aSSmM2mQyo/YrH3/lZ44qRVmh/rMoKFcYQV5EUkvOi2In6O+I+MX RBdhqd3wbZzUcQXpgTLyMC5+vrio7BVQccYqJRLXmc+/7YYcrhUnoE7hnMZ0GSM9cdYL 96GSX6BssyP7X7VYoGNJOwzT36kl1lf38nekwRbBBRMj590qJvBBbsDljhxtFVWLf628 XBv1e/pUUjjVQMSY51yp2mnUn/oBy6iLMhu3yW2dxxIvbVxfHUkYkiSEX+OqPzV4UrxU 2DhFRMWtic8tUzESLQBCSi7RHFJIwY550eAeqnVe4xIe1l5NSwRVK43KpniGkZvGo4Rg +dOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714343475; x=1714948275; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=osBKKwwpR/+9hL2wkALs6vJuDNYhp8UoHBeiito79xI=; b=AbgxPjBctYa+PFwV0LTH2G0JNMrYPXDGHGl4fo3QGUifnuBSJShrcjMZuLHhAx6Tzh B8Tm18Q5omdRLdVs8ZKNLXxBEPy9ieO+suf5kOve3y2iof9NTqAzJ71eg4ozgC2XH7Ql P/iTRurS0tc0eDceuVbUDjQdDxRcjdEiOSE4XVJnTc1KaM/mAh8Ir7Am4ndOGg6bGWHO XdjnCIfFDOsXhG/e1OEwZL6W7h9/bbUsGXOabi/dgwECpNVw/hPJuQ/Dob1lwbXRGDw8 kNOlo2WCV6aoxcRtLAr/bq5fWomc21o/lzhddRYnGXp/UH9a78X70F5vb365gTn88gK3 o3ZA== X-Gm-Message-State: AOJu0YyVW94HXqpZNwWYI1/ZtgzBzTY7gGbkF5rE+3ijZpJWvDsAFdi1 1+4B51phg8ppKUiwkp/quOVP0YU7JY6JLG+byUFUFvLKHNGXsPQFJkAinA== X-Google-Smtp-Source: AGHT+IG1wlMZX+7gokpZBnn9sd33eVGlNgVWhQK3gWInpYkJ+PadjFNW9WP93omRG68kLso1KOSitw== X-Received: by 2002:a05:600c:3108:b0:41b:b884:f151 with SMTP id g8-20020a05600c310800b0041bb884f151mr4439618wmo.34.1714343475592; Sun, 28 Apr 2024 15:31:15 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n40-20020a05600c502800b0041b4c293f75sm14052311wmr.13.2024.04.28.15.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 15:31:15 -0700 (PDT) Message-Id: <33e128496b3d250b45a27490fa45d40cb659c3b2.1714343461.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 28 Apr 2024 22:31:01 +0000 Subject: [PATCH 13/13] tests: add tests for the new url-parse builtin Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Matheus Moreira , Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira From: Matheus Afonso Martins Moreira Test git URL parsing, validation and component extraction on all documented git URL schemes and syntaxes. Signed-off-by: Matheus Afonso Martins Moreira --- t/t9904-url-parse.sh | 194 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100755 t/t9904-url-parse.sh diff --git a/t/t9904-url-parse.sh b/t/t9904-url-parse.sh new file mode 100755 index 00000000000..f147f00591c --- /dev/null +++ b/t/t9904-url-parse.sh @@ -0,0 +1,194 @@ +#!/bin/sh +# +# Copyright © 2024 Matheus Afonso Martins Moreira +# + +test_description='git url-parse tests' + +. ./test-lib.sh + +test_expect_success 'git url-parse -- ssh syntax' ' + git url-parse "ssh://user@example.com:1234/repository/path" && + git url-parse "ssh://user@example.com/repository/path" && + git url-parse "ssh://example.com:1234/repository/path" && + git url-parse "ssh://example.com/repository/path" +' + +test_expect_success 'git url-parse -- git syntax' ' + git url-parse "git://example.com:1234/repository/path" && + git url-parse "git://example.com/repository/path" +' + +test_expect_success 'git url-parse -- http syntax' ' + git url-parse "https://example.com:1234/repository/path" && + git url-parse "https://example.com/repository/path" && + git url-parse "http://example.com:1234/repository/path" && + git url-parse "http://example.com/repository/path" +' + +test_expect_success 'git url-parse -- scp syntax' ' + git url-parse "user@example.com:/repository/path" && + git url-parse "example.com:/repository/path" +' + +test_expect_success 'git url-parse -- username expansion - ssh syntax' ' + git url-parse "ssh://user@example.com:1234/~user/repository" && + git url-parse "ssh://user@example.com/~user/repository" && + git url-parse "ssh://example.com:1234/~user/repository" && + git url-parse "ssh://example.com/~user/repository" +' + +test_expect_success 'git url-parse -- username expansion - git syntax' ' + git url-parse "git://example.com:1234/~user/repository" && + git url-parse "git://example.com/~user/repository" +' + +test_expect_success 'git url-parse -- username expansion - scp syntax' ' + git url-parse "user@example.com:~user/repository" && + git url-parse "example.com:~user/repository" +' + +test_expect_success 'git url-parse -- file urls' ' + git url-parse "file:///repository/path" && + git url-parse "file:///" && + git url-parse "file://" +' + +test_expect_success 'git url-parse -c protocol -- ssh syntax' ' + test ssh = "$(git url-parse -c protocol "ssh://user@example.com:1234/repository/path")" && + test ssh = "$(git url-parse -c protocol "ssh://user@example.com/repository/path")" && + test ssh = "$(git url-parse -c protocol "ssh://example.com:1234/repository/path")" && + test ssh = "$(git url-parse -c protocol "ssh://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c protocol -- git syntax' ' + test git = "$(git url-parse -c protocol "git://example.com:1234/repository/path")" && + test git = "$(git url-parse -c protocol "git://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c protocol -- http syntax' ' + test https = "$(git url-parse -c protocol "https://example.com:1234/repository/path")" && + test https = "$(git url-parse -c protocol "https://example.com/repository/path")" && + test http = "$(git url-parse -c protocol "http://example.com:1234/repository/path")" && + test http = "$(git url-parse -c protocol "http://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c protocol -- scp syntax' ' + test ssh = "$(git url-parse -c protocol "user@example.com:/repository/path")" && + test ssh = "$(git url-parse -c protocol "example.com:/repository/path")" +' + +test_expect_success 'git url-parse -c user -- ssh syntax' ' + test user = "$(git url-parse -c user "ssh://user@example.com:1234/repository/path")" && + test user = "$(git url-parse -c user "ssh://user@example.com/repository/path")" && + test "" = "$(git url-parse -c user "ssh://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c user "ssh://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c user -- git syntax' ' + test "" = "$(git url-parse -c user "git://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c user "git://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c user -- http syntax' ' + test "" = "$(git url-parse -c user "https://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c user "https://example.com/repository/path")" && + test "" = "$(git url-parse -c user "http://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c user "http://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c user -- scp syntax' ' + test user = "$(git url-parse -c user "user@example.com:/repository/path")" && + test "" = "$(git url-parse -c user "example.com:/repository/path")" +' + +test_expect_success 'git url-parse -c host -- ssh syntax' ' + test example.com = "$(git url-parse -c host "ssh://user@example.com:1234/repository/path")" && + test example.com = "$(git url-parse -c host "ssh://user@example.com/repository/path")" && + test example.com = "$(git url-parse -c host "ssh://example.com:1234/repository/path")" && + test example.com = "$(git url-parse -c host "ssh://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c host -- git syntax' ' + test example.com = "$(git url-parse -c host "git://example.com:1234/repository/path")" && + test example.com = "$(git url-parse -c host "git://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c host -- http syntax' ' + test example.com = "$(git url-parse -c host "https://example.com:1234/repository/path")" && + test example.com = "$(git url-parse -c host "https://example.com/repository/path")" && + test example.com = "$(git url-parse -c host "http://example.com:1234/repository/path")" && + test example.com = "$(git url-parse -c host "http://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c host -- scp syntax' ' + test example.com = "$(git url-parse -c host "user@example.com:/repository/path")" && + test example.com = "$(git url-parse -c host "example.com:/repository/path")" +' + +test_expect_success 'git url-parse -c port -- ssh syntax' ' + test 1234 = "$(git url-parse -c port "ssh://user@example.com:1234/repository/path")" && + test "" = "$(git url-parse -c port "ssh://user@example.com/repository/path")" && + test 1234 = "$(git url-parse -c port "ssh://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c port "ssh://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c port -- git syntax' ' + test 1234 = "$(git url-parse -c port "git://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c port "git://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c port -- http syntax' ' + test 1234 = "$(git url-parse -c port "https://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c port "https://example.com/repository/path")" && + test 1234 = "$(git url-parse -c port "http://example.com:1234/repository/path")" && + test "" = "$(git url-parse -c port "http://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c port -- scp syntax' ' + test "" = "$(git url-parse -c port "user@example.com:/repository/path")" && + test "" = "$(git url-parse -c port "example.com:/repository/path")" +' + +test_expect_success 'git url-parse -c path -- ssh syntax' ' + test "/repository/path" = "$(git url-parse -c path "ssh://user@example.com:1234/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "ssh://user@example.com/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "ssh://example.com:1234/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "ssh://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c path -- git syntax' ' + test "/repository/path" = "$(git url-parse -c path "git://example.com:1234/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "git://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c path -- http syntax' ' + test "/repository/path" = "$(git url-parse -c path "https://example.com:1234/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "https://example.com/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "http://example.com:1234/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "http://example.com/repository/path")" +' + +test_expect_success 'git url-parse -c path -- scp syntax' ' + test "/repository/path" = "$(git url-parse -c path "user@example.com:/repository/path")" && + test "/repository/path" = "$(git url-parse -c path "example.com:/repository/path")" +' + +test_expect_success 'git url-parse -c path -- username expansion - ssh syntax' ' + test "~user/repository" = "$(git url-parse -c path "ssh://user@example.com:1234/~user/repository")" && + test "~user/repository" = "$(git url-parse -c path "ssh://user@example.com/~user/repository")" && + test "~user/repository" = "$(git url-parse -c path "ssh://example.com:1234/~user/repository")" && + test "~user/repository" = "$(git url-parse -c path "ssh://example.com/~user/repository")" +' + +test_expect_success 'git url-parse -c path -- username expansion - git syntax' ' + test "~user/repository" = "$(git url-parse -c path "git://example.com:1234/~user/repository")" && + test "~user/repository" = "$(git url-parse -c path "git://example.com/~user/repository")" +' + +test_expect_success 'git url-parse -c path -- username expansion - scp syntax' ' + test "~user/repository" = "$(git url-parse -c path "user@example.com:~user/repository")" && + test "~user/repository" = "$(git url-parse -c path "example.com:~user/repository")" +' + +test_done