From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.154 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796141932; b=Se7N/nKzjZgYqJULeJW+niMLE8b553RdoknFRKQscarhgdxiCcFn68amlHMyceFwzAOx Ioj7khvCOGOvH3V7V7ZGhHdGs4c1TQZg3AvDQDf48ScK9pAH5rDBsWmBvGVTO3b6F+SSb 9g++1Ae1tF9tQz48MlPv77KyMTkUny6SVCqMbIdTtZFBjFrqv25k7Wk6Y2KjtrqKxkh4s WItowT0Xu/bzanmyYMyyIgq4Dlg8x21Y9H3W3aozf2OsftMrLOFrNej1OKH2WUkrdLuVE R2lE9H7IRMB0KTr1Wpfy5w4io6yddzfNg5dsFvY6s/HI0r66XhTt8AQztDa+/VMtLag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796141932; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=HWKJFlfLmM1jokKKi0L5NPpMKfVwmv76579XOJsTc/k=; b=vOps/oK6qKYhlGPvI5wpsts8+bu5f8scXKUOrzorFh2GILOH/9e0qC93jp/CnNmLiunZ IWfGSVMWbRL/SQy+8SRWeuNJwKqoWTILCFSC/qP95qGAxBeRKU5Ie+m5qZbmmJtOXq4sY 9SEzVaEG2b451KwTt2Y1+/k+wVDMIDrMxxPurT5yxzfvgHSpQr/Tx47uj6nRHy82nLuh4 fnb7oYMsfA7SS6pd1Sx9N3vpBPwrRXz7CMMMhUmXcU/m5Lzg4uTXqfk9hFnnrpxsC1Fhq y11sjj7Z2UMZ8NO5U69ktvTJ5QLiF7rSdytyrmhhdTO9X5uM/q/dkHL4gShaSH73nlA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=xMF1Mk8d; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=LjG0oDnO; arc=none smtp.remote-ip=202.12.124.154 Received: from fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34EA3606A322 for ; Tue, 1 Dec 2026 16:18:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 34EA3606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=xMF1Mk8d; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=LjG0oDnO Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 85B237A0308 for ; Tue, 1 Dec 2026 11:18:51 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Tue, 01 Dec 2026 11:18:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796141931; x=1796228331; bh=HWKJFlfLmM 1jokKKi0L5NPpMKfVwmv76579XOJsTc/k=; b=xMF1Mk8dbXCYlT7GGYSIikj8MI t6jtyvR3Nufbpgbra2JN4GbKpegQ3tXIhbCTRyN1txIyEPnmAZXKE93cfbNiE6oe 613z6M2KwiwHtR2ywf0PMsXibvRBazQJAYAzqDsAYaA0xQhVnga5L1qC8RqkpqNp ln+6vxKPZjSK1S6gFSaFnm+rETf08xZB1/HVIR0Fmb9Shyg8vMZLPdqwqMYOrJ5B bhQLQcVFiG5PsaM+KOtN7xCvLsaZ2mszGMBUFuOL6v/op+8TVj74MxtAlo2bwuL4 8hgOOq/Y0ZrrFPfzZBNdpJoO5zmCaZVF2SLsN+qtZRMpdY3X0oJOl3gUyPJw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796141931; x=1796228331; bh=HWKJFlfLmM1jokKKi0L5NPpMKfVwmv76579 XOJsTc/k=; b=LjG0oDnO/q97OS0rUvi0NuWB4zcjx9ldZEOnElaeT23BYFd5Equ AKo8xI/s86w6nYr9Cwxi1JYq/rq6bxY6nsjfurKk8Hg72h9FPg/DYuvbIlBIGU+D q8TmF5CrR0FjO5FfVjqiZngOSK4zCb925/lalGPky+gTD/LWTI6gli2bY5SmYGbw zCE60Ydi3g0tCI0zxRpTRzgypPTV2d4XC5+Em1ObcVZNcFAgLMxsxlhNl85HFaes Bvz2ogDDufrTGDznuor29psOIW7g8C99CpS3l4hxMBzB78HNi5oL5JuU4oE6F5fx E80B77xHIgXU6ul85jl1kCrHfNzNkXDhGVw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796141931; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:PXKc1Q7N/tXcbtVsM8SQW1u1jRvkBibdQUQg5J3wkN+qVel R5DB28g8RmBgpP9zuq3uwh6/BxYLJh33bvkIKbzZhAGHmUY5lGleGgMyjGWAY5Kh 3eMXQw4p4phhNDuo0S5QCBFm8yfO//v2dJH/S3TJ0DB7Fc+itTBtZd2+cR/iiMdH wSN1P0ygIXB73zYqPKiWZhprE9DV01RDd0ZGo0d5CDCXGpWF881Iq6yhMg5Hwa5E jB0inT6OY/ws6B2nugw0VcNR6r/zz5xuQZmYSwLo5az5jzaaeCCTZWkWNXgyu+MM zpV/sQK03++xXvUbIW8Y/DP0UUvhbykxS9LpCig==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:KraSZek7Js5LfuCqiYoK6f3w29YdZByVs8TfCAYPsxk=:9tFrAgfyjrjMKGp6k35QKUOYwd87A8ijYMvGjONAwqY=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEL93RU2pVZAWm7h41S8z82P2cBLjoGVqvg0dQqmHOAq8+xDd2D64EP9UQsDn5XY5 73/7aMWqmK4OdqewGEstfVPoCBa+reGIjimuZa7QMCf/xYxPwMMdN/33j2n0dfzgkN4czb Cn1lHFLKtqAOG69HPdqHjgW1EzmtHlQqIFEq66DPIuQ0wJhgcKOR8v1dsVyKvYMb1UwoUn D/xibhJ0lvyAHwSFOt4dXKEyPNj11uVRbgv8/irRzq3ut7EjeWUpH78aKOoCrF/+/AzhAp tlY90akX6NDTQUrWZuJGdKH/vZfMG4onAP63Hama525wpOLDp+b5EIM8f7YKdhJHwSIMMw dyhSf6I9aEkbX6QOk+m0k65ifYQ6g41Gt1Rog7+wvbd5FcKOYI+zXxzwaA8cyz+7Vat33r uIH6V22lpqkzbviJyTgUdfMJJ/NQHQHS+JrENMZ0Nven6jaq08JRSZXlrOuUmB6T5AlZUJ muoFaK+H0XS6ekH4iOaVJzbVI0kpLheaqKsktGv103eruofAkMQf43//j4Q2pwY5CxPw15 HqYHFHJWfgbc+dY4h0jkwBWdZ6MSgLnf4o1Sod8iwrY7H3r8+wFMw7ktv+WpDAX8ogcSaG Px1abpKBqtslFLY4rXb0Bm5Vstf0f8+85JZSWfQ4MHESnB7P15c1VgEnqPwQ X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Dec 2026 11:18:50 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id 2cabcf1e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Dec 2026 16:18:49 +0000 (UTC) Date: Tue, 1 Dec 2026 17:18:46 +0100 From: Patrick Steinhardt To: Nahid Hasan via GitGitGadget Cc: git@vger.kernel.org, Nahid Hasan Subject: Re: [PATCH v2] push: shell-quote names in suggested push commands Message-ID: References: X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Nov 27, 2026 at 02:48:37AM +0000, Nahid Hasan via GitGitGadget wrote: > diff --git a/builtin/push.c b/builtin/push.c > index 2377b5af55..3908f5f532 100644 > --- a/builtin/push.c > +++ b/builtin/push.c > @@ -155,6 +156,9 @@ static NORETURN void die_push_simple(struct branch *branch, > const char *advice_automergesimple_maybe = ""; > const char *short_upstream = branch->merge[0]->src; > struct repo_config_values *cfg = repo_config_values(the_repository); > + struct strbuf quoted_remote = STRBUF_INIT; > + struct strbuf refspec = STRBUF_INIT; > + struct strbuf quoted_refspec = STRBUF_INIT; > > skip_prefix(short_upstream, "refs/heads/", &short_upstream); > > @@ -173,18 +177,26 @@ static NORETURN void die_push_simple(struct branch *branch, > "won't match the local branch, see option " > "'simple' of branch.autoSetupMerge\n" > "in 'git help config'.\n"); > + > + /* > + * Quote for copy-paste into a POSIX shell. Ordinary names stay > + * bare; metacharacters are wrapped in single quotes. > + */ I think it's unnecessary to document how the quoting is performed, that's none of our business here. So this can be a oneliner: /* Quote for copy-paste into a POSIX shell. */ > + strbuf_addf(&refspec, "HEAD:%s", short_upstream); > + sq_quote_buf_pretty("ed_remote, remote->name); > + sq_quote_buf_pretty("ed_refspec, refspec.buf); Do we need the extra `refspec` buffer? As far as I can see, `sq_quote_buf_pretty()` calls `sq_quote_buf()`, and that function handles the case where `dst.buf == src`. So: strbuf_aqqf("ed_refspec, "HEAD:%s", short_upstream); sq_quote_buf_pretty("ed_refspec, quoted_refspec.buf); > diff --git a/t/t5529-push-errors.sh b/t/t5529-push-errors.sh > index 5f8aa1ed19..57d50d8950 100755 > --- a/t/t5529-push-errors.sh > +++ b/t/t5529-push-errors.sh > @@ -94,4 +94,103 @@ test_expect_success 'detect ambiguous refs early' ' > test_cmp expect rp-ran > ' > > +# How a POSIX shell splits a copy-paste command line. > +shell_split () { > + line=$1 > + eval "set -- $line" > + printf "%s\n" "$#" "$@" > +} Aren't all of these tests it t5529 a tiny bit excessive only to verify that we quote the output correctly? It almost feels as if we're now unit-testing `sq_quote_buf()` itself, but if we wanted to do that we should do it via a proper unit test and not via git-push(1). Patrick