From patchwork Sun Mar 2 07:45:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mandelberg X-Patchwork-Id: 13997754 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 79ECA1BD01F for ; Sun, 2 Mar 2025 07:45:29 +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=1740901531; cv=none; b=F8xk3/RNA0thCQEXEoUoaF0+VSqu8U+bw0nDG+L9ik909DF0qIWmCU8ylnxupm5mFhqoRHtEY0HzewH6qxENBwo3WfjKm6N6kLWIrSat/htlfMY05DSOaXTQN1qraIOSj5W1WMab56YHJQUawiUZ0ktSL2KAQH5PwVTXx5ion+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740901531; c=relaxed/simple; bh=9UbH5fRM8D7OWySSr1WX3miOJ8ws8pKrd4Z5g1mCUao=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=UVUIUh0qII7Q8FauUm3ht9oNz9mYxehAGGQVtf2OryDSMDo5tmcAd1RpnrCBFHqnNhRjNk5x8TdnTfI0RzaTZ91CnL7t3iqGUCD+bvsgGjFj7MecjgD8f5TI4sm7Qa6kUD0hUigGQOo8FdtBs5YipoDxHqGedwQAtcKc9FpXIS0= 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=E7UolJ29; 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="E7UolJ29" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43994ef3872so21963925e9.2 for ; Sat, 01 Mar 2025 23:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740901527; x=1741506327; 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=AVHQO+bhQ6d4Sk4HDFa1QABWCGfs546zyD4jF4I39nM=; b=E7UolJ29dePTqkwz0+vIQ1dlgh1wB2JUZa1jpqEFh3b6f3R6ziFcgiTeXFmonYoVcQ UmteTGu60M1UhsyKQoicRLVagslG3o3I89pKKM99ps0dxGoOBtHmCZEWMwH8MTZ6BTgM xLrbDffgUMYahvyNyuqa3YcqT8Tz/ySmfQIWvAap9eTX7PoLcaIw1xEJqVWrTO3Vi/4Y DEN8umMeMNMDEXA6kWnh61yLdw1N1wF/pcZ9NLkc1UiFjuUnB9CdpLQucNPuqtHx6kGK bVgw/y97h6+MS4Gjl2f4aPpTOz3k4eNskBJO/1Ci1DGSdRmnjAVnMwW5HwvlOu/MlY54 NcfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740901527; x=1741506327; 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=AVHQO+bhQ6d4Sk4HDFa1QABWCGfs546zyD4jF4I39nM=; b=YoY18eaFcPkgpHdAC18i82gWNqlC03LEx3QMafrtuS8TxDhbscZkBN4kKJ0nA2QPFL DYiWa92FDatxxPOs31uGzNW42FeXYiYWqS9rIRPucYSzb+0ZgqyEvzymdSsHVstqVzk7 f3/h8NvDGEGBf3kTQsHIVm2PdBSBSl7l1/6D0a/Nmcly25Rpu0KiZPunGcikoevQ02c6 FBsoofzwsiswT8GzYN946zq3zNCokxnmQ9JweK3sVRvSW39CHh67czGsGthgYC4KN8IM W/7S0ePYGiNV56tn/7hqXVMeoUm3umPvV1PXi6JlHr6m9BwvChvKMI9xDVkKo3KSYND+ wcFg== X-Gm-Message-State: AOJu0YwIiRTGvJf0nqO1jOAJG5nzWbYInzSI0K4ck9bxZof/aXFvhlpB BU2fUdfcclKQ9B7z6PXCEUzZWESJLjJM+LDZQu2eYDc4B0wiLA5XWeO5hw== X-Gm-Gg: ASbGnctc7BSQe8d/+GhmBAvEXVRiXKXQZPlQ+CGdxIct/9ko43LIBBzyjFBGtTov63Y LghJ+xg6ZIexhtFGO3q0E0I5sodTXWAhbXmdN8putTn3wM+PpcwC+O9J0+DMplLDLzOOuReG1WJ zILuKiLBVJM5zSTZjymdvlBOfM460raYos8uydA3R9VDXR7ux9QTK3Upom7hVg+sAnTGjTdqZ9i 0Yfo0NbbZwjlyAnaGCm0JXiJ1u2S7tcpzGsnM1nBftqRmDfePNCQQUDutAHLySazF+kaM5xf6ts 4qCdzuUV4e/0eHP7FC5TX3whyxvC19HowT379eUi7XB6sQ== X-Google-Smtp-Source: AGHT+IGCC4dbdWVQQ1LXvkvcPgod3mPpFjh0yFUyMEYQgkJH9g+4tPsWvY9y+TIhL8qHkgtbkgxEMA== X-Received: by 2002:a05:600c:1c22:b0:439:8c80:6b02 with SMTP id 5b1f17b1804b1-43ba6a78efcmr81076555e9.31.1740901527277; Sat, 01 Mar 2025 23:45:27 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43bbc8b7cbesm7504225e9.37.2025.03.01.23.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 23:45:27 -0800 (PST) Message-Id: In-Reply-To: References: Date: Sun, 02 Mar 2025 07:45:23 +0000 Subject: [PATCH 1/3] completion: add helper to escape strings for fnmatch 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: Jacob Keller , Junio C Hamano , David Mandelberg , David Mandelberg From: David Mandelberg From: David Mandelberg A follow-up commit will use this to escape parts of ref names for for-each-ref. Signed-off-by: David Mandelberg --- contrib/completion/git-completion.bash | 12 ++++++++++++ t/t9902-completion.sh | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 413911be3be..cb10f818a81 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -234,6 +234,18 @@ __git_dequote () done } +# Escapes special characters in a string to pass to fnmatch(3) +# 1: String to escape. +__git_escape_fnmatch () +{ + local s="$1" + s=${s//\\/\\\\} + s=${s//\?/\\\?} + s=${s//\*/\\\*} + s=${s//\[/\\\[} + printf '%s\n' "$s" +} + # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 51bd7508376..c5e91622876 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -455,6 +455,13 @@ test_expect_success '__git_dequote - open double quote' ' ' +test_expect_success '__git_escape_fnmatch' ' + echo '\''foo\\\?\*\['\'' >expected && + __git_escape_fnmatch '\''foo\?*['\'' >"$actual" && + test_cmp expected "$actual" +' + + test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' ' sed -e "s/Z$//g" >expected <<-EOF && with-trailing-space Z From patchwork Sun Mar 2 07:45:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mandelberg X-Patchwork-Id: 13997755 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.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 859B71CAA63 for ; Sun, 2 Mar 2025 07:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740901532; cv=none; b=El2v4E0eLGdTVD0ij8kJmPrDteuOcBxFY0ffpZX2e4qY9Fm8jf0Nbnhq2X+Ys2wCY+8/BMV/cPwW0UOM7VPTruJGJee3TXDPx3U5Qw8uzvSRjirhnsABg14J1wPxKP8guwhORHF4bE/TuCgglZ9WD5zeGr3fV1TTToexZQ0CYLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740901532; c=relaxed/simple; bh=wlIdBiMv1fiJhoIUuBBJhZ4evLFUWhVh7K6dlRfB5bM=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=LmGC/R07pa/y1GNv+GYA/LuyDuLHShJxY2xpaO0i3M6BOaNk0aDyu6FizUdbod1g70Kme4vB3dU0S4VlZ/ZYShkLh6EhmaOLiGkKkW4LKrUOP9DCX3wAJAAmcE+hsFzQ9Bzt8ssi3z4FZJ1tUbdZeRHqYgsxRpValiqbjsyzTSs= 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=VEqfgA7J; arc=none smtp.client-ip=209.85.128.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="VEqfgA7J" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4399deda4bfso21566825e9.0 for ; Sat, 01 Mar 2025 23:45:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740901528; x=1741506328; 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=ilylWBto4J5A+PWbsJRGiLufFNXBA1Kk4go+uYkDWnE=; b=VEqfgA7Jwp68D6957c6BWQbSPi2lv5gQWacaEMGL7PTBL928HkIQB9MiOQ0bwt5Af5 xaO1KFxXV/nq8bZe2UCOSwT1rPK3L5wvfXO4m+RvrLf8CFsxk1yNEten3DmZkT0OW+vc cA8ItuK2d82GwWa9EcDYGRjNt017P35q35aKAYsLWAms3K79/rqD3iOSa1jBigJC9TuG qFPt/sLFOSg/pbFEM2VgPPJAkZNRH89NQhYa4AnyRUC1pLu6IwhPrO8eAuK69jnX26hr Pr2hR1h1U5NVXSb/pycTWYhbMPbAPxDn2YQxAKywAmzMIxkw9O718ZiAxK3rxFPWa8Ra iZPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740901528; x=1741506328; 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=ilylWBto4J5A+PWbsJRGiLufFNXBA1Kk4go+uYkDWnE=; b=ly/iKEcmrtdkAkrr+6+JkHiixvXWAQPWM8xJv0ObRrfO/6qZwuHWmJLQKsk+JGUulU Y+wGLODgzRxRIkZl5Yf1VaNILNMgYuxWKLR08FIkec4C8Z1+Wa9sDvvMpF4OO53q+TUC 10iYiSrOVRfH5aiaMqGCm7D/2ufxDvsklCc4YS8iJEbk41QbCKPQEPGNdl++EnryU0lv i1URgyw6E/SkGIwNwu4jb2z5pRlVzelxzexKWm3bDM1jRancytVN7Iz2C0BVuQLON1Rl fKblYnxkzCHMfC09oFQCkuQ+nuzYpVav5iUZOk+6CPFc4j8chMri3jJnd2dIHY3CuuHV PU/Q== X-Gm-Message-State: AOJu0YyqAykiCw4MUbEipTobIpWHP4HrXt85QnAmPlWxtlKdn9lNZRYW wn7Iih1vMjytBFjP5DaTz5/pkYuqsqkjrIHI/oAlyx8YxoThun3LnoyTMg== X-Gm-Gg: ASbGncvKElBfNfHDyF0PR6zOOmfJDYGpGS7Ci5PNAd3D0WaunvLOarWlFy5vOIwhQ6P 01KESs5jFwEsyf5od8SaJgvfsOOLlZQMxCj5odeel3Zr7erKkQKAS2RZ4jSbbAWWTJt2ql9GDnY 81Qkl+PdITq5LvS+rNQvbBnrKBZiZCmjwOcYv+chicnhE21J8hBVCkN6SL2jhkiOzjsQheCsc+/ eV4OOy0qNLmRqEB3kVPYH75cIt++lR//4yXWKdl3mzwAK1kCiC3M9goxMrP90xwEm8plbtaZHhZ Ft8KhVGm8eGpcXRdIGxdXxvF0JWsvwi++isEtZPqJBIPcw== X-Google-Smtp-Source: AGHT+IG82ZEQ5WT+KD20SdUVIVYJFqot13KUeo5/5ez24xx/Z8IheoGwZcMB3wGeTCVK06kLJdzzqw== X-Received: by 2002:a05:600c:4693:b0:439:88bb:d017 with SMTP id 5b1f17b1804b1-43ba66da7aamr70389365e9.6.1740901528403; Sat, 01 Mar 2025 23:45:28 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a6d0asm10439957f8f.27.2025.03.01.23.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 23:45:27 -0800 (PST) Message-Id: <4fab893d9fddd65b20d280edfb8cdf6ed8bfa295.1740901525.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 02 Mar 2025 07:45:24 +0000 Subject: [PATCH 2/3] completion: add helper to count path 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: Jacob Keller , Junio C Hamano , David Mandelberg , David Mandelberg From: David Mandelberg From: David Mandelberg A follow-up commit will use this with for-each-ref to strip the right number of path components from refnames. Signed-off-by: David Mandelberg --- contrib/completion/git-completion.bash | 11 +++++++++++ t/t9902-completion.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index cb10f818a81..17c044f7d60 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -246,6 +246,17 @@ __git_escape_fnmatch () printf '%s\n' "$s" } +# Prints the number of slash-separated components in a path. +# 1: Path to count components of. +__git_count_path_components () +{ + local path="$1" + local relative="${path#/}" + relative="${relative%/}" + local slashes="/${relative//[^\/]}" + echo "${#slashes}" +} + # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index c5e91622876..0219408358c 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -462,6 +462,32 @@ test_expect_success '__git_escape_fnmatch' ' ' +test_expect_success '__git_count_path_components - no slashes' ' + echo 1 >expected && + __git_count_path_components a >"$actual" && + test_cmp expected "$actual" +' + +test_expect_success '__git_count_path_components - relative' ' + echo 3 >expected && + __git_count_path_components a/b/c >"$actual" && + test_cmp expected "$actual" + +' + +test_expect_success '__git_count_path_components - absolute' ' + echo 3 >expected && + __git_count_path_components /a/b/c >"$actual" && + test_cmp expected "$actual" +' + +test_expect_success '__git_count_path_components - trailing slash' ' + echo 3 >expected && + __git_count_path_components a/b/c/ >"$actual" && + test_cmp expected "$actual" +' + + test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' ' sed -e "s/Z$//g" >expected <<-EOF && with-trailing-space Z From patchwork Sun Mar 2 07:45:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mandelberg X-Patchwork-Id: 13997756 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 927EA1D5CC6 for ; Sun, 2 Mar 2025 07:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740901534; cv=none; b=jtjsQV7uztGZ06Se5+eACiSqJqUCFO9WmNvO9cWAHthqjflf1JBPNf77YT5esrhzsMqnsEwq8zmk09rOc4IsVPVqpQIdD7DgBekjIS9kef8aMxgZYi93Eid5gZcqbze2N86FWfRSbXl2W7kQW/sCo+HhCf4mt1/ABxmBKh6UePQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740901534; c=relaxed/simple; bh=Nxg+iHI7LLZIZDZUqUUsMQiKPz3hq2iriFivUZKw2YA=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=RXT1vSMsiq1sW+IIPujpmui97+cjrLOUoBvfjfWICDRDukl4M4m7VtPqCu5ZidW80MDZyMv+lzX3jYdAtgH+cH3OFSrLA3Ug88TsQZBlZWVJUM3Wxv3Q6l4VKnrvZ4DD46HTdI6fqfwUPN+nbIAzIwN0iN2KUHrBCiIZDCoqV6Q= 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=EKI13ZfD; arc=none smtp.client-ip=209.85.128.41 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="EKI13ZfD" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-439a2780b44so21360535e9.1 for ; Sat, 01 Mar 2025 23:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740901529; x=1741506329; 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=/BhkRO3rnuqSGnUAFMPwYz5UBybkTVV/cQjnv9IwQwc=; b=EKI13ZfDQvr22lf0QtKC8PCOPzmdEEwFVTeooiitxBy0bIHvJQW/JBY2M4GFiwVOzF 0CF4r6IpubQnsrawb7Kpv/vcZ+9uUug7lnbDciJHZviUGVaZ5oME5skGm3VKc1MfHY90 bGkFqU4jMpSXx6x3/54SGFq0rMlRwa+/aDoHpICWQca+aPzA2Qf9sr3ShJhVORDEJo9C 9eoSlKZF7qM4WrGB60Bpwt9Bwtk8bVIBtctUok5J5FrM9bSKZI0enEebhZ1h2g5Dv1Xi AKEoaLdlVuDpDSphRBdmisT8QCdVmXqf/jEhxelCEhSHt+UqoD93jEFSi0iQYEF62gFP u4SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740901529; x=1741506329; 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=/BhkRO3rnuqSGnUAFMPwYz5UBybkTVV/cQjnv9IwQwc=; b=IgPZPCPYjSlzx2qjVpxGNSQQ+gieiCpazgeGIt4p7jQa6jUEGQxb32OYI7sZ0SI9/E 93JMcY5znmLR60ATnLq3Quf3D0oi7zVKg553qoM4kI7yK9cdReweV8R3q8Vkkd3skjPb 461TnGoTAuGw0+46xgtM1redHC2LKgvKfyYQYwpmpfMsj7fapOo+14gLSd++CpRt9ujV OdAkgkzpJaBCekHxXGx90iz+WRXSXkGn1H+FUkhhhwGPMQU/dqo6dcGsMhqRFQ32sniK qGnuAbQ9lAaKtJKTrCjzblF7Mt/SRZmOugwHmzPWUpwkoSfzkgiM6qexe4HZ+xRItnq7 5yvA== X-Gm-Message-State: AOJu0YxZ+iRQThZuRzxIARKlpKjUo9st1NuAFvV0F5uqjjsBTnuXOkXO EJiDiOTKtAGAQcIDHuDRxzowMKQWfXG//89GU12+hB1QOLt9pTvhZsf7jA== X-Gm-Gg: ASbGncsZiGG9sNsdeP7FuspvTVeDw4qMyaWqqo/WDtIBse7Epz8Lfdu/xsu4tvhKp0I 7qaWNoERpQ5Y5De6LwujpbcX3pPjtS+6rvPzNIoASrEhwjZ3pworUYbo+PNt5eeSZVXiCBY+uaY aLddzJ8jJchvnHXCG+WUaxryn7kKBpCZh1WKHLiEzFlALZIMngLBmmwHi1aKs0Gpd0HB1ExK2Id WCb9lyouyhLYtksW+c2hAFz8utRPYBlarUQgsEwd2OlAvnU6nAZsLiFKmrVEMJq+hdwcmposNlw e6LfRHKA5PUqXb+CzOq00uvZ6l/nk1zeBY3GVoCK9qv/qw== X-Google-Smtp-Source: AGHT+IHixIVrK9Ulry3IGe/qyaBI6W3ZLfxHmuitfg330Eq3S81qh8Ljng18nKcNuGZ/X9Ci6zZz2A== X-Received: by 2002:a05:600c:384b:b0:439:86fb:7340 with SMTP id 5b1f17b1804b1-43ba675ae8emr81902965e9.30.1740901529448; Sat, 01 Mar 2025 23:45:29 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43b7a27ab9fsm113054555e9.25.2025.03.01.23.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 23:45:28 -0800 (PST) Message-Id: <95ffa62df6ce394249a8ddabb84fb2b517825fe3.1740901525.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 02 Mar 2025 07:45:25 +0000 Subject: [PATCH 3/3] completion: fix bugs with slashes in remote names 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: Jacob Keller , Junio C Hamano , David Mandelberg , David Mandelberg From: David Mandelberg From: David Mandelberg Previously, some calls to for-each-ref passed fixed numbers of path components to strip from refs, assuming that remote names had no slashes in them. This made completions like: git push github/dseomn :com Result in: git push github/dseomn :dseomn/completion-remote-slash With this patch, it instead results in: git push github/dseomn :completion-remote-slash In addition, the change to __git_dwim_remote_heads() restricts it to only list remote branches, not HEAD. I think that actually improves the completion where it's used though, since HEAD doesn't seem to be valid anyway: $ git switch HEAD fatal: a branch is expected, got 'HEAD' Signed-off-by: David Mandelberg --- contrib/completion/git-completion.bash | 17 ++- t/t9902-completion.sh | 180 ++++++++++++++++++++++--- 2 files changed, 169 insertions(+), 28 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 17c044f7d60..5f4407be37f 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -807,11 +807,15 @@ __git_dwim_remote_heads () # employ the heuristic used by git checkout and git switch # Try to find a remote branch that cur_es the completion word # but only output if the branch name is unique - __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ - --sort="refname:strip=3" \ - ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \ - "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \ - uniq -u + local remote + for remote in $(__git_remotes); do + local base="$(__git_escape_fnmatch "refs/remotes/$remote")" + local strip="$(__git_count_path_components "$base")" + __git for-each-ref \ + --format="$fer_pfx%(refname:strip=$strip)$sfx" \ + ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \ + "$base/$cur_*" "$base/$cur_*/**" + done | sort | uniq -u } # Lists refs from the local (by default) or from a remote repository. @@ -917,7 +921,8 @@ __git_refs () case "HEAD" in $match*|$umatch*) echo "${pfx}HEAD$sfx" ;; esac - __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + local strip="$(__git_count_path_components "refs/remotes/$remote")" + __git for-each-ref --format="$fer_pfx%(refname:strip=$strip)$sfx" \ ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \ "refs/remotes/$remote/$match*" \ "refs/remotes/$remote/$match*/**" diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 0219408358c..0c41ef9d5b1 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -149,7 +149,8 @@ fi test_expect_success 'setup for __git_find_repo_path/__gitdir tests' ' mkdir -p subdir/subsubdir && mkdir -p non-repo && - git init -b main otherrepo + git init -b main otherrepo && + git init -b main slashrepo ' test_expect_success '__git_find_repo_path - from command line (through $__git_dir)' ' @@ -681,6 +682,13 @@ test_expect_success 'setup for ref completion' ' ) && git remote add other "$ROOT/otherrepo/.git" && git fetch --no-tags other && + ( + cd slashrepo && + git commit --allow-empty -m initial && + git branch -m main branch/with/slash + ) && + git remote add remote/with/slash "$ROOT/slashrepo/.git" && + git fetch --no-tags remote/with/slash && rm -f .git/FETCH_HEAD && git init thirdrepo ' @@ -693,6 +701,8 @@ test_expect_success '__git_refs - simple' ' other/HEAD other/branch-in-other other/main-in-other + remote/with/slash/HEAD + remote/with/slash/branch/with/slash matching-tag EOF ( @@ -709,6 +719,8 @@ test_expect_success '__git_refs - full refs' ' refs/remotes/other/HEAD refs/remotes/other/branch-in-other refs/remotes/other/main-in-other + refs/remotes/remote/with/slash/HEAD + refs/remotes/remote/with/slash/branch/with/slash refs/tags/matching-tag EOF ( @@ -774,6 +786,19 @@ test_expect_success '__git_refs - configured remote' ' test_cmp expected "$actual" ' +test_expect_success '__git_refs - configured remote - with slash' ' + cat >expected <<-EOF && + HEAD + HEAD + branch/with/slash + EOF + ( + cur= && + __git_refs remote/with/slash >"$actual" + ) && + test_cmp expected "$actual" +' + test_expect_success '__git_refs - configured remote - full refs' ' cat >expected <<-EOF && HEAD @@ -916,17 +941,19 @@ test_expect_success '__git_refs - unique remote branches for git checkout DWIMer other/ambiguous other/branch-in-other other/main-in-other - remote/ambiguous - remote/branch-in-remote + remote/with/slash/HEAD + remote/with/slash/ambiguous + remote/with/slash/branch-in-remote + remote/with/slash/branch/with/slash matching-tag - HEAD branch-in-other branch-in-remote + branch/with/slash main-in-other EOF for remote_ref in refs/remotes/other/ambiguous \ - refs/remotes/remote/ambiguous \ - refs/remotes/remote/branch-in-remote + refs/remotes/remote/with/slash/ambiguous \ + refs/remotes/remote/with/slash/branch-in-remote do git update-ref $remote_ref main && test_when_finished "git update-ref -d $remote_ref" || return 1 @@ -946,6 +973,8 @@ test_expect_success '__git_refs - after --opt=' ' other/HEAD other/branch-in-other other/main-in-other + remote/with/slash/HEAD + remote/with/slash/branch/with/slash matching-tag EOF ( @@ -962,6 +991,8 @@ test_expect_success '__git_refs - after --opt= - full refs' ' refs/remotes/other/HEAD refs/remotes/other/branch-in-other refs/remotes/other/main-in-other + refs/remotes/remote/with/slash/HEAD + refs/remotes/remote/with/slash/branch/with/slash refs/tags/matching-tag EOF ( @@ -979,6 +1010,8 @@ test_expect_success '__git refs - excluding refs' ' ^other/HEAD ^other/branch-in-other ^other/main-in-other + ^remote/with/slash/HEAD + ^remote/with/slash/branch/with/slash ^matching-tag EOF ( @@ -995,6 +1028,8 @@ test_expect_success '__git refs - excluding full refs' ' ^refs/remotes/other/HEAD ^refs/remotes/other/branch-in-other ^refs/remotes/other/main-in-other + ^refs/remotes/remote/with/slash/HEAD + ^refs/remotes/remote/with/slash/branch/with/slash ^refs/tags/matching-tag EOF ( @@ -1022,6 +1057,8 @@ test_expect_success '__git_refs - do not filter refs unless told so' ' other/branch-in-other other/main-in-other other/matching/branch-in-other + remote/with/slash/HEAD + remote/with/slash/branch/with/slash matching-tag matching/tag EOF @@ -1142,6 +1179,8 @@ test_expect_success '__git_complete_refs - simple' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z matching-tag Z EOF ( @@ -1180,6 +1219,20 @@ test_expect_success '__git_complete_refs - remote' ' test_cmp expected out ' +test_expect_success '__git_complete_refs - remote - with slash' ' + sed -e "s/Z$//" >expected <<-EOF && + HEAD Z + HEAD Z + branch/with/slash Z + EOF + ( + cur= && + __git_complete_refs --remote=remote/with/slash && + print_comp + ) && + test_cmp expected out +' + test_expect_success '__git_complete_refs - track' ' sed -e "s/Z$//" >expected <<-EOF && HEAD Z @@ -1188,9 +1241,11 @@ test_expect_success '__git_complete_refs - track' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z matching-tag Z - HEAD Z branch-in-other Z + branch/with/slash Z main-in-other Z EOF ( @@ -1235,6 +1290,8 @@ test_expect_success '__git_complete_refs - suffix' ' other/HEAD. other/branch-in-other. other/main-in-other. + remote/with/slash/HEAD. + remote/with/slash/branch/with/slash. matching-tag. EOF ( @@ -1260,6 +1317,20 @@ test_expect_success '__git_complete_fetch_refspecs - simple' ' test_cmp expected out ' +test_expect_success '__git_complete_fetch_refspecs - with slash' ' + sed -e "s/Z$//" >expected <<-EOF && + HEAD:HEAD Z + HEAD:HEAD Z + branch/with/slash:branch/with/slash Z + EOF + ( + cur= && + __git_complete_fetch_refspecs remote/with/slash && + print_comp + ) && + test_cmp expected out +' + test_expect_success '__git_complete_fetch_refspecs - matching' ' sed -e "s/Z$//" >expected <<-EOF && branch-in-other:branch-in-other Z @@ -1340,8 +1411,8 @@ test_expect_success '__git_complete_worktree_paths with -C' ' test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' ' test_completion "git switch " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1487,8 +1558,8 @@ test_expect_success 'git-bisect - existing view subcommand is recognized and ena test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' ' test_completion "git checkout " <<-\EOF HEAD Z - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1496,6 +1567,8 @@ test_expect_success 'git checkout - completes refs and unique remote branches fo other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1515,8 +1588,8 @@ test_expect_success 'git switch - with GIT_COMPLETION_CHECKOUT_NO_GUESS=1, compl test_expect_success 'git switch - --guess overrides GIT_COMPLETION_CHECKOUT_NO_GUESS=1, complete local branches and unique remote names for DWIM logic' ' GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git switch --guess " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1525,8 +1598,8 @@ test_expect_success 'git switch - --guess overrides GIT_COMPLETION_CHECKOUT_NO_G test_expect_success 'git switch - a later --guess overrides previous --no-guess, complete local and remote unique branches for DWIM' ' test_completion "git switch --no-guess --guess " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1549,14 +1622,16 @@ test_expect_success 'git checkout - with GIT_COMPLETION_NO_GUESS=1 only complete other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' test_expect_success 'git checkout - --guess overrides GIT_COMPLETION_NO_GUESS=1, complete refs and unique remote branches for DWIM' ' GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git checkout --guess " <<-\EOF HEAD Z - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1564,6 +1639,8 @@ test_expect_success 'git checkout - --guess overrides GIT_COMPLETION_NO_GUESS=1, other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1576,14 +1653,16 @@ test_expect_success 'git checkout - with --no-guess, only completes refs' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' test_expect_success 'git checkout - a later --guess overrides previous --no-guess, complete refs and unique remote branches for DWIM' ' test_completion "git checkout --no-guess --guess " <<-\EOF HEAD Z - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1591,6 +1670,8 @@ test_expect_success 'git checkout - a later --guess overrides previous --no-gues other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1603,6 +1684,8 @@ test_expect_success 'git checkout - a later --no-guess overrides previous --gues other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1616,6 +1699,8 @@ test_expect_success 'git checkout - with checkout.guess = false, only completes other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1623,8 +1708,8 @@ test_expect_success 'git checkout - with checkout.guess = true, completes refs a test_config checkout.guess true && test_completion "git checkout " <<-\EOF HEAD Z - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1632,6 +1717,8 @@ test_expect_success 'git checkout - with checkout.guess = true, completes refs a other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1639,8 +1726,8 @@ test_expect_success 'git checkout - a later --guess overrides previous checkout. test_config checkout.guess false && test_completion "git checkout --guess " <<-\EOF HEAD Z - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -1648,6 +1735,8 @@ test_expect_success 'git checkout - a later --guess overrides previous checkout. other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1661,6 +1750,8 @@ test_expect_success 'git checkout - a later --no-guess overrides previous checko other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1673,6 +1764,8 @@ test_expect_success 'git switch - with --detach, complete all references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1685,6 +1778,8 @@ test_expect_success 'git checkout - with --detach, complete only references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1857,6 +1952,8 @@ test_expect_success 'git switch - with -d, complete all references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1869,6 +1966,8 @@ test_expect_success 'git checkout - with -d, complete only references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1877,11 +1976,15 @@ test_expect_success 'git switch - with --track, complete only remote branches' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF test_completion "git switch -t " <<-\EOF other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1890,11 +1993,15 @@ test_expect_success 'git checkout - with --track, complete only remote branches' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF test_completion "git checkout -t " <<-\EOF other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1914,6 +2021,8 @@ test_expect_success 'git checkout - with --no-track, complete only local referen other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1926,6 +2035,8 @@ test_expect_success 'git switch - with -c, complete all references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1938,6 +2049,8 @@ test_expect_success 'git switch - with -C, complete all references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1950,6 +2063,8 @@ test_expect_success 'git switch - with -c and --track, complete all references' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1962,6 +2077,8 @@ test_expect_success 'git switch - with -C and --track, complete all references' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1974,6 +2091,8 @@ test_expect_success 'git switch - with -c and --no-track, complete all reference other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1986,6 +2105,8 @@ test_expect_success 'git switch - with -C and --no-track, complete all reference other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -1998,6 +2119,8 @@ test_expect_success 'git checkout - with -b, complete all references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -2010,6 +2133,8 @@ test_expect_success 'git checkout - with -B, complete all references' ' other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -2022,6 +2147,8 @@ test_expect_success 'git checkout - with -b and --track, complete all references other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -2034,6 +2161,8 @@ test_expect_success 'git checkout - with -B and --track, complete all references other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -2046,6 +2175,8 @@ test_expect_success 'git checkout - with -b and --no-track, complete all referen other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -2058,13 +2189,15 @@ test_expect_success 'git checkout - with -B and --no-track, complete all referen other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' test_expect_success 'git switch - for -c, complete local branches and unique remote branches' ' test_completion "git switch -c " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -2073,8 +2206,8 @@ test_expect_success 'git switch - for -c, complete local branches and unique rem test_expect_success 'git switch - for -C, complete local branches and unique remote branches' ' test_completion "git switch -C " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -2111,8 +2244,8 @@ test_expect_success 'git switch - for -C with --no-track, complete local branche test_expect_success 'git checkout - for -b, complete local branches and unique remote branches' ' test_completion "git checkout -b " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -2121,8 +2254,8 @@ test_expect_success 'git checkout - for -b, complete local branches and unique r test_expect_success 'git checkout - for -B, complete local branches and unique remote branches' ' test_completion "git checkout -B " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -2159,8 +2292,8 @@ test_expect_success 'git checkout - for -B with --no-track, complete local branc test_expect_success 'git switch - with --orphan completes local branch names and unique remote branch names' ' test_completion "git switch --orphan " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -2175,8 +2308,8 @@ test_expect_success 'git switch - --orphan with branch already provided complete test_expect_success 'git checkout - with --orphan completes local branch names and unique remote branch names' ' test_completion "git checkout --orphan " <<-\EOF - HEAD Z branch-in-other Z + branch/with/slash Z main Z main-in-other Z matching-branch Z @@ -2192,6 +2325,8 @@ test_expect_success 'git checkout - --orphan with branch already provided comple other/HEAD Z other/branch-in-other Z other/main-in-other Z + remote/with/slash/HEAD Z + remote/with/slash/branch/with/slash Z EOF ' @@ -2206,7 +2341,8 @@ test_expect_success 'git restore completes modified files' ' test_expect_success 'teardown after ref completion' ' git branch -d matching-branch && git tag -d matching-tag && - git remote remove other + git remote remove other && + git remote remove remote/with/slash '