From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (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 44806474258 for ; Wed, 12 Aug 2026 16:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786553335; cv=none; b=Vc6MbrtwMrxxHn0Y27Z0+F8t/ED8W7gkiYtMqPcWFic4/4ZnYQOiPrJ7XDHk6uNC6YicvghV9Jsuvigm4msJ0OR3xdzFAAFJyFuirytWJGdt2IvtBwZpWqIW4uGsCPyycGSdTdCLYgNCyVj4a/Gt7tWjkyt/oaiCgPB5L31Mv3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786553335; c=relaxed/simple; bh=oTy5iv4pmoZEkgPawZd9nB5G/mzuQhY1DslzGqAYOTI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mi5Kyjb/zO9F35xcVwlh9Flfk74jZCDN3/VV1ZVhXM2TSgLbQr3DO3ruuedPdDsxPjJzcPs49Yn92Za3R8fhz/AuFJrn5SbpYNwHzg9FQLD3gcW34olHJNZW3Jkt3ub/YxduAL8Zd8lPcGSVgbDz0lT0RnRpAOB8nTiRn2SIejE= 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=FtL/ifXT; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=etuSnajy; arc=none smtp.client-ip=103.168.172.146 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="FtL/ifXT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="etuSnajy" Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 8B15FEC0227; Wed, 12 Aug 2026 12:48:50 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-10.internal (MEProxy); Wed, 12 Aug 2026 12:48:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :content-transfer-encoding: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=1786553330; x= 1786639730; bh=biEctt4Y7RpiGL9QozyOt5hru5xk14z4hlJHAYnwQm0=; b=F tL/ifXTStFSrAwfjkCC+rUty9iYswdcSaTf1J4LJ1n79xwVdGwULnQOys33TH2zN gg568nwIZF56TddpICy0DbKGR2mrDUUt0YP/FSR21z2cRP8kCOnudj48MT8iOe7j CDCgy2L+LfCBwynGzN53bRi6HGaEjFpru4JXIgEQMJoM9uQ5lD/HzBe1qQ8Su0pj YzA5ze4CCGSp0ojW0tPpeWvkWCx6cE1dFKH46nDS+dffKhrT8btZOY3IxNivz728 M2N/PZmH5If1EtO9zuwhSeJZLKMESW1vLgsnUAsn5/02LN3i3DiIEltQWAPr+RED FKbX7SFACjf7EBiA9Uz3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=1786553330; x=1786639730; bh=biEctt4Y7RpiGL9QozyOt5hru5xk 14z4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TwTlw X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Aug 2026 12:48:50 -0400 (EDT) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH v2 1/3] completion: no-op refactoring of checkout completion Date: Wed, 12 Aug 2026 09:48:44 -0700 Message-ID: <20260812164846.2236221-2-gitster@pobox.com> X-Mailer: git-send-email 2.55.0-721-g26b8014fc4 In-Reply-To: <20260812164846.2236221-1-gitster@pobox.com> References: <20260812164846.2236221-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The 'git checkout' completion function punts very early when it sees '--' on the command line, as it indicates that options or revisions can no longer appear. By returning early, it allows the default Bash action (which completes files in '$PWD') to kick in. In preparation for changing what happens in the next step when option or revision completion yields no matching candidates, or when '--' is present, reorganize the control flow to avoid this early return, and add explicit returns to the option completion branches. Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 84 +++++++++++++------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d35b4f3024..38dec1cabe 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1735,49 +1735,51 @@ __git_checkout_default_dwim_mode () _git_checkout () { - __git_has_doubledash && return - - local dwim_opt="$(__git_checkout_default_dwim_mode)" - - case "$prev" in - -b|-B|--orphan) - # Complete local branches (and DWIM branch - # remote branch names) for an option argument - # specifying a new branch name. This is for - # convenience, assuming new branches are - # possibly based on pre-existing branch names. - __git_complete_refs $dwim_opt --mode="heads" - return - ;; - *) - ;; - esac + if ! __git_has_doubledash; then + local dwim_opt="$(__git_checkout_default_dwim_mode)" - case "$cur" in - --conflict=*) - __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}" - ;; - --*) - __gitcomp_builtin checkout - ;; - *) - # At this point, we've already handled special completion for - # the arguments to -b/-B, and --orphan. There are 3 main - # things left we can possibly complete: - # 1) a start-point for -b/-B, -d/--detach, or --orphan - # 2) a remote head, for --track - # 3) an arbitrary reference, possibly including DWIM names - # + case "$prev" in + -b|-B|--orphan) + # Complete local branches (and DWIM branch + # remote branch names) for an option argument + # specifying a new branch name. This is for + # convenience, assuming new branches are + # possibly based on pre-existing branch names. + __git_complete_refs $dwim_opt --mode="heads" + return + ;; + *) + ;; + esac - if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then - __git_complete_refs --mode="refs" - elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then - __git_complete_refs --mode="remote-heads" - else - __git_complete_refs $dwim_opt --mode="refs" - fi - ;; - esac + case "$cur" in + --conflict=*) + __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}" + return + ;; + --*) + __gitcomp_builtin checkout + return + ;; + *) + # At this point, we've already handled special completion for + # the arguments to -b/-B, and --orphan. There are 3 main + # things left we can possibly complete: + # 1) a start-point for -b/-B, -d/--detach, or --orphan + # 2) a remote head, for --track + # 3) an arbitrary reference, possibly including DWIM names + # + + if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then + __git_complete_refs --mode="refs" + elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then + __git_complete_refs --mode="remote-heads" + else + __git_complete_refs $dwim_opt --mode="refs" + fi + ;; + esac + fi } __git_sequencer_inprogress_options="--continue --quit --abort --skip" -- 2.55.0-721-g26b8014fc4