From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (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 B8D4A3093B5 for ; Wed, 17 Jun 2026 17:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781716916; cv=none; b=A/l6m0awRnTfzW6N009TuySlznPRJopUpDexJYuqqnliwyYCSmSgVBQqHKYbbeLBzIuRJuezSCoN4jGiAD+Q2prhBEYiTr+ZgwVOHfHKmhLL5vmpybOmCB9jdGshODgWGAhT1j3ObLyjAc+tHBQXrcgxb15oUedT5IWsU9+oakI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781716916; c=relaxed/simple; bh=ak+GjipcEl2ZnKtYR9JZuWlfkVwun7zth33nkZ+GRRM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=phwiOqt7UENHALzwL8ELA1fjD1ckwvUp6OLhxf7v4vzb2U940NLAT9otIxBQ9iCz8pwSz5NZ11EUTdvwQ2Wx9ql2NfihcZK1qal3g+FHS82vJLbf/TSCwMUILzD+nRCcSj3m/PXFiPULgfROHsfLxjL4HhXeeFq3RBFh7SiOhZs= 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=j1GVXtEC; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Nc9gooJG; arc=none smtp.client-ip=202.12.124.154 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="j1GVXtEC"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Nc9gooJG" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id BDF687A00EA; Wed, 17 Jun 2026 13:21:53 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-04.internal (MEProxy); Wed, 17 Jun 2026 13:21:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; 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=1781716913; x=1781803313; bh=yqbFuSd967 49kw9ootCDvuNBmzFthtB2Je4aI5Y5474=; b=j1GVXtECTblPqIIfKVS/2uF+Zh OliLHv6cWQgRem9T7Np+xJyvIZ58ZJjLA/Sjxz86rz8LFCVQn7EvKG1olzwFFlmv STylqUGEKT5d/lRduYBILSv0X079sTTJrF0qg3sFLkadv6tuRdIxKloR5P5gmlvt uRVJ8zEF2ZjHzPr5+2aeihllMLQy8V43DmtCLX59zmC+Xv3yvcnnUQnCNvmvdfqP 0gNMyERPWZVAra4K0GFDCnHimSJRRiBQpQ5UBop0o8fBNGWVCCmsSJg/POc9XWyN V4+sW+ka4XGda9I6WJPknzB4fIx5WzJtefDmSY1/gBjntx4xikW6JZz7lLeQ== 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=fm1; t= 1781716913; x=1781803313; bh=yqbFuSd96749kw9ootCDvuNBmzFthtB2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Wdjn929ntFNz4mQg X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Jun 2026 13:21:53 -0400 (EDT) From: Junio C Hamano To: "Lutz Lengemann via GitGitGadget" Cc: git@vger.kernel.org, Lutz Lengemann Subject: Re: [PATCH] completion: zsh: support completion after "git -C " In-Reply-To: (Lutz Lengemann via GitGitGadget's message of "Wed, 17 Jun 2026 15:30:55 +0000") References: Date: Wed, 17 Jun 2026 10:21:50 -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 "Lutz Lengemann via GitGitGadget" writes: > From: Lutz Lengemann > > The zsh completion wrapper (__git_zsh_main) did not handle the global -C > option, so "git -C " offered nothing and could not > complete a command's arguments. I do not write, use, or customize zsh, so please take my comments with huge grains of salt, or just ignore them completely (your choice) ;-), but one thng I noticed was that ... > diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh > index c32186a977..323049be8b 100644 > --- a/contrib/completion/git-completion.zsh > +++ b/contrib/completion/git-completion.zsh > @@ -227,6 +227,7 @@ __git_zsh_main () > '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ > '(-p --paginate)--no-pager[do not pipe git output into a pager]' \ > '--git-dir=-[set the path to the repository]: :_directories' \ > + '*-C[run as if git was started in ]: :_directories' \ > '--bare[treat the repository as a bare repository]' \ > '(- :)--version[prints the git suite version]' \ > '--exec-path=-[path to where your core git programs are installed]:: :_directories' \ ... this part talks about not just "-C" but knows about all the other options that the "git" potty itself takes, while ... > @@ -252,6 +253,14 @@ __git_zsh_main () > ;; > (arg) > local command="${words[1]}" __git_dir __git_cmd_idx=1 > + local -a __git_C_args > + local -i i=2 > + > + while [[ ${orig_words[i]} == -C ]]; do > + __git_C_args+=(-C ${orig_words[i+1]}) > + (( __git_cmd_idx += 2 )) > + (( i += 2 )) > + done ... this only knows about "-C" and nothing else. Doesn't it want to do something similar to what __git_main in git-completion.bash does at the beginning, namely, this part? __git_main () { local i c=1 command __git_dir __git_repo_path local __git_C_args C_args_count=0 local __git_cmd_idx while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; --git-dir) ((c++)) __git_dir="${words[c]}" ;; --bare) __git_dir="." ;; --help) command="help" break ;; -c|--work-tree|--namespace) ((c++)) ;; -C) __git_C_args[C_args_count++]=-C ((c++)) __git_C_args[C_args_count++]="${words[c]}" ;; -*) ;; *) command="$i" __git_cmd_idx="$c" break ;; esac ((c++)) done