From patchwork Sun Jan 21 13:15:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13524581 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 4FD2D1EB37 for ; Sun, 21 Jan 2024 13:15:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842945; cv=none; b=u+JVxHodg+IL/bXs0AdLJdHnNG/3OKt35b/9Wb1hn8OLbuZkJZSpr7ttYyPv7dUYVmILFd+YnPWZ6E9IurvIn6hriFj/R8FgnmU3iDvLD5D8e6319y2/xyyZd0jUb9jAHRCNMQrwJHy1QduA1IHxUQ8IcSjw3grrrW9zAXFyjo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842945; c=relaxed/simple; bh=VTTvXlnLMU0oFGoD6VkDrMjbGf0bfpv+0/vY7ftzt6Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BRUa/923CMATVGd56k53MFjbDFXWBWw7f3yn9j1E9W1f7nK2YebQvyI64xQ709YHWHluJLp4Z9XkcZyQe7/AlBVlptwIhLYWkWhaCDN8dDe24s4HBvgvA+g81Xc31Tw+i14k+6/gVmEp1VX8rc/oCHuuEk5PleBGF3Nsl3E/2yE= 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=WZdz43Km; arc=none smtp.client-ip=209.85.210.181 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="WZdz43Km" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6dbcdbe13e1so492224b3a.3 for ; Sun, 21 Jan 2024 05:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705842943; x=1706447743; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wOc2EDUTzVq2aO/+vtOZQZl3p1U45Gfk21S5wJoNoxo=; b=WZdz43KmLQF/8PfT/o2PZnZ/fHMnbj4VaqtFKCE5SXeY3ULOpPeESotVEW+A+zzsrQ 9blzCcACAb1kR2d2Jc/Ok4UfuEqLrtcS/nLfstWrBLtZXrQKxsZWnO4zV9PgJNPybFO5 rChPUYCMnqKQY4ECZBbYtIWR+JyBiyiQLUTL539SQhI9WOhpKHXKxqrAEYNMgUEtXVP/ OJwD8ZkptnLfo8O7EUz3H+wYUA5PoQI0F1aV2kVD7C60CTuShgXmNKWdkcN1oymSn+PS /2Qe997uR4utLi/6xnPqwlUQdksLNrYwqoi3tL+b9Gg6cjwj+2VHfQDUG2DG2lYTsG7k cqfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705842943; x=1706447743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wOc2EDUTzVq2aO/+vtOZQZl3p1U45Gfk21S5wJoNoxo=; b=Ge+Gdda5tHlCr2LTJgvpLFHyPcY+mdwxtCRAn1CZWjomtrCND4c1top7dlx8INP1xb kz3lOUTy525+zIX5YOXXXjWTQfasYF+CNWjsdB7pHUuqoKdtFgOY/2Ls1Y3BdQHUYccP YWTcb6njhDQLhvj5JV57Lf3qolcN0t/OBGNOwJbBRv+mN5HPjYF/v6oKBki/jZnKgo5N kbLZGpH0UusWu6a1hFjV0Ek2kiRcg/fMCVhpG6z4FClJmFMHid4jpPTNmaxy8I7/kuEP u2F8sazf/bBULULs4FSjAGNR2ZEATExBvuc1GV+yWvW+DaUepTjcoiJmpuaSmfYCkBSS zIVA== X-Gm-Message-State: AOJu0YwBH4w+/8Yr5LZ5XmUI3T0LSE83B+1hm7UpKcWj5C6VXnEbXwjr ybhuLF0xkYcGjYEvl0Mm4twaR9MpPhs8X3Xvu1VnrTcKDGqOLTSrZEhVeDNC X-Google-Smtp-Source: AGHT+IFmuVcYOxRv8/rEEQif1/w/YBETEmGMLWdXvChcpcs1oAQHicHzcxgJupjUJn4qpmdcTzZqDA== X-Received: by 2002:a05:6a00:a93:b0:6da:cbee:9d9c with SMTP id b19-20020a056a000a9300b006dacbee9d9cmr1129357pfl.29.1705842943356; Sun, 21 Jan 2024 05:15:43 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id g5-20020a636b05000000b005bd980cca56sm6619005pgc.29.2024.01.21.05.15.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jan 2024 05:15:42 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Linus Arver Cc: Jiang Xin Subject: [PATCH v6 1/6] transport-helper: no connection restriction in connect_helper Date: Sun, 21 Jan 2024 21:15:33 +0800 Message-Id: <0994bc2d642501d0f9874773996cbb7ce26ef488.1705841443.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jiang Xin When commit b236752a (Support remote archive from all smart transports, 2009-12-09) added "remote archive" support for "smart transports", it was for transport that supports the ".connect" method. The "connect_helper()" function protected itself from getting called for a transport without the method before calling process_connect_service(), which only worked with the ".connect" method. Later, commit edc9caf7 (transport-helper: introduce stateless-connect, 2018-03-15) added a way for a transport without the ".connect" method to establish a "stateless" connection in protocol v2, where process_connect_service() was taught to handle the ".stateless_connect" method, making the old protection too strict. But commit edc9caf7 forgot to adjust this protection accordingly. Even at the time of commit b236752a, this protection seemed redundant, since process_connect_service() would return 0 if the connection could not be established, and connect_helper() would still die() early. Remove the restriction in connect_helper() and give the function process_connect_service() the opportunity to establish a connection using ".connect" or ".stateless_connect" for protocol v2. So we can connect with a stateless-rpc and do something useful. E.g., in a later commit, implements remote archive for a repository over HTTP protocol. Helped-by: Junio C Hamano Helped-by: Linus Arver Signed-off-by: Jiang Xin --- transport-helper.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/transport-helper.c b/transport-helper.c index 49811ef176..2e127d24a5 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -662,8 +662,6 @@ static int connect_helper(struct transport *transport, const char *name, /* Get_helper so connect is inited. */ get_helper(transport); - if (!data->connect) - die(_("operation not supported by protocol")); if (!process_connect_service(transport, name, exec)) die(_("can't connect to subservice %s"), name); From patchwork Sun Jan 21 13:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13524582 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 8E4653716C for ; Sun, 21 Jan 2024 13:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842947; cv=none; b=XV3xGXivFr7npcHaQXnsB+l515CBEeEDkTyhlRGyeepyiHCBY3F2C9G9K1jwMGS+D+r8096zgoLR+MSiPaVEL6QMZdVJ1Nu3HOD+jv26WyFnP3pTIkxrxtTjibOIxtALeHeGMCozV7PucF2iAV1WbAZh6SwgWlB+ZTkbwXF1Pfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842947; c=relaxed/simple; bh=KB7hJ7veuo+sIVGtCOFeU07Ih6ir3co//yLmTrnLgHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XNu8hxOSK7cSW2CxrrQPwddBTuPlMqWkLtpgnq/lMBSQ/MLszVrRPA6hpEYAXn3vQNlNxbtlh+qEsI0vlHVdWXKV2nWZZSHfU5GmLaiikAr9SEG2cvkALbjjpGZBm65Pj1mTy1dmsDLdv5aYv891iXk15T/fVwEaLZ2XzXS+JdY= 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=OXkX3lts; arc=none smtp.client-ip=209.85.167.171 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="OXkX3lts" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3bda6c92ce7so1425491b6e.2 for ; Sun, 21 Jan 2024 05:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705842944; x=1706447744; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t9FMJy0BfYncbOyA8v2BwB5v3NRrdoNxTP85p4a7NtI=; b=OXkX3ltshFJJtFmo1JN2qDMarxYeLrhoL0vKqG9KepxkfCjrL4ofOdYOm7Ck7vzU+s YEYSYuSN8ERFPJxuUoiPx7fBWsbmgjXpRCLaxsfJTWydHfC6yhGteh0W8ks+XSxA7WIh qKNc8shnG8D/z843n9JiXO5dVKuC2jdhRmkRm8SkSAPAk8kpeIl9O7i77N7+lDD0r7IB tqK4AkNMimDfNXEkATD9pnxnnCPJEOdCRomEV3d7N9EqX+A+k/g3w+lz7irdnJNOcbf3 RqV/CHj9eNmAy/MzLByn+v7PIIx3Glgem3h9hBYDpZmWRcOjCRlPEhT+In0PUiVizxNI MRVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705842944; x=1706447744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t9FMJy0BfYncbOyA8v2BwB5v3NRrdoNxTP85p4a7NtI=; b=DL9ZXAr6lVcTuEXRVbMjIDOZmeWtJJHd5j+YVpYlX3HXt8ndIgcMAsfzWLSIl3aehU JuapngSvWgogirXWt5qGJnpYc0M290Wm4/sRTdGmvNtnMZbLxJiQaTcEfeQ4twzCd/pO AOqi05LfiCXW6kQdjV2y0D2tf1d82hD6xuzDEqaVOTr1za0SmDnxUovyYThwcOOUEGk3 34DS5r3KlB/2a2fadZmieGccN6/KWCyLXJi0zm0nfLSs5W6d7vNeWhaDCZOquprkpgBy FurgW1zPsS0vH554carKbgN9RLZdfGb/Dedh1aONchaV7nhlvLYSieWBwM/vpRQggC+h wtvg== X-Gm-Message-State: AOJu0YwXrm5bQKhT0gCZXfuZ9z8dJzBO8c6c61gSGn9pihGy/kurwV/k sj8GdV5SlKVLlKLdkYLM3oD24ltsoJhsfBUSAEidXQfjYRyP10jr12HjT6Er X-Google-Smtp-Source: AGHT+IET1nq4lsy3EKPZw9tmn0gRopCTHAxqaWqtF+auVeoWI+B+gCyG/p/zVXfbhPK02KLoLXWjmA== X-Received: by 2002:a05:6358:3a14:b0:176:411b:888b with SMTP id g20-20020a0563583a1400b00176411b888bmr1934956rwe.17.1705842944234; Sun, 21 Jan 2024 05:15:44 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id g5-20020a636b05000000b005bd980cca56sm6619005pgc.29.2024.01.21.05.15.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jan 2024 05:15:43 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Linus Arver Cc: Jiang Xin Subject: [PATCH v6 2/6] remote-curl: supports git-upload-archive service Date: Sun, 21 Jan 2024 21:15:34 +0800 Message-Id: X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jiang Xin Add new service (git-upload-archive) support in remote-curl, so we can support remote archive over HTTP/HTTPS protocols. Differences between git-upload-archive and other services: 1. The git-archive program does not expect to see protocol version and capabilities when connecting to remote-helper, so do not send them in remote-curl for the git-upload-archive service. 2. We need to detect protocol version by calling discover_refs(). Fallback to use the git-upload-pack service (which, like git-upload-archive, is a read-only operation) to discover protocol version. Signed-off-by: Jiang Xin --- remote-curl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/remote-curl.c b/remote-curl.c index ef05752ca5..ce6cb8ac05 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1447,8 +1447,14 @@ static int stateless_connect(const char *service_name) * establish a stateless connection, otherwise we need to tell the * client to fallback to using other transport helper functions to * complete their request. + * + * The "git-upload-archive" service is a read-only operation. Fallback + * to use "git-upload-pack" service to discover protocol version. */ - discover = discover_refs(service_name, 0); + if (!strcmp(service_name, "git-upload-archive")) + discover = discover_refs("git-upload-pack", 0); + else + discover = discover_refs(service_name, 0); if (discover->version != protocol_v2) { printf("fallback\n"); fflush(stdout); @@ -1486,9 +1492,11 @@ static int stateless_connect(const char *service_name) /* * Dump the capability listing that we got from the server earlier - * during the info/refs request. + * during the info/refs request. This does not work with the + * "git-upload-archive" service. */ - write_or_die(rpc.in, discover->buf, discover->len); + if (strcmp(service_name, "git-upload-archive")) + write_or_die(rpc.in, discover->buf, discover->len); /* Until we see EOF keep sending POSTs */ while (1) { From patchwork Sun Jan 21 13:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13524583 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 D016137179 for ; Sun, 21 Jan 2024 13:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842947; cv=none; b=B7mXXCki9gYMJfjyqb02Mm+xw5aRvLASBFB/9S46Edr4kDIyUxxp4PP+z2QGkWodzpw6NI3ijY275HefNAAj/MSDFyF0vCx2kyD95BmdfHoH1aZAfjtmAV4xVQyHFBwa+SmNuBgvb6CcOfVz9yk5I+WXNLOM8aUHXr3Tw/5R1+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842947; c=relaxed/simple; bh=8mP5ZeO2XE4oNIaM9n6ADLDfJX4CmdtXPQVo35MR/uc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uEksxnniB6GPJXfCLMZ9f4VpXXb4Yna7Fb1dqSF37wrdPc2YIPasU49lbdj3gTMxAKruu3k6Bl0niyHewn1nruWYxLTfJL2ByKRBtWTh7Yf5ubEsqTJ7HyxBREBMi1rWg2KNbC7QKWFvCnFTywdp1owfQy0n6bZevfJssFv2KPM= 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=V26T2Vhu; arc=none smtp.client-ip=209.85.210.180 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="V26T2Vhu" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6dbdbddc180so274150b3a.2 for ; Sun, 21 Jan 2024 05:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705842945; x=1706447745; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aDf09HtepJJO4llaPqDFOSwRIGq0nxfm5RqIR+biF70=; b=V26T2Vhuw8/0X+52BqeOsofexBaIJcsMwud8U86zP2h5hkDFQqhkYpdWk5QKFd6KTF 8o0bMTZytfBL9vtawrZiyMqHqL+52mxE2V5WLeeX7qIECX22Zi2BWF8/ljodF1n6CZ0T T7aMqwj7IrWe1iC6MviR0ObkMT0DcGJOtNQmxO9WEUtdlVzrHLbJteBMJ3HXDEh8TLua u/wahyKzhcx9viT1YqRr0+W4GPq3hXqtkCf/xu0IJzItAC0f2Mw6WZVtVamLvycuzJ08 OOOADCOhuQuXuieYW9Y8QH6FsHuouwZ5SPjpcWAjJONIfogjnNB87w0F9PX7hz9mo6sW oD5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705842945; x=1706447745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aDf09HtepJJO4llaPqDFOSwRIGq0nxfm5RqIR+biF70=; b=b1lFs+H7/HOzU07bzY393QHaLBE9UVo9yzsMqluvGqeXdzHzYJ5X0amOVH+eWIicaE 3u/J6osJXAmfj2Q9BDaw6f14dHzo78nFrkafIJ3VAnDKplZklHAb8x6H68yFVnf5uGDg nAJvhO4WlYCSIfJv7nTUNRd9WZmvCf/5A72K0JRNkR9DRiXHsPtsbmCUT8L/Nx6kkuxz DGdRsrHwKxAT2Pao1eBG4e4Hob05TW5RqcO6iBM0zj3wpI4lCkd0b2wXUnLJenfEcJRu rW9mTFJNb3XmnczPG/6pkgu80TXBlYEL52shMl90JSDQnvNQtMBYQSq7/G9bKiwfycFu 4sMg== X-Gm-Message-State: AOJu0YyCTf6kw+J19UkrdhVswvAA1stj7GWqYcI3O/wqSy8QjsJfVdNG g+EhWAn9ZlHE+PAx+Al8zK2ou71e1Lr5hESbehEiqmJQNYkhPmDN2CZq14wh X-Google-Smtp-Source: AGHT+IGh91ZPVQIwbZ46UJgx7OSKKZ3Q85sjrEYFEDPnbTiEyHs/snClIrKZbdadqnvbKKvizzUbew== X-Received: by 2002:a05:6a20:6594:b0:199:87dc:4f0a with SMTP id p20-20020a056a20659400b0019987dc4f0amr2938663pzh.95.1705842945000; Sun, 21 Jan 2024 05:15:45 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id g5-20020a636b05000000b005bd980cca56sm6619005pgc.29.2024.01.21.05.15.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jan 2024 05:15:44 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Linus Arver Cc: Jiang Xin Subject: [PATCH v6 3/6] transport-helper: protocol v2 supports upload-archive Date: Sun, 21 Jan 2024 21:15:35 +0800 Message-Id: X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jiang Xin We used to support only git-upload-pack service for protocol v2. In order to support remote archive over HTTP/HTTPS protocols, add new service support for git-upload-archive in protocol v2. Signed-off-by: Jiang Xin --- transport-helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport-helper.c b/transport-helper.c index 2e127d24a5..6fe9f4f208 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -628,7 +628,8 @@ static int process_connect_service(struct transport *transport, ret = run_connect(transport, &cmdbuf); } else if (data->stateless_connect && (get_protocol_version_config() == protocol_v2) && - !strcmp("git-upload-pack", name)) { + (!strcmp("git-upload-pack", name) || + !strcmp("git-upload-archive", name))) { strbuf_addf(&cmdbuf, "stateless-connect %s\n", name); ret = run_connect(transport, &cmdbuf); if (ret) From patchwork Sun Jan 21 13:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13524584 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (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 224861EB37 for ; Sun, 21 Jan 2024 13:15:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842948; cv=none; b=U45qOxTCN4vNFUccuB+xLcX3rcTYgcqwJbnEnSAC6eMzMKRLQUTt1UhbgJZd4IIHL3HRyZ6PoJ05C6eyi7foeTEt2B4xu/ha7dg8+H6nNxRRA6AEJAyAA37lgUUOdo8NVXOZJnLtJBJtIDu6wBkJK9UCIo94CwfUTGnq/9biGYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842948; c=relaxed/simple; bh=A8ggfsAAido3UXW46H+H8bumqOBYX7Aqply9tNbF5ms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DYd0ml2oPs1a53ejG8ATizoDqLT0The+JM/0LbFrOPNSFwabvfGAO3fZFJYnF6AosHlCINTHPhjg4rWK3yq0kb6mcN+B8PrgIZbBpGVborligAkC6IbQYS5tRAllvH+W2jyrSrrssi6/TE6jAx+7uHMfhuR59IFZ3GhBJcMfGSA= 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=VdmFul6W; arc=none smtp.client-ip=209.85.166.53 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="VdmFul6W" Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-7ba903342c2so151738839f.3 for ; Sun, 21 Jan 2024 05:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705842946; x=1706447746; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AoNFgjU2uuAwx1uE3fJGx4ANiWcUafSa0KGE2hPV8Zg=; b=VdmFul6WTQiYixleRpVzw01HLSNCiLP2kHYX/zXSyxdYtuPxCb7ZTtg0rdx++1tscD l1Pjhmeo/DUjg/ufdJmsOQFAzdYob67gQU45H+Z269fXw3/Jm+1JoSpneCuV30ZE1IQ2 3NWGeQeijWEMo+EBsM2TfpFUv0ky5CSwXAag7GW4UD53sJhk20vqGFrHWjE1ACSQTCG1 PUTfjhpEo85eDoStIK0e8rpkmJM3cSirMrjzNgvQZpPf+ZhWYqm2j7qBNr989cDYYvBp /B7dREI4KyzfIV+Km8rI2KowA7JAKd8j1c0yauBKMKRuYbwQbj/H8I5TDaMzFGkP0yIo Tdxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705842946; x=1706447746; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AoNFgjU2uuAwx1uE3fJGx4ANiWcUafSa0KGE2hPV8Zg=; b=NBOoEeNJrNqNrvylQ2Q/jYf98rYu6916M4qIgYF/lNoC/pHz9GT6jq978nlU78EQj3 lsnyLnCZCz+HPO3XxUC2WLh8paCogi/slU4XaLQVMTuOW6koFQOjiL0ueGYsy7xUib2a +GFbgXNr4kA8QzrQ5pj3YPQufdbkl6pIA8lupTO6p7IZWFESsJ9G2ddJ/l839vstMveq qidb6LuXOiggRyuG1Om6UHzZbsduco1hY1AmN02qryZmeB+OE94IJ5nNOedeR2Xyqb9a VBO1SyAZyDwP1pRWuDyGcM+nh6bHfRULzN+b6ohM3Hs9cumW8XEVSocBpRjpL4D2zIqB /rdQ== X-Gm-Message-State: AOJu0Yzk2vNDfScVyMv7LIvfe1VPp2sY5mvnx07n8K6Va0nZQ3XgAA8W vstLX5lgExdnUH4/tp3cTXfxswrbqUzdlnCq6m/LhU0ZuScgWIkQIsKfEuCT X-Google-Smtp-Source: AGHT+IGb6yPm0Mm6b/YBjhx8ZyJgEmospaGzoFyL0uctxXmvhJ94nWNwGxyddavTzmsTPfTChvCPWA== X-Received: by 2002:a05:6e02:52d:b0:35f:fb58:e5be with SMTP id h13-20020a056e02052d00b0035ffb58e5bemr4414727ils.17.1705842945927; Sun, 21 Jan 2024 05:15:45 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id g5-20020a636b05000000b005bd980cca56sm6619005pgc.29.2024.01.21.05.15.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jan 2024 05:15:45 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Linus Arver Cc: Jiang Xin , Eric Sunshine Subject: [PATCH v6 4/6] http-backend: new rpc-service for git-upload-archive Date: Sun, 21 Jan 2024 21:15:36 +0800 Message-Id: <4a5d48859324b21092b95865d2d02f6fe83fa0ea.1705841443.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jiang Xin Add new rpc-service "upload-archive" in http-backend to add server side support for remote archive over HTTP/HTTPS protocols. Also add new test cases in t5003. In the test case "archive remote http repository", git-archive exits with a non-0 exit code even though we create the archive correctly. It will be fixed in a later commit. Helped-by: Eric Sunshine Signed-off-by: Jiang Xin --- http-backend.c | 13 ++++++++++--- t/t5003-archive-zip.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/http-backend.c b/http-backend.c index ff07b87e64..1ed1e29d07 100644 --- a/http-backend.c +++ b/http-backend.c @@ -38,6 +38,7 @@ struct rpc_service { static struct rpc_service rpc_service[] = { { "upload-pack", "uploadpack", 1, 1 }, { "receive-pack", "receivepack", 0, -1 }, + { "upload-archive", "uploadarchive", 0, -1 }, }; static struct string_list *get_parameters(void) @@ -639,10 +640,15 @@ static void check_content_type(struct strbuf *hdr, const char *accepted_type) static void service_rpc(struct strbuf *hdr, char *service_name) { - const char *argv[] = {NULL, "--stateless-rpc", ".", NULL}; + struct strvec argv = STRVEC_INIT; struct rpc_service *svc = select_service(hdr, service_name); struct strbuf buf = STRBUF_INIT; + strvec_push(&argv, svc->name); + if (strcmp(service_name, "git-upload-archive")) + strvec_push(&argv, "--stateless-rpc"); + strvec_push(&argv, "."); + strbuf_reset(&buf); strbuf_addf(&buf, "application/x-git-%s-request", svc->name); check_content_type(hdr, buf.buf); @@ -655,9 +661,9 @@ static void service_rpc(struct strbuf *hdr, char *service_name) end_headers(hdr); - argv[0] = svc->name; - run_service(argv, svc->buffer_input); + run_service(argv.v, svc->buffer_input); strbuf_release(&buf); + strvec_clear(&argv); } static int dead; @@ -723,6 +729,7 @@ static struct service_cmd { {"GET", "/objects/pack/pack-[0-9a-f]{64}\\.idx$", get_idx_file}, {"POST", "/git-upload-pack$", service_rpc}, + {"POST", "/git-upload-archive$", service_rpc}, {"POST", "/git-receive-pack$", service_rpc} }; diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh index fc499cdff0..6f85bd3463 100755 --- a/t/t5003-archive-zip.sh +++ b/t/t5003-archive-zip.sh @@ -239,4 +239,38 @@ check_zip with_untracked2 check_added with_untracked2 untracked one/untracked check_added with_untracked2 untracked two/untracked +# Test remote archive over HTTP protocol. +# +# Note: this should be the last part of this test suite, because +# by including lib-httpd.sh, the test may end early if httpd tests +# should not be run. +# +. "$TEST_DIRECTORY"/lib-httpd.sh +start_httpd + +test_expect_success "setup for HTTP protocol" ' + cp -R bare.git "$HTTPD_DOCUMENT_ROOT_PATH/bare.git" && + git -C "$HTTPD_DOCUMENT_ROOT_PATH/bare.git" \ + config http.uploadpack true && + set_askpass user@host pass@host +' + +setup_askpass_helper + +test_expect_success 'remote archive does not work with protocol v1' ' + test_must_fail git -c protocol.version=1 archive \ + --remote="$HTTPD_URL/auth/smart/bare.git" \ + --output=remote-http.zip HEAD >actual 2>&1 && + cat >expect <<-EOF && + fatal: can${SQ}t connect to subservice git-upload-archive + EOF + test_cmp expect actual +' + +test_expect_success 'archive remote http repository' ' + test_must_fail git archive --remote="$HTTPD_URL/auth/smart/bare.git" \ + --output=remote-http.zip HEAD && + test_cmp_bin d.zip remote-http.zip +' + test_done From patchwork Sun Jan 21 13:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13524585 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 D56C6374E7 for ; Sun, 21 Jan 2024 13:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842949; cv=none; b=fj37HQZc/lJTW5g2T5jnXydLLM8WWJxXHBbkuEa5rsmnq6Kq3k4TbPoHxXbMu7Aw9G8yoe51zsGDDzlHq4MbIMZFFmpsh0wVxzgtKn5bacn32J0+yCxUKxqPlHyJRvIatF2wqXK9phEO+9cIuvcTVoA2vUGzftxOH8CKEigVAPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842949; c=relaxed/simple; bh=ZZB2Me0hZC+F/869g+i1glDZFmrteYDQkUAxBYZfe+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ovj+B4s29vGJDksOj0xNYbUm9EouUsJAFRRte4Qfd2i9uKoTjQ6RqSLyLzFJ7sgNnF/ZMng7BB06IVllkd0kPwCMuRZUGnu7tS3axEay2UgxlNXvcfjgMZtAcfRmb7YxPb6GqXjABho7iaqi6Ba1jr2eAqCQoOvTkIJno3c1kcY= 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=UBPd8tF3; arc=none smtp.client-ip=209.85.210.175 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="UBPd8tF3" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6db05618c1fso2215438b3a.1 for ; Sun, 21 Jan 2024 05:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705842947; x=1706447747; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8dCfY9ji/XaEgjdygE1LRi3A8zh1vB9pDamO6bGmR2M=; b=UBPd8tF32oRVzGdSo6uvCZwCMllcVJ0de1dkrBjInLoMSh3tN/PGoKZ99eH6KJb3kz RwMdfj2PolqHrSWTaCcBqpxWkGHWZTpkAlAMxtri5/SgiZ0xN7msKQ9CnQVtlQCE258e ZrUIvK6q8v3e1F+y9zd9dNEsUCGiHCNZtn8EKGQwQ7JjAxSw4h3jMElcLYTdJ0kZlpa6 plJW0v3gx5682ThgjE4XpzU7VN3z0yUiclblNXFwvEk6A3BiedTAgEEiV+/lnxOm1ODJ eqkHsMOy+NKnGw+3kiOTfILlEQsMnwuV4BmZoE7qjQmfYtrCAaFwqZzYsN585k9liJDj J4EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705842947; x=1706447747; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8dCfY9ji/XaEgjdygE1LRi3A8zh1vB9pDamO6bGmR2M=; b=XTtQ+fnCin0lU79cMn2q6+eHdIY21FDL3myepGhn5xy4E8WmkFPDkpbBieILkhHk2J EUA9iuOvF8WbQKu+k/5FVioYnnwLJzZdOidwuzvXP8ckn3ouIldbSjs+00Mo3LHHX3+J w6VM82i2tzEdfqufhBMQghy6qD/aIA5bBVpWBSMpQIc0xNteLY2fcATs6s8aoxJ9VyCN zNDUsv9gaHF4Ayha3/6kR1vZOVPwMN03PmGFWbhxxVLRaGwnPfqM2Jx3q+wYJ+F4Yyff 5xXNqJqKtj/hLaoYonIkBJ7ZYaG1aUIB5AFOcqYrYBpdIrWPJitRspX51XhgqkMCMPoT 6xhg== X-Gm-Message-State: AOJu0YwIh19Ee0EiyM7JO6ehP0ciaHxDPEe1h1sVPwh7ZSQB0ve91vk1 xZYHQDnXHDJXtc0T9QDX2fXn0ENqYqYiWULRLOfjXnMPTul6XO4UBMQMPUla X-Google-Smtp-Source: AGHT+IHIu0bTlqOkgi7au+kCIN4mX6X8ojsjlLx193WqT12lm4ps/ExrwXmZLJNVSYO5Z8OJIvBnZQ== X-Received: by 2002:a05:6a20:4709:b0:19a:f6f1:c63f with SMTP id ek9-20020a056a20470900b0019af6f1c63fmr2833868pzb.72.1705842946910; Sun, 21 Jan 2024 05:15:46 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id g5-20020a636b05000000b005bd980cca56sm6619005pgc.29.2024.01.21.05.15.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jan 2024 05:15:46 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Linus Arver Cc: Jiang Xin Subject: [PATCH v6 5/6] transport-helper: call do_take_over() in connect_helper Date: Sun, 21 Jan 2024 21:15:37 +0800 Message-Id: <12a5b5e532f46558a0b4abaf80b45a670a0e7f88.1705841443.git.zhiyou.jx@alibaba-inc.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jiang Xin After successfully connecting to the smart transport by calling process_connect_service() in connect_helper(), run do_take_over() to replace the old vtable with a new one which has methods ready for the smart transport connection. This fixes the exit code of git-archive in test case "archive remote http repository" of t5003. The connect_helper() function is used as the connect method of the vtable in "transport-helper.c", and it is called by transport_connect() in "transport.c" to setup a connection. The only place that we call transport_connect() so far is in "builtin/archive.c". Without running do_take_over(), it may fail to call transport_disconnect() in run_remote_archiver() of "builtin/archive.c". This is because for a stateless connection and a service like "git-upload-archive", the remote helper may receive a SIGPIPE signal and exit early. Call do_take_over() to have a graceful disconnect method, so that we still call transport_disconnect() even if the remote helper exits early. Helped-by: Linus Arver Signed-off-by: Jiang Xin --- t/t5003-archive-zip.sh | 2 +- transport-helper.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh index 6f85bd3463..961c6aac25 100755 --- a/t/t5003-archive-zip.sh +++ b/t/t5003-archive-zip.sh @@ -268,7 +268,7 @@ test_expect_success 'remote archive does not work with protocol v1' ' ' test_expect_success 'archive remote http repository' ' - test_must_fail git archive --remote="$HTTPD_URL/auth/smart/bare.git" \ + git archive --remote="$HTTPD_URL/auth/smart/bare.git" \ --output=remote-http.zip HEAD && test_cmp_bin d.zip remote-http.zip ' diff --git a/transport-helper.c b/transport-helper.c index 6fe9f4f208..91381be622 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -669,6 +669,8 @@ static int connect_helper(struct transport *transport, const char *name, fd[0] = data->helper->out; fd[1] = data->helper->in; + + do_take_over(transport); return 0; } From patchwork Sun Jan 21 13:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13524586 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.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 D64A6374F5 for ; Sun, 21 Jan 2024 13:15:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842950; cv=none; b=X4tudn8dmlrbA1gTwLlFtBtHz02FqMEJcE56l7OAu6ysCCHIJxcg17De0Ew5GK8KrLZFLQ+88rA1KIqBoYh5edi3EAgNLuljZqtHB2bBW+JqtuS1GInDWQp13mSxSLyCxFLMfeNg/MFq9UCjnzG87pGjDM7+uNBHryRKYVBlp5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705842950; c=relaxed/simple; bh=v0bApPGYbw+NFOFCDWm4cQGKQcPc1sX0kUteFAizM6c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o4EXGooDFB1k9n34YDModcm0pKR+sUo9ZTsFvi7gs1Ecy+01IeKMeSzoR1WCfkv+fjYc6OJdZAMN5Squ6rQtaRhkNttkLw+nd73o+SD6HhSJvXto+b1wRlVEfsIV8RKRvNNet049+UnIuwNwgnbRvhX6xeXeMjmbJo9G6xpoubM= 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=aUWIIGvD; arc=none smtp.client-ip=209.85.161.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="aUWIIGvD" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-5997492d71cso596482eaf.2 for ; Sun, 21 Jan 2024 05:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705842948; x=1706447748; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CozsLbOmwkgZRdoKGjxxiV76kRVAqRlsUpx1KPOtBJg=; b=aUWIIGvDOpAnTnAPsBClCt2i6O9vA9strvKlYCty6tcQxOLE0GbkiRE7uBDk7KXjZW fnJXIWMEEyT+77rJaHOPf3RMmUR1AMiYT6DsrvDDYONVOa4Rqm9/PkXCikY3HKrETayA rHneoSwcXUiKvYqehGqjuy1aPCPxo8g3qVQewIxiCMwPu16c39TyK66KoF1LcpIwh6lx oj/QklUYYelZclPH9va6AJEzUYZEtw2huG/qXiADFNMlHyxdGudhY31GfCXmcuxXKQok CsAG0svFbLAV/lHz5HOGOx5Xy7vlsxY/Ugem7TTXKbx+OICCnUuTE2ieVEA9XRHxIxGD g3EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705842948; x=1706447748; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CozsLbOmwkgZRdoKGjxxiV76kRVAqRlsUpx1KPOtBJg=; b=kfPg+00+XMm6JnkkKeT9KaeW3PPaUanxVfshR3isCj0dq6IMQZEhmUei9VQIHEXOcG ddiA9WHsIJwQp652KiuFUsnaBQ3Bxp8AfyFctVRTTIEfJmeCeHS0IX/A61TZIMEztWBv QBMieh/n7/g7joSJb3mSwfd54JVLjqczrQUBNKRWRpNHGVOWG9aRGjGGPTdNCsaT3G9/ qIfer9zEQxNg/1kngNqclTlebo9rB3TI46QploK5VZtnZt5rolhTvM/10nYHY8t9LEIS z6SpW1KAA9BRG0L0Z5kDKemvjOo8UYpwk0XtRyYXiwSGMXd0mGwKF/MdYBNw7hH576pO jhuA== X-Gm-Message-State: AOJu0Yw2rj7Y79koLWNYIy7R8cpovPZT345LAvrXOSIjts0OvQfv8X1p TFB1MHMtYuQ8SWEtb8UwLBju1mx0qkmvgML0s+i2hkmyrmMyzhmgpM2PrNyp X-Google-Smtp-Source: AGHT+IGurcpwvprokjVosSHnd2fujk+uQPCXHRlwkozemnnxClz7ZI+xD68HHy3q6+vXwTKkj1jYAA== X-Received: by 2002:a05:6358:923:b0:176:4f39:406e with SMTP id r35-20020a056358092300b001764f39406emr379827rwi.54.1705842947673; Sun, 21 Jan 2024 05:15:47 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id g5-20020a636b05000000b005bd980cca56sm6619005pgc.29.2024.01.21.05.15.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jan 2024 05:15:47 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Linus Arver Cc: Jiang Xin Subject: [PATCH v6 6/6] transport-helper: call do_take_over() in process_connect Date: Sun, 21 Jan 2024 21:15:38 +0800 Message-Id: X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jiang Xin The existing pattern among all callers of process_connect() seems to be if (process_connect(...)) { do_take_over(); ... dispatch to the underlying method ... } ... otherwise implement the fallback ... where the return value from process_connect() is the return value of the call it makes to process_connect_service(). Move the call of do_take_over() inside process_connect(), so that calling the process_connect() function is more concise and will not miss do_take_over(). Suggested-by: Junio C Hamano Signed-off-by: Jiang Xin --- transport-helper.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/transport-helper.c b/transport-helper.c index 91381be622..566f7473df 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -646,6 +646,7 @@ static int process_connect(struct transport *transport, struct helper_data *data = transport->data; const char *name; const char *exec; + int ret; name = for_push ? "git-receive-pack" : "git-upload-pack"; if (for_push) @@ -653,7 +654,10 @@ static int process_connect(struct transport *transport, else exec = data->transport_options.uploadpack; - return process_connect_service(transport, name, exec); + ret = process_connect_service(transport, name, exec); + if (ret) + do_take_over(transport); + return ret; } static int connect_helper(struct transport *transport, const char *name, @@ -685,10 +689,8 @@ static int fetch_refs(struct transport *transport, get_helper(transport); - if (process_connect(transport, 0)) { - do_take_over(transport); + if (process_connect(transport, 0)) return transport->vtable->fetch_refs(transport, nr_heads, to_fetch); - } /* * If we reach here, then the server, the client, and/or the transport @@ -1145,10 +1147,8 @@ static int push_refs(struct transport *transport, { struct helper_data *data = transport->data; - if (process_connect(transport, 1)) { - do_take_over(transport); + if (process_connect(transport, 1)) return transport->vtable->push_refs(transport, remote_refs, flags); - } if (!remote_refs) { fprintf(stderr, @@ -1189,11 +1189,9 @@ static struct ref *get_refs_list(struct transport *transport, int for_push, { get_helper(transport); - if (process_connect(transport, for_push)) { - do_take_over(transport); + if (process_connect(transport, for_push)) return transport->vtable->get_refs_list(transport, for_push, transport_options); - } return get_refs_list_using_list(transport, for_push); } @@ -1277,10 +1275,8 @@ static int get_bundle_uri(struct transport *transport) { get_helper(transport); - if (process_connect(transport, 0)) { - do_take_over(transport); + if (process_connect(transport, 0)) return transport->vtable->get_bundle_uri(transport); - } return -1; }