From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13264 invoked from network); 1 Sep 2021 09:00:23 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Sep 2021 09:00:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=pI4NgYPRcxiNru4/Yj5lCswugC5qaj5xmTnThpKNOFk=; b=AyHeQSXbFz+MwoeFqHrkXsypDd KwD7vpSVOg3iUeYAaeRKbo0PoKXAfDw/uVKzK6VAjQitlNaz2oZ4RYzX/2nzAJ2cfMzEoYArC37Zc ZhWsYK+U3vBYPR1s7aSfIZSwZbagls+b6cFEtA94BHEVKHCr0FCtQLIHv7LHihsBo48WJcAnjPEO+ IcMSyWw1JVoFdoDIh34T8t1GL8N1lNwyZCN7+77tztxKCwoOtbMHzBdVtRKWYzhZ4ziBs61lTkoLv mfmNurebIoGJ67ZLvtR51jAIL3sNLWqQV+UE9vcKeYKUiYZpwi0SSmbvXNduBM6iFpdNi5K9ikibH CrJAFGyQ==; Received: from authenticated user by zero.zsh.org with local id 1mLM6Y-000Pqr-Ns; Wed, 01 Sep 2021 09:00:22 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mLM6G-000PZF-Rb; Wed, 01 Sep 2021 09:00:05 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mLM6E-000OQN-11; Wed, 01 Sep 2021 11:00:02 +0200 cc: zsh-workers@zsh.org In-reply-to: <1a7714b1-9e2b-a3f0-fd57-f99530943674@gmail.com> From: Oliver Kiddle References: <1a7714b1-9e2b-a3f0-fd57-f99530943674@gmail.com> To: Linus Kardell Subject: Re: git log .. autocompletion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <93889.1630486802.1@hydra> Date: Wed, 01 Sep 2021 11:00:02 +0200 Message-ID: <93890-1630486802.028529@suNr.owxF.3ER2> X-Seq: 49345 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Linus Kardell wrote: > Tab autocompletion does not seem to work for superdirectories for git > log. If you stand in a subdirectory of a git repo, type "git log .." or > "git log ../" and press tab you just get a list of branches (even though > none of them start with ".."), and if type "git log -- .." and press tab > nothing happens at all. This is with zsh 5.8 on openSUSE Tumbleweed. This seems to have been broken with the change in 36957/6a3de99. That change switched to using -r for a recursive listing to allow things like 'git log S/e' to expand to Src/exec.c This change first strips ../ components but then passes them to git ls-tree. (We perhaps should also do likewise for ./ components). I've also made it only add the -r if there's at least one slash in what remains which is an optimisation on a big repository with no loss of functionality. git ls-tree -r @ .. will list files in the current directory without any directory prefix. For completion, the effect is similar to the ignore-parents style with _files (arguably a feature) but may have undesirable effects with creative use of matching control. Does anyone think we should handle this properly at the cost of extra complexity? Oliver diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index a82b70e83..7c7fb22bc 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -7370,7 +7370,6 @@ __git_changed_files () { # which case it is relative to the repository root. (( $+functions[__git_tree_files] )) || __git_tree_files () { - local multi_parts_opts local tree Path integer at_least_one_tree_added local -a tree_files compadd_opts @@ -7383,11 +7382,12 @@ __git_tree_files () { zparseopts -D -E -a compadd_opts V+: J+: 1 2 o+: n f x+: X+: M+: P: S: r: R: q F: - [[ "$1" == */ ]] && Path="$1" || Path="${1:h}/" + Path=${(M)1##(../)#} + [[ ${1##(../)#} = */* ]] && extra_args+=( -r ) shift (( at_least_one_tree_added = 0 )) - for tree in $*; do - tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree -r ${(q)extra_args} --name-only -z ${(q)tree} 2>/dev/null)"}) + for tree; do + tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree $extra_args --name-only -z ${(q)tree} $Path 2>/dev/null)"}) __git_command_successful $pipestatus && (( at_least_one_tree_added = 1 )) done