Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D84A743D4FA for ; Tue, 11 Aug 2026 17:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786469111; cv=none; b=pIMCnhDkl3HnPE6chscjS8agxaPEmq4LXS3GGlepdBQ4dbf2qNu5BVXKcktNgQWRQ08cARdWWKn3N5+JU9Ys8UbCVi+aIATsKK/TBCgSDmwFkngLBf8OZIjMI8ZR8XD5y9TJdA/OYqwACblAZ2McUqYUqM7cyoRv6l6M0ThXvzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786469111; c=relaxed/simple; bh=ArtqEYi4h8RIsMMUen7H60OmTK0+aFT+5oulQBjEKXA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=UU40I8KaHjpuF38/1+SZQ/KfEtbn0LQfCs56Tn/4xFV6RJVkAoui3Jrd3bXTBvamUE/HA9Bai+WVYyxiLpWixNTuEQ6qflEJkgynJlXNmGGPsO77nPJ0cRF/VQM4Ch08A1Jur6YuMuopS/5AxUrNXKNbfLA3Wm+bogaCQ/vHs40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=s6vWtmrK; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YEDEOx6e; arc=none smtp.client-ip=103.168.172.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="s6vWtmrK"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YEDEOx6e" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 02F811400147; Tue, 11 Aug 2026 13:25:09 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-03.internal (MEProxy); Tue, 11 Aug 2026 13:25:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-transfer-encoding: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=fm2; t=1786469109; x=1786555509; bh=YEloKd4bkXtD5JX5Hwe8Xqcsuloowl0GQ+sbHj6eypY=; b= s6vWtmrKv6IHgjQbncjlAYYe6kQ8JnaW2Goyqxw6LqJazNzBzn/PTtF4RCK5bkT4 IWt5JUnsx795xiAZzB+Ml62H3CK2tzdmG92pUrRgENHBIigiAz220GlWHjd++7Tz QTsTDvvGViXxFx9DdDnL2vso1rcRqBrfKVEfhPtsWLLxoYBFzRvqcb+bFhfRsFpN VrDpJi/mpLIKxYbD/mnqqqWgLv7sSXBXSFVpscFhPq5+biAura3uNkWONFoeD030 9w7wt5d7h9kDP+P+1QezWBHVbo9ySDfi+swiacSqH1QfUA87vgUc4e14rEC/mbh7 HmRZ8DUIv1rlfCwFwFQYiA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1786469109; x= 1786555509; bh=YEloKd4bkXtD5JX5Hwe8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yN/8iiMe2HPImMg X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 11 Aug 2026 13:25:08 -0400 (EDT) From: Junio C Hamano To: Ben Knoble Cc: git@vger.kernel.org, Philippe Blain , Leo Kerin Britton , Elijah Newren , =?utf-8?Q?Rub=C3=A9n?= Justo , Patrick Steinhardt , =?utf-8?Q?G=C3=A1bor?= SZEDER Subject: Re: [PATCH 2/2] completion: complete tracked paths for "git checkout" In-Reply-To: <834FE315-FB34-47B7-9ACF-FC8194FBE8D5@gmail.com> (Ben Knoble's message of "Tue, 11 Aug 2026 12:32:05 -0400") References: <834FE315-FB34-47B7-9ACF-FC8194FBE8D5@gmail.com> Date: Tue, 11 Aug 2026 10:25:06 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Ben Knoble writes: >> >> Le 10 août 2026 à 23:21, Junio C Hamano a écrit : >> >> When completing arguments for "git checkout", _git_checkout() >> delegates to __git_complete_refs(), which only completes revision >> references. This is good, as mixing revisions and paths in a single >> list from which the user can choose is confusing. However, if no >> reference matches, or if "--" is given, _git_checkout() leaves >> COMPREPLY empty. Bash then falls back to the default filename >> completion in $PWD. >> >> This fails when "git -C " is used, as $PWD is not the target >> repository. >> >> Update _git_checkout() to use __git_complete_index_file() when "--" >> is present, or when revision reference completion yields no matching >> candidates, so that tracked paths are offered as candidates. >> >> Signed-off-by: Junio C Hamano >> --- >> contrib/completion/git-completion.bash | 4 ++++ >> t/t9902-completion.sh | 27 ++++++++++++++++++++++++++ >> 2 files changed, 31 insertions(+) >> >> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash >> index 38dec1cabe..bd4b6e9247 100644 >> --- a/contrib/completion/git-completion.bash >> +++ b/contrib/completion/git-completion.bash >> @@ -1780,6 +1780,10 @@ _git_checkout () >> ;; >> esac >> fi >> + >> + if [ ${#COMPREPLY[@]} -eq 0 ]; then >> + __git_complete_index_file >> + fi >> } > > Assuming the prior step was purely mechanical, which I did not validate, this looks reasonable to me. Actually the new call should use "--cached" to complete from the paths in the index, I think.