From patchwork Tue Aug 30 09:30:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F032C0502A for ; Tue, 30 Aug 2022 09:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231287AbiH3Jbq (ORCPT ); Tue, 30 Aug 2022 05:31:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230000AbiH3Jbn (ORCPT ); Tue, 30 Aug 2022 05:31:43 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A65E99B40 for ; Tue, 30 Aug 2022 02:31:43 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-11c4d7d4683so15347679fac.8 for ; Tue, 30 Aug 2022 02:31:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=lFTLPaWSHwhDaQSfY1P+2FkHzQtINHyZtFu31qB1Hq4=; b=FDJvIo4CnvDto4AkvhAlNGwgOZvh44hqHg6+gba9A0hjZFCMootZn85K7MlpPn7Kuu MoUw5dPBc14yzjTqRKzKqW0E/k6LomyYNjSSPyHT3FKziszxVYbqbMrNlMNKU/2Y+fmg KH2VkR6fa7yPN1qVs2M85HeVo9pYQiTy2lcpu2QJDnn9cAzDKgFkeYhJvRhyGg0cb9jV dm7bnrWhCcZCYaF1d2JEtqk4uneeaYtS6F3NbYBRkCq0uJinsPDk4Hmml69H6mH7/u5L j3CbGM8GRky1GCs8prb9FdwluYNDRKQJCQ2VdJWoU3ZIGheymdTXCPcK4TU6eprxsado QdTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=lFTLPaWSHwhDaQSfY1P+2FkHzQtINHyZtFu31qB1Hq4=; b=H8QS+h7QdcLjQ14qAPJXkQgBNtHkv/fusjKbzW+D+F654XOv8K8Wp8JFxM5/fjDNjl CNneEwOPjTbGVGMBaQfjMYBbbMn58wX6OWsDxdZzwCS1SdgbCU0dMFdebURYz2YwXlVs Zr2G5lPHrpEch2l5Ywnrvqx6ClJRFj4mu8DobfBhW9cmyulmXsBtbowv5iZGnSh6j37T iSVCEaLjBL4Ct6ZE6KEZtS5VwLMom7HzlrggsCUbgsB4W0OEtmouAsmN5dC0KJfKUz5j SfCG7dQHoQyIExHTU/XtIA4se3czBN/i+fiVDRqSVYgjrfrDxNPUZh9XYPU/3S4bzOz5 UG/g== X-Gm-Message-State: ACgBeo3UbtXDXd94VDTFbAqB1vrL1/f0NsIzLsEe/y32PTxnQ9SFKw1U Ixu3s/EuIXuq1t7LV8RG7ug4VOyZeiw= X-Google-Smtp-Source: AA6agR5vOyCrL+TpS+AoDuuwNMSFPokj9GflVnaJ2eNwrb9oD6cc73iaYi2OGFPWLuoTVkPI5WO+gA== X-Received: by 2002:a05:6808:f06:b0:343:2e08:ce93 with SMTP id m6-20020a0568080f0600b003432e08ce93mr8743254oiw.273.1661851901985; Tue, 30 Aug 2022 02:31:41 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id x17-20020a4ad051000000b00443abbc1f3csm6384266oor.24.2022.08.30.02.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:41 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 01/51] test: completion add test for __git_cmd_idx Date: Tue, 30 Aug 2022 04:30:48 -0500 Message-Id: <20220830093138.1581538-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When __git_func_wrap was fixed to set correctly __git_cmd_idx in cea232194d (completion: bash: fix late declaration of __git_cmd_idx, 2021-06-18) no test was added, therefore we could hit the same bug in the future. To ensure that doesn't happen add a test which adds an alias for 'git add' with __git_complete, and then pretend the user typed this alias. To make sure __git_cmd_idx is correct we add the --update option to ensure the result of __git_find_on_cmdline (which uses __git_cmd_idx) is correct. When __git_cmd_idx isn't correct __git_find_on_cmdline fails, and therefore the --update option isn't interpreted correctly. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 43de868b80..8cc30448c7 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2659,4 +2659,13 @@ test_expect_success '__git_complete' ' test_must_fail __git_complete ga missing ' +test_expect_success '__git_complete has correct __git_cmd_idx' ' + __git_complete ga _git_add && + echo modified > file1 && + touch file3 && + _words=(ga --update f) _cword=2 && + __git_wrap_git_add && + test "${COMPREPLY[*]}" = "file1" +' + test_done From patchwork Tue Aug 30 09:30:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20FC5ECAAA1 for ; Tue, 30 Aug 2022 09:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231363AbiH3Jbz (ORCPT ); Tue, 30 Aug 2022 05:31:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbiH3Jbr (ORCPT ); Tue, 30 Aug 2022 05:31:47 -0400 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41BF97FE58 for ; Tue, 30 Aug 2022 02:31:45 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id 92-20020a9d0be5000000b0063946111607so7656557oth.10 for ; Tue, 30 Aug 2022 02:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=L8bBXz9FeGY108pJhX9rhWd5kFTZL27t2OMRLk+yIfI=; b=pOBxykYJqHk3xhH5zlKAd9vIHmypIBjcL1VphiLfy1uN9RMaYB012EEqIqUH9ftsNI ZwmKTIBRfLmX3eKBLt+8BrbB13J6WocRuz+TxNpAUEBM+uVm00PjcIbxYM+VFDG5gSH+ 5IIya8h4+vBF24yqtVFKF32sijC5jNGulMeqmu1XcTcKWnUc9Hj7XgIv/QcheKAtaKY6 FFa5fybsPMbJxWMgabkRXz3HCxn4JWZfryemXBBdIxpSxkniUTHkfjKhY1ip+XyshVNp wVsTsGGuR5LbI2lUY58sOLkwGyAZofDW1ag+Rd1JytDP8WsVvnNxjZSezZevZ6EM7KOb oSmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=L8bBXz9FeGY108pJhX9rhWd5kFTZL27t2OMRLk+yIfI=; b=Yp4njQUOHJPeVNNJqSMRdqeYzz/VkOZ1sA/5v6F9JGyLyKI04YD/TndYrpbV+9XTEm y6k/Lgxwe00Lf9TJp4IegW2ZW6i3VJYB1lTJAR1I4FnttugG+yiVsl9Hch4fXurdz2vB +yW2Lif/KIMy6rpsvCFFnUbGfgZ7Pa05t2JUv6IItcxOeZa7k3duTQRXom5Gyx7M3Sr1 XlVveSER3TVlgFvDLzbomMK82YbFkV1J/iFn8HlekLdinBtcQmIOlaTr+V9NmDeyYms2 pCcWFbGJX1dr7pnVCLdDkv+EGKyMrRMwZB7Hdm0DvXzaZaDwROiNnsH5Jbe3GR/5q4lT ZZ7g== X-Gm-Message-State: ACgBeo3jLM7XtldMF/6ARi7m9cYZpVUp38Rvgzl9BU/jzT6JZckTCR/d 7QtgXax8VHFUbZU3aJn7h3GIuQSwMx4= X-Google-Smtp-Source: AA6agR6KXm48766MgxxEUEqLArZqaZHEtOtdMl5Zrgj8pIUMnn1dTl62Kk4UGi+VVRx68emGh8Pfrw== X-Received: by 2002:a05:6830:4110:b0:637:38e4:5aad with SMTP id w16-20020a056830411000b0063738e45aadmr8260167ott.382.1661851903941; Tue, 30 Aug 2022 02:31:43 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id d9-20020aca3609000000b00342ece494ffsm5808221oia.46.2022.08.30.02.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:43 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 02/51] test: add zsh completion tests Date: Tue, 30 Aug 2022 04:30:49 -0500 Message-Id: <20220830093138.1581538-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org zsh's completion system is very advanced, but that comes with a disadvantage: there is no easy way to dump the completions. The simplest way of doing that is printing them to stdout in a certain format, and then use the zpty module to parse that format and actually print them. There is no easier way. We also have to simulate `compadd` in order to output the list of completions in a way that is similar to the bash completion tests. The resulting test scripts is very close to the bash completion test script, except some tests don't make sense, and others require minor modifications. Signed-off-by: Felipe Contreras --- t/t9904-zsh-completion.sh | 1124 +++++++++++++++++++++++++++++++++++++ t/t9904/.gitignore | 1 + t/t9904/.zshrc | 50 ++ t/t9904/_git | 1 + t/t9904/completion | 11 + 5 files changed, 1187 insertions(+) create mode 100755 t/t9904-zsh-completion.sh create mode 100644 t/t9904/.gitignore create mode 100644 t/t9904/.zshrc create mode 120000 t/t9904/_git create mode 100755 t/t9904/completion diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh new file mode 100755 index 0000000000..5179b2dc76 --- /dev/null +++ b/t/t9904-zsh-completion.sh @@ -0,0 +1,1124 @@ +#!/bin/bash +# +# Copyright (c) 2012-2022 Felipe Contreras +# + +test_description='test zsh completion' + +. ./lib-bash.sh + +if ! command -v zsh > /dev/null 2>&1; then + skip_all='skipping completion zsh tests: zsh not available' + test_done +fi + +export GIT_BUILD_DIR + +run_completion () +{ + "$TEST_DIRECTORY/t9904/completion" "$1" > out + [[ -s out ]] || { echo > out ; } +} + +# Test high-level completion +# Arguments are: +# 1: typed text so far (cur) +# 2: expected completion +test_completion () +{ + if test $# -gt 1 + then + printf '%s\n' "$2" >expected + else + sed -e 's/Z$//' |sort >expected + fi && + run_completion "$1" && + sort -u out >out_sorted && + test_cmp expected out_sorted +} + +# Test __gitcomp. +# The first argument is the typed text so far (cur); the rest are +# passed to __gitcomp. Expected output comes is read from the +# standard input, like test_completion(). +test_gitcomp () +{ + sed -e 's/Z$//' >expected && + local cur="$1" && + shift && + run_completion "git func __gitcomp $(printf "%q " "$@") $cur" && + test_cmp expected out +} + +# Test __gitcomp_nl +# Arguments are: +# 1: current word (cur) +# -: the rest are passed to __gitcomp_nl +test_gitcomp_nl () +{ + sed -e "s/Z$//" >expected && + local cur="$1" && + shift && + run_completion "git func __gitcomp_nl $(printf "%q " "$@") $cur" && + test_cmp expected out +} + +actual="$TRASH_DIRECTORY/actual" + +if test_have_prereq MINGW +then + ROOT="$(pwd -W)" +else + ROOT="$(pwd)" +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 +' + +test_expect_success '__gitcomp - trailing space - options' ' + test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message= + --reset-author" <<-EOF + --reuse-message=Z + --reedit-message=Z + --reset-author Z + EOF +' + +test_expect_success '__gitcomp - trailing space - config keys' ' + test_gitcomp "br" "branch. branch.autosetupmerge + branch.autosetuprebase browser." <<-\EOF + branch.Z + branch.autosetupmerge Z + branch.autosetuprebase Z + browser.Z + EOF +' + +test_expect_success '__gitcomp - option parameter' ' + test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \ + "" "re" <<-\EOF + recursive Z + resolve Z + EOF +' + +test_expect_failure '__gitcomp - prefix' ' + test_gitcomp "branch.me" "remote merge mergeoptions rebase" \ + "branch.maint." "me" <<-\EOF + branch.maint.merge Z + branch.maint.mergeoptions Z + EOF +' + +test_expect_failure '__gitcomp - suffix' ' + test_gitcomp "branch.me" "master maint next seen" "branch." \ + "ma" "." <<-\EOF + branch.master.Z + branch.maint.Z + EOF +' + +test_expect_success '__gitcomp - ignore optional negative options' ' + test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF + --abc Z + --def Z + --no-one Z + --no-... Z + EOF +' + +test_expect_success '__gitcomp - ignore/narrow optional negative options' ' + test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF + --abc Z + --abcdef Z + EOF +' + +test_expect_success '__gitcomp - ignore/narrow optional negative options' ' + test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF + --no-one Z + --no-... Z + EOF +' + +test_expect_success '__gitcomp - expand all negative options' ' + test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF + --no-one Z + --no-two Z + EOF +' + +test_expect_success '__gitcomp - expand/narrow all negative options' ' + test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF + --no-one Z + EOF +' + +test_expect_failure '__gitcomp - equal skip' ' + test_gitcomp "--option=" "--option=" <<-\EOF && + + EOF + test_gitcomp "option=" "option=" <<-\EOF + + EOF +' + +read -r -d "" refs <<-\EOF +main +maint +next +seen +EOF + +test_expect_success '__gitcomp_nl - trailing space' ' + test_gitcomp_nl "m" "$refs" <<-EOF + main Z + maint Z + EOF +' + +test_expect_failure '__gitcomp_nl - prefix' ' + test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF + --fixup=main Z + --fixup=maint Z + EOF +' + +test_expect_success '__gitcomp_nl - suffix' ' + test_gitcomp_nl "branch.ma" "$refs" "branch." "ma" "." <<-\EOF + branch.main.Z + branch.maint.Z + EOF +' + +test_expect_success '__gitcomp_nl - no suffix' ' + test_gitcomp_nl "ma" "$refs" "" "ma" "" <<-\EOF + mainZ + maintZ + EOF +' + +test_expect_success 'setup for ref completion' ' + git commit --allow-empty -m initial && + git branch -M main && + git branch matching-branch && + git tag matching-tag && + ( + cd otherrepo && + git commit --allow-empty -m initial && + git branch -m main main-in-other && + git branch branch-in-other && + git tag tag-in-other + ) && + git remote add other "$ROOT/otherrepo/.git" && + git fetch --no-tags other && + rm -f .git/FETCH_HEAD && + git init thirdrepo +' + +test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' ' + test_completion "git switch " <<-\EOF + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' ' + test_completion "git checkout " <<-\EOF + HEAD Z + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with --no-guess, complete only local branches' ' + test_completion "git switch --no-guess " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - with GIT_COMPLETION_CHECKOUT_NO_GUESS=1, complete only local branches' ' + GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git switch " <<-\EOF + main Z + matching-branch Z + EOF +' + +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 + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +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 + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - a later --no-guess overrides previous --guess, complete only local branches' ' + test_completion "git switch --guess --no-guess " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - with GIT_COMPLETION_NO_GUESS=1 only completes refs' ' + GIT_COMPLETION_CHECKOUT_NO_GUESS=1 test_completion "git checkout " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other 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 + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with --no-guess, only completes refs' ' + test_completion "git checkout --no-guess " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other 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 + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - a later --no-guess overrides previous --guess, complete only refs' ' + test_completion "git checkout --guess --no-guess " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with checkout.guess = false, only completes refs' ' + test_config checkout.guess false && + test_completion "git checkout " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with checkout.guess = true, completes refs and unique remote branches for DWIM' ' + test_config checkout.guess true && + test_completion "git checkout " <<-\EOF + HEAD Z + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - a later --guess overrides previous checkout.guess = false, complete refs and unique remote branches for DWIM' ' + test_config checkout.guess false && + test_completion "git checkout --guess " <<-\EOF + HEAD Z + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - a later --no-guess overrides previous checkout.guess = true, complete only refs' ' + test_config checkout.guess true && + test_completion "git checkout --no-guess " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with --detach, complete all references' ' + test_completion "git switch --detach " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with --detach, complete only references' ' + test_completion "git checkout --detach " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with -d, complete all references' ' + test_completion "git switch -d " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with -d, complete only references' ' + test_completion "git checkout -d " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with --track, complete only remote branches' ' + test_completion "git switch --track " <<-\EOF + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with --track, complete only remote branches' ' + test_completion "git checkout --track " <<-\EOF + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with --no-track, complete only local branch names' ' + test_completion "git switch --no-track " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - with --no-track, complete only local references' ' + test_completion "git checkout --no-track " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with -c, complete all references' ' + test_completion "git switch -c new-branch " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with -C, complete all references' ' + test_completion "git switch -C new-branch " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with -c and --track, complete all references' ' + test_completion "git switch -c new-branch --track " <<-EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with -C and --track, complete all references' ' + test_completion "git switch -C new-branch --track " <<-EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with -c and --no-track, complete all references' ' + test_completion "git switch -c new-branch --no-track " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - with -C and --no-track, complete all references' ' + test_completion "git switch -C new-branch --no-track " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with -b, complete all references' ' + test_completion "git checkout -b new-branch " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with -B, complete all references' ' + test_completion "git checkout -B new-branch " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with -b and --track, complete all references' ' + test_completion "git checkout -b new-branch --track " <<-EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with -B and --track, complete all references' ' + test_completion "git checkout -B new-branch --track " <<-EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with -b and --no-track, complete all references' ' + test_completion "git checkout -b new-branch --no-track " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git checkout - with -B and --no-track, complete all references' ' + test_completion "git checkout -B new-branch --no-track " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'git switch - for -c, complete local branches and unique remote branches' ' + test_completion "git switch -c " <<-\EOF + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - for -C, complete local branches and unique remote branches' ' + test_completion "git switch -C " <<-\EOF + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - for -c with --no-guess, complete local branches only' ' + test_completion "git switch --no-guess -c " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - for -C with --no-guess, complete local branches only' ' + test_completion "git switch --no-guess -C " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - for -c with --no-track, complete local branches only' ' + test_completion "git switch --no-track -c " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - for -C with --no-track, complete local branches only' ' + test_completion "git switch --no-track -C " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - for -b, complete local branches and unique remote branches' ' + test_completion "git checkout -b " <<-\EOF + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - for -B, complete local branches and unique remote branches' ' + test_completion "git checkout -B " <<-\EOF + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - for -b with --no-guess, complete local branches only' ' + test_completion "git checkout --no-guess -b " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - for -B with --no-guess, complete local branches only' ' + test_completion "git checkout --no-guess -B " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - for -b with --no-track, complete local branches only' ' + test_completion "git checkout --no-track -b " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - for -B with --no-track, complete local branches only' ' + test_completion "git checkout --no-track -B " <<-\EOF + main Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - with --orphan completes local branch names and unique remote branch names' ' + test_completion "git switch --orphan " <<-\EOF + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git switch - --orphan with branch already provided completes nothing else' ' + test_completion "git switch --orphan main " <<-\EOF + + EOF +' + +test_expect_success 'git checkout - with --orphan completes local branch names and unique remote branch names' ' + test_completion "git checkout --orphan " <<-\EOF + branch-in-other Z + main Z + main-in-other Z + matching-branch Z + EOF +' + +test_expect_success 'git checkout - --orphan with branch already provided completes local refs for a start-point' ' + test_completion "git checkout --orphan main " <<-\EOF + HEAD Z + main Z + matching-branch Z + matching-tag Z + other/branch-in-other Z + other/main-in-other Z + EOF +' + +test_expect_success 'teardown after ref completion' ' + git branch -d matching-branch && + git tag -d matching-tag && + git remote remove other +' + +test_expect_success 'basic' ' + run_completion "git " && + # built-in + grep -q "^add\$" out && + # script + grep -q "^rebase\$" out && + # plumbing + ! grep -q "^ls-files\$" out && + + run_completion "git r" && + ! grep -q -v "^r" out +' + +test_expect_success 'double dash "git" itself' ' + test_completion "git --" <<-\EOF + --paginate + --no-pager + --git-dir + --bare + --version + --exec-path + --html-path + --man-path + --info-path + --work-tree + --namespace + --no-replace-objects + --help + EOF +' + +test_expect_success 'double dash "git checkout"' ' + test_completion "git checkout --" <<-\EOF + --quiet Z + --detach Z + --track Z + --orphan=Z + --ours Z + --theirs Z + --merge Z + --conflict=Z + --patch Z + --ignore-skip-worktree-bits Z + --ignore-other-worktrees Z + --recurse-submodules Z + --progress Z + --guess Z + --no-guess Z + --no-... Z + --overlay Z + --pathspec-file-nul Z + --pathspec-from-file=Z + EOF +' + +test_expect_success 'general options' ' + test_completion "git --ver" "--version" && + test_completion "git --hel" "--help" && + test_completion "git --exe" "--exec-path" && + test_completion "git --htm" "--html-path" && + test_completion "git --pag" "--paginate" && + test_completion "git --no-p" "--no-pager" && + test_completion "git --git" "--git-dir" && + test_completion "git --wor" "--work-tree" && + test_completion "git --nam" "--namespace" && + test_completion "git --bar" "--bare" && + test_completion "git --inf" "--info-path" && + test_completion "git --no-r" "--no-replace-objects" +' + +test_expect_failure 'general options plus command' ' + test_completion "git --version check" "" && + test_completion "git --paginate check" "checkout" && + test_completion "git --git-dir=foo check" "checkout" && + test_completion "git --bare check" "checkout" && + test_completion "git --exec-path=foo check" "checkout" && + test_completion "git --html-path check" "" && + test_completion "git --no-pager check" "checkout" && + test_completion "git --work-tree=foo check" "checkout" && + test_completion "git --namespace=foo check" "checkout" && + test_completion "git --paginate check" "checkout" && + test_completion "git --info-path check" "" && + test_completion "git --no-replace-objects check" "checkout" && + test_completion "git --git-dir some/path check" "checkout" && + test_completion "git -c conf.var=value check" "checkout" && + test_completion "git -C some/path check" "checkout" && + test_completion "git --work-tree some/path check" "checkout" && + test_completion "git --namespace name/space check" "checkout" +' + +test_expect_success 'git --help completion' ' + test_completion "git --help ad" "add " && + test_completion "git --help core" "core-tutorial " +' + +test_expect_success 'setup for integration tests' ' + echo content >file1 && + echo more >file2 && + git add file1 file2 && + git commit -m one && + git branch mybranch && + git tag mytag +' + +test_expect_success 'checkout completes ref names' ' + test_completion "git checkout m" <<-\EOF + main Z + mybranch Z + mytag Z + EOF +' + +test_expect_failure 'git -C checkout uses the right repo' ' + test_completion "git -C subdir -C subsubdir -C .. -C ../otherrepo checkout b" <<-\EOF + branch-in-other Z + EOF +' + +test_expect_success 'show completes all refs' ' + test_completion "git show m" <<-\EOF + main Z + mybranch Z + mytag Z + EOF +' + +test_expect_success ': completes paths' ' + test_completion "git show mytag:f" <<-\EOF + file1Z + file2Z + EOF +' + +test_expect_success 'complete tree filename with spaces' ' + echo content >"name with spaces" && + git add "name with spaces" && + git commit -m spaces && + test_completion "git show HEAD:nam" <<-\EOF + name with spacesZ + EOF +' + +test_expect_success 'complete tree filename with metacharacters' ' + echo content >"name with \${meta}" && + git add "name with \${meta}" && + git commit -m meta && + test_completion "git show HEAD:nam" <<-\EOF + name with ${meta}Z + name with spacesZ + EOF +' + +test_expect_success PERL 'send-email' ' + test_completion "git send-email --cov" <<-\EOF && + --cover-from-description=Z + --cover-letter Z + EOF + test_completion "git send-email --val" <<-\EOF && + --validate Z + EOF + test_completion "git send-email ma" "main " +' + +test_expect_success 'complete files' ' + git init tmp && cd tmp && + test_when_finished "cd .. && rm -rf tmp" && + + echo "expected" > .gitignore && + echo "out" >> .gitignore && + echo "out_sorted" >> .gitignore && + + git add .gitignore && + test_completion "git commit " ".gitignore" && + + git commit -m ignore && + + touch new && + test_completion "git add " "new" && + + git add new && + git commit -a -m new && + test_completion "git add " "" && + + git mv new modified && + echo modify > modified && + test_completion "git add " "modified" && + + mkdir -p some/deep && + touch some/deep/path && + test_completion "git add some/" "some/deep" && + git clean -f some && + + touch untracked && + + : TODO .gitignore should not be here && + test_completion "git rm " <<-\EOF && + .gitignore + modified + EOF + + test_completion "git clean " "untracked" && + + : TODO .gitignore should not be here && + test_completion "git mv " <<-\EOF && + .gitignore + modified + EOF + + mkdir dir && + touch dir/file-in-dir && + git add dir/file-in-dir && + git commit -m dir && + + mkdir untracked-dir && + + : TODO .gitignore should not be here && + test_completion "git mv modified " <<-\EOF && + .gitignore + dir + modified + untracked + untracked-dir + EOF + + test_completion "git commit " "modified" && + + : TODO .gitignore should not be here && + test_completion "git ls-files " <<-\EOF && + .gitignore + dir + modified + EOF + + touch momified && + test_completion "git add mom" "momified" +' + +test_expect_success "simple alias" ' + test_config alias.co checkout && + test_completion "git co m" <<-\EOF + main Z + mybranch Z + mytag Z + EOF +' + +test_expect_success "recursive alias" ' + test_config alias.co checkout && + test_config alias.cod "co --detached" && + test_completion "git cod m" <<-\EOF + main Z + mybranch Z + mytag Z + EOF +' + +test_expect_success "completion uses completion for alias: !sh -c 'git ...'" ' + test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" && + test_completion "git co m" <<-\EOF + main Z + mybranch Z + mytag Z + EOF +' + +test_expect_success 'completion uses completion for alias: !f () { VAR=val git ... }' ' + test_config alias.co "!f () { VAR=val git checkout ... ; } f" && + test_completion "git co m" <<-\EOF + main Z + mybranch Z + mytag Z + EOF +' + +test_expect_success 'completion used completion for alias: !f() { : git ; ... }' ' + test_config alias.co "!f() { : git checkout ; if ... } f" && + test_completion "git co m" <<-\EOF + main Z + mybranch Z + mytag Z + EOF +' + +test_expect_failure 'completion without explicit _git_xxx function' ' + test_completion "git version --" <<-\EOF + --build-options Z + --no-build-options Z + EOF +' + +test_expect_failure 'complete with tilde expansion' ' + git init tmp && cd tmp && + test_when_finished "cd .. && rm -rf tmp" && + + touch ~/tmp/file && + + test_completion "git add ~/tmp/" "~/tmp/file" +' + +test_expect_success 'setup other remote for remote reference completion' ' + git remote add other otherrepo && + git fetch other +' + +test_expect_success 'git config - section' ' + test_completion "git config br" <<-\EOF + branch.Z + browser.Z + EOF +' + +test_expect_success 'git config - section include, includeIf' ' + test_completion "git config inclu" <<-\EOF + include.Z + includeIf.Z + EOF +' + +test_expect_success 'git config - variable name' ' + test_completion "git config log.d" <<-\EOF + log.date Z + log.decorate Z + log.diffMerges Z + EOF +' + +test_expect_success 'git config - variable name include' ' + test_completion "git config include.p" <<-\EOF + include.path Z + EOF +' + +test_expect_success 'git config - value' ' + test_completion "git config color.pager " <<-\EOF + false Z + true Z + EOF +' + +test_expect_failure 'git -c - section' ' + test_completion "git -c br" <<-\EOF + branch.Z + browser.Z + EOF +' + +test_expect_failure 'git -c - variable name' ' + test_completion "git -c log.d" <<-\EOF + log.date=Z + log.decorate=Z + log.diffMerges=Z + EOF +' + +test_expect_failure 'git -c - value' ' + test_completion "git -c color.pager=" <<-\EOF + false Z + true Z + EOF +' + +test_expect_success 'git clone --config= - section' ' + test_completion "git clone --config=br" <<-\EOF + branch.Z + browser.Z + EOF +' + +test_expect_failure 'git clone --config= - variable name' ' + test_completion "git clone --config=log.d" <<-\EOF + log.date=Z + log.decorate=Z + log.diffMerges=Z + EOF +' + +test_expect_success 'git clone --config= - value' ' + test_completion "git clone --config=color.pager=" <<-\EOF + false Z + true Z + EOF +' + +test_expect_failure 'options with value' ' + test_completion "git merge -X diff-algorithm=" <<-\EOF + + EOF +' + +test_done diff --git a/t/t9904/.gitignore b/t/t9904/.gitignore new file mode 100644 index 0000000000..f9917e1bf9 --- /dev/null +++ b/t/t9904/.gitignore @@ -0,0 +1 @@ +/.zcompdump diff --git a/t/t9904/.zshrc b/t/t9904/.zshrc new file mode 100644 index 0000000000..1da11a5445 --- /dev/null +++ b/t/t9904/.zshrc @@ -0,0 +1,50 @@ +setopt zle + +PS1="" +fpath=($ZDOTDIR $fpath) +LISTMAX=1000 + +autoload -U compinit && compinit -u + +zstyle ':completion:*:*:git:*' script "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" +zstyle ":completion:*:default" list-colors "no=" "fi=" "di=" "sp=" "lc=" "rc=" "ec=\n" +zstyle ':completion:*' verbose no + +zle_complete () { + zle list-choices + zle kill-whole-line + print "" +} +zle -N zle_complete +bindkey "^I" zle_complete + +functions[_default]=: + +compadd () { + local pfx sfx + local -a args + + if (( ${@[(I)-a|-d]} )); then + builtin compadd -V unsorted "$@" + else + while (($#)); do + case "$1" in + -p) pfx="$2" ; shift 2 ;; + -S) sfx="$2" ; shift 2 ;; + --) args+=($1) ; shift ; break ;; + *) args+=("$1") ; shift ;; + esac + done + + while (($#)); do + args+=(${pfx}$1${sfx}) + shift + done + + builtin compadd -V unsorted -S '' "${args[@]}" + fi +} + +_git_func () { + eval ${words[2,-2]} +} diff --git a/t/t9904/_git b/t/t9904/_git new file mode 120000 index 0000000000..92d0240ac4 --- /dev/null +++ b/t/t9904/_git @@ -0,0 +1 @@ +../../contrib/completion/git-completion.zsh \ No newline at end of file diff --git a/t/t9904/completion b/t/t9904/completion new file mode 100755 index 0000000000..2927b81f6a --- /dev/null +++ b/t/t9904/completion @@ -0,0 +1,11 @@ +#!/bin/zsh + +zmodload zsh/zpty + +zpty zsh "ZDOTDIR=$(dirname $0) zsh -o NO_GLOBAL_RCS" +zpty -n -w zsh "$1"$'\t' +zpty -r zsh log '*' + +for x in ${(M)${(f)log}:#*''*}; do + print -- "${${x%''*}#*''}" +done From patchwork Tue Aug 30 09:30:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958960 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A0CEECAAA1 for ; Tue, 30 Aug 2022 09:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231382AbiH3Jby (ORCPT ); Tue, 30 Aug 2022 05:31:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231319AbiH3Jbr (ORCPT ); Tue, 30 Aug 2022 05:31:47 -0400 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563269D8E2 for ; Tue, 30 Aug 2022 02:31:46 -0700 (PDT) Received: by mail-oo1-xc35.google.com with SMTP id u3-20020a4ab5c3000000b0044b125e5d9eso1871620ooo.12 for ; Tue, 30 Aug 2022 02:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=6/cizRKdLoQzx+cPHSd+Ub9D1a/k7U0p+UD2tp3Hs+4=; b=c7SrbYGw/Gf9fSIFaa2w7E7Klee35IAgGD3bbfnatgqvphYyisQ6kRPbaIBaYGogTq 3iXMrL4fE8R51DtvgvNf2JlZTigf7Pn16ghgim0AtU/T1pcWhpM0NiEZtVZim0ocRk7G 0MyqzD0eDuBuF1OhWCz8fn4GfMooVti01gXba2zHjiqdZUeolEpu+nszCecsxPa/UKF1 sboO38OkDg0cn3bhOTmQPWGqpC2PE+huiqXJjWcDd+C8btZTPCQKOtDaqyv2UdhNxEoj 9V9hHBDt0jdsCr0vYs5JoHkmrOJXsotN9QARZyAW6XkuIdFHA/5s9rzZ8xCp4iejmwXF EBCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=6/cizRKdLoQzx+cPHSd+Ub9D1a/k7U0p+UD2tp3Hs+4=; b=mM5wiKLH64hSadSq6XDO5zTlqZuOR0e3umjXXWXa3gu3p80A2ovj4JiPUJ+f2cwP6q 3SgiG9IfJq6ajBtzJBrHLZW0ktE1d25gtLwooPkqbqdEdTtoVwrFWZG8S4eT7+tPQyW1 1ikORwP46h3IN15fbjQlwXD6NjoJyItev8xp/UK8LDvYWlDqoT3fxq9VouKMJe2OBNyt qnuTKRyPTfafRFN4muMygDJUj42hj1dKhJh5KybyLLlWVuaJ0RKzBE6OTIaTpEyEDQqJ 4g2Ny6f83JB4jULAnxRB/v5L9Q1/GK+l6sFtlw0VEGfoUwWQWD3mg3VXgJksyQ86sbuk bBjA== X-Gm-Message-State: ACgBeo27fmFbzBcLYKey0ovUDLy984NBoiD/0I6VB4pBvZt8TZTPM6HJ IesJufxrlptWn3H0g4xDwuH4Ylx55y0= X-Google-Smtp-Source: AA6agR4Cx5zaT1P33r5SLkWW62Qx5NtAzlWbKdQmTvMfI25E4CypywOM001tQ5iCPD1RzOuRMkz0Xw== X-Received: by 2002:a4a:e0d8:0:b0:44a:e39b:26d4 with SMTP id e24-20020a4ae0d8000000b0044ae39b26d4mr6932822oot.2.1661851905451; Tue, 30 Aug 2022 02:31:45 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id s2-20020a4aeac2000000b0044884c40c8asm6385288ooh.30.2022.08.30.02.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:44 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras , Harrison McCullough Subject: [PATCH 03/51] completion: fix __git_cmd_idx regression for zsh Date: Tue, 30 Aug 2022 04:30:50 -0500 Message-Id: <20220830093138.1581538-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The commit 59d85a2a05 (git-completion.bash: use $__git_cmd_idx in more places, 2021-04-22) caused a regression when using __git_complete and a command relies on __git_cmd_idx. This was fixed in cea232194d (completion: bash: fix late declaration of __git_cmd_idx, 2021-06-18) but only for bash. We need the function wrapper (__git_func_wrap in bash and _git in zsh) to define __git_cmd_idx. Otherwise the equivalent of __git_complete in zsh fails: compdef _git ga=git_add ga ga __git_find_on_cmdline:[:14: unknown condition: -lt Reported-by: Harrison McCullough Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- t/t9904-zsh-completion.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index cac6f61881..a1f2d27817 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -271,7 +271,7 @@ __git_zsh_main () _git () { local _ret=1 - local cur cword prev + local cur cword prev __git_cmd_idx=0 cur=${words[CURRENT]} prev=${words[CURRENT-1]} diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index 5179b2dc76..656eaf77ab 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -1121,4 +1121,10 @@ test_expect_failure 'options with value' ' EOF ' +test_expect_success 'main sets correct __git_cmd_idx' ' + echo modified > file1 && + touch file3 && + test_completion "compdef _git ga=git_add${LF}ga --update f" "file1" +' + test_done From patchwork Tue Aug 30 09:30:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958962 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BC72ECAAD4 for ; Tue, 30 Aug 2022 09:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbiH3Jb7 (ORCPT ); Tue, 30 Aug 2022 05:31:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230000AbiH3Jbv (ORCPT ); Tue, 30 Aug 2022 05:31:51 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C439AA1A57 for ; Tue, 30 Aug 2022 02:31:48 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11eab59db71so11495346fac.11 for ; Tue, 30 Aug 2022 02:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Q1vuPeCXqBCRUSIrTfPdNtLcw7RAAJ2ArRVWRD/b/9g=; b=gJjj/5X19DkBkNnhsxxflKT8veFTMms4Qv+b5sIDxp0GnU7R+rHkTPvmrP22ML5iLm uYDA35cd1yeQzNF3q3EEP50K4oGeSrzH0+cMiFFuhUikxF1R+SH+ttR2iY7TRJ0h+fj9 NnnTRU6duo6JL9K93K0A+iquPYVT2uEhB6608CgNg7KFtkbFdzWhERjLpZjl0ezOeu7z oD+iGaKeVcNOHUXtqH4tGDigEVN592M2zSPLnZMB/+6NV7FZ/Nnsmzqrnc7Ewl6CgtUJ 9PvhvyxcQwXB9uuiYFNqg6BAdJxNKZmX45KJBbdxo/IZ7XV7Q8RUoiKb+Icipne/9Pui Vryg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Q1vuPeCXqBCRUSIrTfPdNtLcw7RAAJ2ArRVWRD/b/9g=; b=s9ihmssGP+uB7KNK7vRr0R/rEDPp95Qy38k8J6Sb8Z/wLxXiABMvEMeq+cThIYTFoJ NrMThQ8k+VCvf4siRzwDPmI4aMu6w5HOgzG88iX2rZvAa/MuF9ECUMuF09D+eAIg5Ivd OcuptVU4oPoj4tuDJPj59MsrA+ndlFwXyK+QW0ab1Ulcp1CVR/hX5tASy05ehnqfObEI KeDSKviAwbWKXhO+/Vsea1eWTZcgUeCXaiGxHhDj7tERT66UX9/pMDCmz4sjQ8YI2ww7 zcX0A9Nh38riI0REdxrNF1vJ0nKzniBN3iLQq8MUM7VXUIPRzcCKgXLVI/fA4Xw8BSFv YBvA== X-Gm-Message-State: ACgBeo2tM54gHtes1fs8Px/hPaxsS58YygglprOLpgQgpRqGJB0jTtlW IMnJKp+GJX4pP0a4gMObmiR50jmPJys= X-Google-Smtp-Source: AA6agR5lFQX/T3/mFuIdavVUeu0TCTj45FO3v+xWNPJi0IvgodZ9cadndhASrvydKkOzOsXWwiCbVg== X-Received: by 2002:a05:6870:e245:b0:11d:74a4:4fc6 with SMTP id d5-20020a056870e24500b0011d74a44fc6mr9779427oac.156.1661851907115; Tue, 30 Aug 2022 02:31:47 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id 2-20020aca2802000000b0034378294973sm5783745oix.30.2022.08.30.02.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 04/51] completion: bash: trivial cleanup Date: Tue, 30 Aug 2022 04:30:51 -0500 Message-Id: <20220830093138.1581538-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index ba5c395d2d..2df51ed946 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3545,8 +3545,7 @@ fi __git_func_wrap () { - local cur words cword prev - local __git_cmd_idx=0 + local cur words cword prev __git_cmd_idx=0 _get_comp_words_by_ref -n =: cur words cword prev $1 } From patchwork Tue Aug 30 09:30:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76F37ECAAD4 for ; Tue, 30 Aug 2022 09:32:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbiH3JcK (ORCPT ); Tue, 30 Aug 2022 05:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbiH3JcB (ORCPT ); Tue, 30 Aug 2022 05:32:01 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D144DA8CC7 for ; Tue, 30 Aug 2022 02:31:50 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11ba6e79dd1so15325746fac.12 for ; Tue, 30 Aug 2022 02:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=EheOYH28O9kKS+GU70JdwiWyRhwJ0YnbKCuQsA0xq34=; b=RVt+n/JXxgh5c3u1M2DUkICl4Y3TlOaNWrSgAmR7V0mDmkrq1L7VEY9ghcw+YlqvGk LCx4bTbFYGgFA/opUbWwXhS89kJn+jEshUYoP2edcMaK6bve9eCxG4Fu4Gsq2kjfQtwR WtXPdbbBpxwSY2i7BeAn16qAUopvDRgVWEONzlpK5bgRkitgayNjYmi3gtxIsxKqGy+c Ju77XiA2L+E2QQAYw5t3GT3iBNta9+1gkW+Cjm3sxxpcdS5mWAwqD1edKEqXWtFxRaD7 4DLR+87i2qyzBUBdpzADlYIXu4/nyV7LRpOH1cPCYRrUGUBuum8AoCEzsknBtfBWPDbo kX+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=EheOYH28O9kKS+GU70JdwiWyRhwJ0YnbKCuQsA0xq34=; b=5EUFkXAhC8nhXSwDJQxn8B2jN4m19hYyP77kxeLWcNRPF79KDVArpWjLVaZd2tUPhX eZVcmKzLtvw+xPqfHigXmgJ7g5GEyaYD2s+nQ1rGmz7KTCxzIerHhw8RPS+oXOOhZxLl jFirjDYmhnnox5FILNM52jf5GJH1q1R2KDZEDXZl9TjANXvlKalqk+WhL2DmwWm08WW2 GDF/bPsyww585oL+WOQomhUZqaYUQz5wb+lZnUgVWXJFOp2pnvRf45bhO6DzgQwuh7Tj utd9zZhdBgY1UAsewvLUMlFdTDT2xVvhQ5DRheRf1cEUfgou9OkKZ2e4QgkXMiVyFiYH 7qfw== X-Gm-Message-State: ACgBeo0ZVh1iKzN7Q3Z88UCelLadFwhWoyAI5VTSbReC0O4vok3fWMQa jUEMhh6BA5/9Yz0xVVLzDbMD9Oexhns= X-Google-Smtp-Source: AA6agR6FIEETOSlbTn5DI4EkLkVsfCXZquUuWaY0YI64+oqIquoj0Ab4oKWIWYMKaFkMl26C3x3Liw== X-Received: by 2002:a05:6870:b405:b0:10d:7e26:8e8c with SMTP id x5-20020a056870b40500b0010d7e268e8cmr9540752oap.78.1661851909075; Tue, 30 Aug 2022 02:31:49 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id f11-20020a9d6c0b000000b0061c9ccb051bsm7048408otq.37.2022.08.30.02.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:48 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 05/51] completion: zsh: add higher-priority location Date: Tue, 30 Aug 2022 04:30:52 -0500 Message-Id: <20220830093138.1581538-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org bash-completion looks in /usr/local/share first, we should too. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index a1f2d27817..535cf03176 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -35,6 +35,7 @@ if [ -z "$script" ]; then locations=( "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash "$HOME/.local/share/bash-completion/completions/git" + '/usr/local/share/bash-completion/completions/git' "$bash_completion/git" '/etc/bash_completion.d/git' # old debian ) From patchwork Tue Aug 30 09:30:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE2AFECAAA1 for ; Tue, 30 Aug 2022 09:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbiH3JcT (ORCPT ); Tue, 30 Aug 2022 05:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231742AbiH3JcK (ORCPT ); Tue, 30 Aug 2022 05:32:10 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FBEDD99C0 for ; Tue, 30 Aug 2022 02:31:51 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-11dca1c9c01so15397556fac.2 for ; Tue, 30 Aug 2022 02:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=cN/9QVEPFa0gEMZ6LgcZQAx36uetIV8xXC6pStWfzik=; b=oG0ikbVuU0BiN8LTVVP06WsDXehlFJgJiz9tLPg81t68hIte7L/8BmSyuzDLW4V6he Zt/frlvfxaPZS5VxXwO41l6lKhCcTHNhPjb+JDn/ks88tIxuZBgCT3l3yrOqvjQZrPis DkuTjyCpzrxrBku77tfgIaQQca8MtfEfTmajrFdYkTtc/8R87CGYX96ps7ZT1HCCS2bF zuv6mSxL5DQrrSdwNyOUuF7q8Ajw3GqCrDW2BhzwJsvS74r3BAg5I1HcoiFMgkO/PFlr SpKQz64Q5gJHkv9D/pjfbjxr5ot+ccRuC/rom2vixhbqULafsxHowiS/EljYUyl1YM7F 6Keg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=cN/9QVEPFa0gEMZ6LgcZQAx36uetIV8xXC6pStWfzik=; b=6h0ysrRjS7cKAWxr+4zKnpH8XFhKZGiLsznZ6Th1F6GU+/JSPcty38Bjl1eWaP5Coq xTV/NUOd1raWn2xM0dtpwX8kwZfnHrPZsIg+KTXsPS+EuThZvRHfkRDwoyMoDWpYOY1c NDpppb1+BNIBc9dE5MTMvX9LeUIjY/WTDWmlREwuVdbf6de1KKYuqyPI/3Wgv3USLPsx A/5+q/1BVLjrZSjnzlwajbEJKQy6GZapnu6pEfqLN3MX6UToUj/CUZXDUeGoc+BeFQZB 4DqiqJCpdNh+0/MTExk2ES9YoKh571WqqDgUvIBjoIwRnT1RyWK5DnBTMSlJ8h1bwg0n P8Ew== X-Gm-Message-State: ACgBeo2glDe25PG9V6Q3gON89KiG7HQh8Wsp8x256mlCThovc3IEg6/C eEKG/hNsGEDQWsb9JeCmpuhJfP/+fYA= X-Google-Smtp-Source: AA6agR7HdzyJD3S43FiNORuWqYWAkT2O21g3NwpGJGnCMEBsPFrLDjYVNCuq/+K3wziqGwCklLH3OQ== X-Received: by 2002:a05:6870:b61e:b0:11c:d598:e612 with SMTP id cm30-20020a056870b61e00b0011cd598e612mr10089362oab.261.1661851910875; Tue, 30 Aug 2022 02:31:50 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id r130-20020aca4488000000b0032f0fd7e1f8sm5842509oia.39.2022.08.30.02.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:50 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Michael Bianco , Felipe Contreras Subject: [PATCH 06/51] zsh: resolve symlink of script Date: Tue, 30 Aug 2022 04:30:53 -0500 Message-Id: <20220830093138.1581538-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Michael Bianco When using zinit the completions are symlinked to ~/.zinit/completions, this causes the zsh script to not be able to find the bash script. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 535cf03176..1a405ba0a2 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -33,7 +33,7 @@ if [ -z "$script" ]; then bash_completion='/usr/share/bash-completion/completions/' locations=( - "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash + "$(dirname $(realpath ${funcsourcetrace[1]%:*}))"/git-completion.bash "$HOME/.local/share/bash-completion/completions/git" '/usr/local/share/bash-completion/completions/git' "$bash_completion/git" From patchwork Tue Aug 30 09:30:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A0A1ECAAD4 for ; Tue, 30 Aug 2022 09:32:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231404AbiH3JcM (ORCPT ); Tue, 30 Aug 2022 05:32:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231668AbiH3JcJ (ORCPT ); Tue, 30 Aug 2022 05:32:09 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18F5B274A for ; Tue, 30 Aug 2022 02:31:53 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11eb44f520dso11112597fac.10 for ; Tue, 30 Aug 2022 02:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=2xjN05x539BvqXC8gi6MLSSXHmj/V1TNE8iLh/qHNMA=; b=IuEVZ4rZowjL5+9cAbHrku3ct8xDKXh6tjDx/rvz2gdRuP+kzxWXjk14rusIe9WASe 6lazECdPcXLJBPYAhvsS5lK+ZqSJomE7x63MebM7mrXQOlIRKN7ISlEtnXMT/yy9Fq6+ qvFD5xLcXclpvPAFvcZ/bLM4HrCfq8weBGEGXYFBfy1Kp+SeUz4EJSbbEVVahiothFda W8cMkgezABOXZmEFeO8R3oljwTSDO04dDoIy0dlH3z70WSPeKH3IS8VeS0PXG4RCypY3 tZ0/fsQO+hRNK/pLSImCr8DgZY0MHlQylfzYieGmZYqFJWWRmqxsYXjQcxMh7bt8qaE4 XxRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=2xjN05x539BvqXC8gi6MLSSXHmj/V1TNE8iLh/qHNMA=; b=2ARV75aamW2xuB0//jDZWK+QHgM49FpT+E7oMJwlKyV++EUML712piR1uVNgMkjc/2 sdcYsRl9U8cYoyeNa9ZMLcgIHwdNSPmXm8LQ+faIfXb2NR4thXLbbQZ7cJc7s3DwlH3b slp2ocHnTKHfkIlmcmsrar0O8zvMD7fvYSwg/pYnPO93Dw9K5G2pY5HUHEkZOUjLRf2z NyuMtkE7I10porXnD+Z5tanCZnuVCTdkshifymcZ2u6OaqQ8SFrzIVr0ygf+EaaYfDCd 2I6v6fzeBxhQ1/ixyx3iMyPJFBaiAR1dka8J9lfHkNY01O19S9Xf9punyRoaVXpL/MQv utQw== X-Gm-Message-State: ACgBeo0dvAZ3ek3HsjoJ+u1ZU8GMndxQ2ptBJo0kPAvuhPAZoScq/9uR mF+i1iWzi2nJicrE/Sc8ZMhOKdIz0Tc= X-Google-Smtp-Source: AA6agR4M/CKRrs0LchymSgBpp2GH4AgeFDSir+4EzqAbjc0eGjiUPw/wiwMtLNOU2b2MjfJ+0csDuw== X-Received: by 2002:a05:6870:4256:b0:11f:2202:b292 with SMTP id v22-20020a056870425600b0011f2202b292mr2503215oac.145.1661851912392; Tue, 30 Aug 2022 02:31:52 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id h6-20020a4aa746000000b00425806a20f5sm6417563oom.3.2022.08.30.02.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:51 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 07/51] zsh: simplify realpath dirname idiom Date: Tue, 30 Aug 2022 04:30:54 -0500 Message-Id: <20220830093138.1581538-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's a much simpler way in zsh. It's a shame that ${0:A:h} doesn't work probably due to a bug in zsh. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 1a405ba0a2..18ad897568 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -33,7 +33,7 @@ if [ -z "$script" ]; then bash_completion='/usr/share/bash-completion/completions/' locations=( - "$(dirname $(realpath ${funcsourcetrace[1]%:*}))"/git-completion.bash + "${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash "$HOME/.local/share/bash-completion/completions/git" '/usr/local/share/bash-completion/completions/git' "$bash_completion/git" From patchwork Tue Aug 30 09:30:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85CCFECAAD4 for ; Tue, 30 Aug 2022 09:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231889AbiH3Jc2 (ORCPT ); Tue, 30 Aug 2022 05:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbiH3JcK (ORCPT ); Tue, 30 Aug 2022 05:32:10 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF26A2AA1 for ; Tue, 30 Aug 2022 02:31:54 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11edd61a9edso9320356fac.5 for ; Tue, 30 Aug 2022 02:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=qtmTPmGqyXKWpAUmv4NjuF3YtIG+Z0tJK74Y+XaK6Hw=; b=GlakI9oK92jW3NT+zMQTBEq7UcpAtpSMfRcPQAw/Dm9lKFNHGpsgguJkKQViuoqknt 6KGmmPn6YMyOfq4Wi8rlLHgJD66Bz38JlE5+oeEtmIMZ9jcvrEf85bIk/B8zjoVNEJnF TLyQRnFR9qWj0TUYfYQyUBYkmNXqV/Z+j4MbpogTKwTvARnLnsihSY+8KyFwpqigfl/D QW3RRNRP+52Lu7oAECd/s0Y6bzLTVvQ6CIeksy5p2Z3Oc3hxyE791BSpDRbOimgQEyZE Cxeuj10ufZru7PZqrPA5BNKWoK5y5olbkeOkzbf+aTLqNjgwUiHH3WBjtdpNsLr2Ge8M 7sCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=qtmTPmGqyXKWpAUmv4NjuF3YtIG+Z0tJK74Y+XaK6Hw=; b=PKzzcdrb/1nnn7AUPaHPCaN8EW/bmoLnWwJOwNPNoEVFJrsQFMAAlyT2he8jJRPUIW +qkQjAieHArLcH7M2xPbobz5xBRyS/bbvW3b52LbmxqpeQOlhMaGiBme9xtYymeWYGuf 0VKyK1tbwGxmKbUlX9sZq0c30k0SKwFKJ5MVB47fcY+yWFl5uc/QcZHY86Whr9/qnoXm Pg/NMc1R1y4thyQO3fGfDY8G3OaeSUJ6rwK7E5L46mza0Epm1ccbXO7brPG2aZlg5SzS lZdcTR38OsC3Fif/CHVBIY38RlSUxcDh+XHwmELaPAY7rw6vE58eUEKD83f9b1YeBuAi N4/Q== X-Gm-Message-State: ACgBeo1VowKnY21ZdzHVqYYpvndnhuoLwj0UkD3OaZvcgxIYaOkd9Dc5 Azay0yfeuBwHIcZ1FxbmHYieuZDAcWA= X-Google-Smtp-Source: AA6agR7TGKiOFjTWMVK+1eXVU/eEIJGZ9mvxzOTcr7t1pXykiIF4yPyVecAIPSq4OwCQkZszYqFtdw== X-Received: by 2002:a05:6808:16a1:b0:345:ca3c:318e with SMTP id bb33-20020a05680816a100b00345ca3c318emr7153406oib.2.1661851913867; Tue, 30 Aug 2022 02:31:53 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id k4-20020a056870958400b000fb2aa6eef2sm7485611oao.32.2022.08.30.02.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:53 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 08/51] test: reset environment variables Date: Tue, 30 Aug 2022 04:30:55 -0500 Message-Id: <20220830093138.1581538-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org These should not affect the tests. Signed-off-by: Felipe Contreras --- t/t9903-bash-prompt.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 6a30f5719c..c94c351e23 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -18,6 +18,14 @@ c_green='\\[\\e[32m\\]' c_lblue='\\[\\e[1;34m\\]' c_clear='\\[\\e[0m\\]' +unset GIT_PS1_SHOWDIRTYSTATE +unset GIT_PS1_SHOWSTASHSTATE +unset GIT_PS1_SHOWUNTRACKEDFILES +unset GIT_PS1_COMPRESSSPARSESTATE +unset GIT_PS1_SHOWUPSTREAM +unset GIT_PS1_STATESEPARATOR +unset GIT_PS1_SHOWCOLORHINTS + test_expect_success 'setup for prompt tests' ' git init otherrepo && echo 1 >file && From patchwork Tue Aug 30 09:30:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958964 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E71DECAAA1 for ; Tue, 30 Aug 2022 09:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231331AbiH3JcL (ORCPT ); Tue, 30 Aug 2022 05:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231548AbiH3JcB (ORCPT ); Tue, 30 Aug 2022 05:32:01 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFBC3A2A8A for ; Tue, 30 Aug 2022 02:31:56 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11eb8b133fbso10952411fac.0 for ; Tue, 30 Aug 2022 02:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=M+Pt1uQuHUMFRJBB0vBLFZiCog1k6TOqVBpaZWmgXAI=; b=RJg8fHLnj3Uazecrj+iGoD++RlVy+oEetzbKbAeL9NvMi7gCfLpBNZ1uNwrtMO0GgC wj+bnRaAlA6/80YFlMRhk5TaNIN4dfFUZcgH2Pm7dlU76u6c+GAOOZDhz0UQ71FtaNQ3 X8HPH7PVeqiCf1/qSQTWslsfwrfTZJfGYSVaLEOfg4lwPXlpk/ZQyrq+67rNvHZXGmJE sW2WQhchZGLORVpqG5vw6tU0vHmA82b5cOudDi3cv445GAAg5adbq7QkSCb2CSI80LE9 yT5w/AflWb/ZfWPtYpw6TjpsLY8tsbAwBBPnNwA5bEgt1/txj3UbdLOLqpHGuFcQ2LtQ jNWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=M+Pt1uQuHUMFRJBB0vBLFZiCog1k6TOqVBpaZWmgXAI=; b=U/K8xik7oEaNtMHyWkMLz3SfGl8aNtyG8A4v+JmC+AfsiQ2hFcql5ZAj0PJURn6VSU cOnR8GXLi5laAY4/CBvJ3h5XEbxlXsufAoeuIyXTsTtqR8rfhKX0h51hqQ8QeTuD/M0X LwXMcQmhHH71xGniHnfP7a9NaqGxslyeueHz9NHpTY1nELMu2fht79WryvzcmA3VLi82 ueeMpP9uh2mCOQKpQX5aIvngyw5K3TuASYPOP5t2O3ezsnrfYOyDg7p/ewFBmGNgiDpx AjIHeEiZo90S6CbvpLhu9i525oIOBky5d8jiY7SU91e7K8X2jGzYP7gKNk0gvFMqegRi PxxA== X-Gm-Message-State: ACgBeo22woTmoxjypDTf4HPxeu3KibTbu2F5l49vZAHeSL5ebNY67KWg WiYMl3Uv9jqOd66dAtnauAmXowrWEUM= X-Google-Smtp-Source: AA6agR6iFSgWUqioJM3cCos8yQL3kd9xwZSOi2NKdWec8Az6ONoK4Y4AHdbs6JCUmaa73eshO8JC2Q== X-Received: by 2002:a05:6870:2041:b0:10d:c70:42c4 with SMTP id l1-20020a056870204100b0010d0c7042c4mr9488473oad.150.1661851915362; Tue, 30 Aug 2022 02:31:55 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id m4-20020a4ad504000000b00425678b9c4bsm6474114oos.0.2022.08.30.02.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:54 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 09/51] completion: prompt: use generic colors Date: Tue, 30 Aug 2022 04:30:56 -0500 Message-Id: <20220830093138.1581538-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the prompt command mode was introduced in 1bfc51ac81 (Allow __git_ps1 to be used in PROMPT_COMMAND, 2012-10-10) the assumption was that it was necessary in order to properly add colors to PS1 in bash, but this wasn't true. It's true that the \[ \] markers add the information needed to properly calculate the width of the prompt, and they have to be added directly to PS1, a function returning them doesn't work. But that is because bash coverts the \[ \] markers in PS1 to \001 \002, which is what readline ultimately needs in order to calculate the width. We don't need bash to do this conversion, we can use \001 \002 ourselves, and then the prompt command mode is not necessary to display colors. This is what functions returning colors are supposed to do [1]. [1] http://mywiki.wooledge.org/BashFAQ/053 Signed-off-by: Felipe Contreras --- contrib/completion/git-prompt.sh | 19 +++++++------------ t/t9903-bash-prompt.sh | 8 ++++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 1435548e00..01bd807657 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -96,9 +96,7 @@ # # If you would like a colored hint about the current dirty state, set # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on -# the colored output of "git status -sb" and are available only when -# using __git_ps1 for PROMPT_COMMAND or precmd in Bash, -# but always available in Zsh. +# the colored output of "git status -sb". # # If you would like __git_ps1 to do nothing in the case when the current # directory is set up to be ignored by git, then set @@ -255,12 +253,12 @@ __git_ps1_colorize_gitstring () local c_lblue='%F{blue}' local c_clear='%f' else - # Using \[ and \] around colors is necessary to prevent + # Using \001 and \002 around colors is necessary to prevent # issues with command line editing/browsing/completion! - local c_red='\[\e[31m\]' - local c_green='\[\e[32m\]' - local c_lblue='\[\e[1;34m\]' - local c_clear='\[\e[0m\]' + local c_red=$'\001\e[31m\002' + local c_green=$'\001\e[32m\002' + local c_lblue=$'\001\e[1;34m\002' + local c_clear=$'\001\e[0m\002' fi local bad_color=$c_red local ok_color=$c_green @@ -564,11 +562,8 @@ __git_ps1 () b="\${__git_ps1_branch_name}" fi - # NO color option unless in PROMPT_COMMAND mode or it's Zsh if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then - if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then - __git_ps1_colorize_gitstring - fi + __git_ps1_colorize_gitstring fi local f="$h$w$i$s$u$p" diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index c94c351e23..fb396ff3a7 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -13,10 +13,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh" actual="$TRASH_DIRECTORY/actual" -c_red='\\[\\e[31m\\]' -c_green='\\[\\e[32m\\]' -c_lblue='\\[\\e[1;34m\\]' -c_clear='\\[\\e[0m\\]' +c_red='\001\e[31m\002' +c_green='\001\e[32m\002' +c_lblue='\001\e[1;34m\002' +c_clear='\001\e[0m\002' unset GIT_PS1_SHOWDIRTYSTATE unset GIT_PS1_SHOWSTASHSTATE From patchwork Tue Aug 30 09:30:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55984ECAAA1 for ; Tue, 30 Aug 2022 09:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230207AbiH3JcP (ORCPT ); Tue, 30 Aug 2022 05:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbiH3JcJ (ORCPT ); Tue, 30 Aug 2022 05:32:09 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1E2A063C for ; Tue, 30 Aug 2022 02:31:57 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11eab59db71so11496089fac.11 for ; Tue, 30 Aug 2022 02:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=r3olx8FBJ3YfPirvaIW7ssFqvxySlbdnXxpNKjeEsKE=; b=k6XPWaOSnMeLdOZGnIjTsalsyB3W+A3cb4KKt4uSpWxjiOZMoxWB7ymE3AeTRTwMlK ue8svIBOf7uH2RksLO88RC9xI5DOc/Y4NmdEiyn8wD4F/4bl+WGJsN9TJuqGqAemvme7 VPhIwnAtg8usDTzGMaerJXY7xQCyBUu6LBoLfpAwcLaYIkZfWmKkOFAYbuuKMutWbzUx 83klwh+evHLhJdw4Q/5EJIQ+uqA4ntdx5gOEl8VZEaBTW9jh/XoMeBMnKRt863T77Aaw fzJXFutngfExliDmyd8UGPm+Qp+frX+Pvh5v9OEYkSiVa17XAmfzeKNg5zgSfjWnBZ5x aYVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=r3olx8FBJ3YfPirvaIW7ssFqvxySlbdnXxpNKjeEsKE=; b=2NKOBH9HOEtMu5JH8q1f6BNBcpwgUvuTqKLVFYqKeF7o4BesGOyF3DhcezxMJDv3cC CEfmYa4lxBG4440cTAAgCVhBmQlAUSLIAqrt0yTmkdNhwyE8O6qkPq1S6SQdeiEuEJ1P CbupQTKTtFomn5KPVpCW8ChtYRYzSVJWXnJHm3oPujccJRa/DxhkNZRXnkhwPRf1LsIm T4OwiWybxS010do4B4e0W4PJAYxBmBvEQkjLfb4nsfp86dLzarDtu7AOIL5z8S0npmvQ 5Gtx5y3oxgRk8+z5F0Wr8lsruamq+33WtTnQQWij69UITlg1Yp7OemvbS+TvQW9asPRq +iCA== X-Gm-Message-State: ACgBeo3bxaeMe1sx8gGEvIAbXKfycYPwWTSX+yoUNsVJUDoXGPk1pnmh sdXaGGaMNpqGhG/bc8TKByG7BxVGc4I= X-Google-Smtp-Source: AA6agR5Ek6qWetd/t9JW5RuhQqKeZ0fY10vs5jOYStMClj2CaUXfGupPsy9jQBRe0azRky8lZSCoDg== X-Received: by 2002:a05:6870:a78d:b0:11c:437b:ec70 with SMTP id x13-20020a056870a78d00b0011c437bec70mr10029487oao.136.1661851916996; Tue, 30 Aug 2022 02:31:56 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id v30-20020a056830091e00b006371af665c5sm7122486ott.56.2022.08.30.02.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:56 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 10/51] completion: fix for suboptions with value Date: Tue, 30 Aug 2022 04:30:57 -0500 Message-Id: <20220830093138.1581538-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We need to ignore options that don't start with -- as well. Depending on the value of COMP_WORDBREAKS, the last word could be duplicated otherwise. Can be tested with: git merge -X diff-algorithm= Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- t/t9904-zsh-completion.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 18ad897568..1905ff98b7 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -56,7 +56,7 @@ __gitcomp () local cur_="${3-$cur}" case "$cur_" in - --*=) + *=) ;; --no-*) local c IFS=$' \t\n' diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index 656eaf77ab..d3fe42a9b3 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -157,7 +157,7 @@ test_expect_success '__gitcomp - expand/narrow all negative options' ' EOF ' -test_expect_failure '__gitcomp - equal skip' ' +test_expect_success '__gitcomp - equal skip' ' test_gitcomp "--option=" "--option=" <<-\EOF && EOF @@ -1115,7 +1115,7 @@ test_expect_success 'git clone --config= - value' ' EOF ' -test_expect_failure 'options with value' ' +test_expect_success 'options with value' ' test_completion "git merge -X diff-algorithm=" <<-\EOF EOF From patchwork Tue Aug 30 09:30:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7957C0502A for ; Tue, 30 Aug 2022 09:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbiH3Jcb (ORCPT ); Tue, 30 Aug 2022 05:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbiH3JcL (ORCPT ); Tue, 30 Aug 2022 05:32:11 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF0FA262D for ; Tue, 30 Aug 2022 02:31:59 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id m21-20020a9d6ad5000000b00638df677850so7672885otq.5 for ; Tue, 30 Aug 2022 02:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=48c2N2EyXPtPruhNliOaiDF4uD1lfRJ+2RdzFVO51GA=; b=G60gQgd9RKfvo9jjs6Mz+2jxWlqHxLQzUPHPrciCG5HIhU7QugQdi4ZnshOXXb+SCs RGqbnpPvtsVtkCP36ta+iOkmIIfg1qLQUHK43s683qPvZT+3w2yxLzVcHzaj7Zq39NU9 ZkxnZ/zeGOxkoL2wvYVaYhovP9rsVSCWIeTb+D3SU4Ajry1oDT3qb+3QgwGznLlUBbcA fJvLYyv2KMAFOO9Hbb72rcN52wfg3jaejALtDVsUZDkRk8/1lJte+me8USFw5sdLmVh3 CGlmnYUGwVtZs7v8k3zTq/RxLXbcbQLL9tNIBiCA/I1JjnISF6FhAeI0ahM6Il0YbDoC u1RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=48c2N2EyXPtPruhNliOaiDF4uD1lfRJ+2RdzFVO51GA=; b=TyuGSNoXyF2xavm3Tmp3jA2gAKHZXlJsZBNsSQ1xbLRef5yxtG2OSKMAiX3N4OXV+l D2nAs5/uV7cFUsYugecYcIQDrmcJa6eWuwbCg5i4SAp08BNeqAbbuZsAELQW7uBcGkEy /I85N05ks8lSGR7CvkccC3igRw7Ojkkx3/Xp8YNs6Bk1BNngapvBpZptEmiYNKV/ynWj jQj8WDKTCYGSGr7rRA2NEj8+4ZmcMvqAN+5U3CnnuR3JvXtNxCP8lLGlm9kffkrwa9vC c5gzB3JJRFqsATkr5XgaV8SGadXfEICXAVZfD5vyGC0c/nWtk9r4S5zRnMlVvL4ruvXe 6XVA== X-Gm-Message-State: ACgBeo3O5UnYrgGEjbdxSjXNgAof8b/ubSxuLm0ZoGL7em2kqgbEX9tR CLnKS89V9QGzIk2l29iGWsSOSoym/lk= X-Google-Smtp-Source: AA6agR4EX5A06Fp/pYTZxocI33NzKYy1lMGshdSUkIRUCw5HKPB2Ag3k7S/lCIM2yNNPp7y5/F34RA== X-Received: by 2002:a9d:7495:0:b0:639:5528:9f1 with SMTP id t21-20020a9d7495000000b00639552809f1mr8237570otk.12.1661851918455; Tue, 30 Aug 2022 02:31:58 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id bl2-20020a056808308200b00334c2e81dfbsm6022761oib.0.2022.08.30.02.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:58 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 11/51] completion: zsh: trivial improvement Date: Tue, 30 Aug 2022 04:30:58 -0500 Message-Id: <20220830093138.1581538-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org $words has basically all the words we need, except the first one: git. Lets simply add that instead of passing the original, which contains options we don't want to pass downstream (like -c and -C). Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 1905ff98b7..4d81ca73b5 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -220,9 +220,6 @@ __git_zsh_main () { local curcontext="$curcontext" state state_descr line typeset -A opt_args - local -a orig_words - - orig_words=( ${words[@]} ) _arguments -C \ '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ @@ -262,7 +259,7 @@ __git_zsh_main () (( $+opt_args[--help] )) && command='help' - words=( ${orig_words[@]} ) + words=( git ${words[@]} ) __git_zsh_bash_func $command ;; From patchwork Tue Aug 30 09:30:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71A6AECAAA1 for ; Tue, 30 Aug 2022 09:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231876AbiH3Jcd (ORCPT ); Tue, 30 Aug 2022 05:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231865AbiH3JcL (ORCPT ); Tue, 30 Aug 2022 05:32:11 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8747BDCFF6 for ; Tue, 30 Aug 2022 02:32:00 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-11c4d7d4683so15349050fac.8 for ; Tue, 30 Aug 2022 02:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=4OxhtLA9xQDrAoCmNJUr+WszS//iCHJ0tAQIH3pEuR4=; b=KUApCs8eG1OBTsX0reL6uXgBQpW7Dnla4Iz8au8TUxho1dw1Fy7q6GTcX3uureuHh2 4mW74Uigw19UioHGHUhu6Ppej5PD2l+xMKJL5GqhX+IfOAdW5YNHhZxB1dNDJU+UGK+x EWcN8n1Cfd2bihwEfZsqSJuazwNf94kFNzALaprWnwdLiEagIIfsobJs6W04pRSWBPIo U6NYGDZwq931OBBhynon5Ng79teBrgaXD+t29kyrDC9QZb9e22dw6PVpi5KOQTz9L+++ Gx6roXtlsvb2VNvReJEVqUIC8vFYxebilYF8me7/Bd4j3CfRVamU1UXtCpvQ2R/9uTc1 QrAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=4OxhtLA9xQDrAoCmNJUr+WszS//iCHJ0tAQIH3pEuR4=; b=2SUYvqXpb7pC6OacTi5HGQWIBOdF08bLpXxN7b/232LzMKptOCXTrxADFyHWBEQxKr YG6CokqaCY+mbX5I3NAmuDsixXkTI0zAdNG1kWH6jMgzWmO2nZsnwg7YS3086TpNbhmx Rwq216Kkv8eYW4BcNC2S7KcJgwpHr6FJ6B11S7x69WEb5QbADxmpkFUstCIKru0d6Zsb gH5umN+Fq7BwIGm7XDV6MTHQK32eEtRtAz6awv1LMpm3Ess42KoUI6thMCytf07f7ezg iOKAoOjcE/wCj3w7vJoM2Ynvj/j3yB0KzdLdBgi6bOw+eGzCNWNOLtc0A9gbEZy2oJg5 QeHw== X-Gm-Message-State: ACgBeo0+FjkV+pFNcbNxl3D8OpU3tKMMsQKNkLQ35i2zYx0WA0jzzugy EZzpqOJiO3rn4FeMKd2jWjLGSvaCaFg= X-Google-Smtp-Source: AA6agR6R4lVvD+VWQFlP3C+dmAvUiwOrGd52n/NJMsAD2C5ydsEYP6HKMVVCERTC9Mp+0xuhf2GPkw== X-Received: by 2002:a05:6870:b61e:b0:11c:d598:e612 with SMTP id cm30-20020a056870b61e00b0011cd598e612mr10089589oab.261.1661851919928; Tue, 30 Aug 2022 02:31:59 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id f23-20020a4ad817000000b004359da266b4sm6412748oov.14.2022.08.30.02.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:31:59 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 12/51] completion: bash: do not modify COMP_WORDBREAKS Date: Tue, 30 Aug 2022 04:30:59 -0500 Message-Id: <20220830093138.1581538-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There was no need for this once __git_reassemble_comp_words_by_ref() was introduced. Now irrespective of the value of COMP_WORDBREAKS, words are always joined together. By default COMP_WORDBREAKS does contain a colon, and if it doesn't somebody probably has a reason for it. Completions are not supposed to modify COMP_WORDBREAKS and none of the completions in the bash-completion project do. We manually set it in Zsh so the Bash script is not confused. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 5 ----- contrib/completion/git-completion.zsh | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 2df51ed946..ef0b7aa192 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -59,11 +59,6 @@ # When set to "1" suggest all options, including options which are # typically hidden (e.g. '--allow-empty' for 'git commit'). -case "$COMP_WORDBREAKS" in -*:*) : great ;; -*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" -esac - # Discovers the path to the git repository taking any '--git-dir=' and # '-C ' options into account and stores it in the $__git_repo_path # variable. diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 4d81ca73b5..2de1a72c09 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -46,6 +46,7 @@ fi local old_complete="$functions[complete]" functions[complete]=: +COMP_WORDBREAKS=':' GIT_SOURCING_ZSH_COMPLETION=y . "$script" functions[complete]="$old_complete" From patchwork Tue Aug 30 09:31:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AB0EECAAD4 for ; Tue, 30 Aug 2022 09:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbiH3Jce (ORCPT ); Tue, 30 Aug 2022 05:32:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbiH3Jc0 (ORCPT ); Tue, 30 Aug 2022 05:32:26 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC19DDAB6 for ; Tue, 30 Aug 2022 02:32:03 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11dca1c9c01so15398376fac.2 for ; Tue, 30 Aug 2022 02:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=AjkVUDWYaNWykE6lLpNh9SjNW7ND0zhhQV3lOJ4CUEc=; b=VgCtHz5tmzMI5WHOJBSBfD6Tj694icuzLmmDjYyxktPBtD+5X5VRyoH7NklBYmcff2 pYfIWix6D77/ybx1c0eSptmHFdXxSexGYBP3W5EmZ9AMUnpcc546m9RILY3CZ7b/CVuR 4QzsMg4q6578GJa1Vp/kszCXvfYdROPNIJi2UhMVXC4D8/Jq1DUG9Z1nFoL6IWBlbvGV iMY1OLrn5K3rnecG3zZWy5z0Gohw61yy9xaaZHhi/lTXSr6q0LxYCI9WBs2BpRNYuLda +6frcgv115q8e2PWDckoewijYVJPAx2QUrSxoFaBvoxo/iFes4+OLkjwy3mtWnuyPjXV EJTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=AjkVUDWYaNWykE6lLpNh9SjNW7ND0zhhQV3lOJ4CUEc=; b=xlZB326fhLNzwleqolO9iDy4Na+G2/U2ldq2vQWGhZ/aeP/hfoHAjS8NQeFYxFgUoC mdgTx7rcREu1lcppWDFixPrPtGopdwHYODosFiUDr0tAwq31MePySdBY9Z8Yr2Jhsfx3 y+T/TFAWjSuDzldjlJzSivIexnUysG5sPuuOfx2D2dzSlGA/Vc8V4hysCMO2DGuvApyw +T14p6g+2vlS8ZZ29SebyMnTUAKdN5aSQFjV8ebfisezjb8DvjM/iqJwR7SruHXGS4tJ keXQgjZeG5LQNUuDYFcSkvlMQrAL7D0CQybWP7NoZ3Iu2zUQjXV8D3EGPF5bB/lYuFwd zfEg== X-Gm-Message-State: ACgBeo1epCvoHEmSb9kkJUv2x0HY8zhfRN2peu0zhFladVONlg9DRMJS KZjIdpjY4SA8SH7qm1+jzHdvNwhD7Dw= X-Google-Smtp-Source: AA6agR4ThMyUfzL5tYsw0vci/eY/Q8NwLcJWdy1YGiEDE/o23jFEg5MYMzF9LXRAYikwnCBRhoyVLw== X-Received: by 2002:a05:6808:1488:b0:344:dc19:d7d9 with SMTP id e8-20020a056808148800b00344dc19d7d9mr8902609oiw.196.1661851921814; Tue, 30 Aug 2022 02:32:01 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id y64-20020a9d22c6000000b006369d5d6372sm5986095ota.50.2022.08.30.02.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:01 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 13/51] test: completion: fix currently typed words Date: Tue, 30 Aug 2022 04:31:00 -0500 Message-Id: <20220830093138.1581538-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org They don't match what we are supposed to be completing. No functional changes. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 4 ++-- t/t9904-zsh-completion.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 8cc30448c7..031f05cf47 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -486,7 +486,7 @@ test_expect_success '__gitcomp - option parameter' ' ' test_expect_success '__gitcomp - prefix' ' - test_gitcomp "branch.me" "remote merge mergeoptions rebase" \ + test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z @@ -494,7 +494,7 @@ test_expect_success '__gitcomp - prefix' ' ' test_expect_success '__gitcomp - suffix' ' - test_gitcomp "branch.me" "master maint next seen" "branch." \ + test_gitcomp "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index d3fe42a9b3..e9df29c135 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -106,7 +106,7 @@ test_expect_success '__gitcomp - option parameter' ' ' test_expect_failure '__gitcomp - prefix' ' - test_gitcomp "branch.me" "remote merge mergeoptions rebase" \ + test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z @@ -114,7 +114,7 @@ test_expect_failure '__gitcomp - prefix' ' ' test_expect_failure '__gitcomp - suffix' ' - test_gitcomp "branch.me" "master maint next seen" "branch." \ + test_gitcomp "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z From patchwork Tue Aug 30 09:31:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91A3BECAAA1 for ; Tue, 30 Aug 2022 09:32:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbiH3Jch (ORCPT ); Tue, 30 Aug 2022 05:32:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231807AbiH3Jc0 (ORCPT ); Tue, 30 Aug 2022 05:32:26 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26B47A925E for ; Tue, 30 Aug 2022 02:32:05 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11f11d932a8so6967008fac.3 for ; Tue, 30 Aug 2022 02:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=QPRSVzXcyD14zgWjFMeYAQTcyvIGsx3ocDkIgXd3Fcc=; b=WT/8+zXtOrANIWGS9FQW/MUKDdptcyIBFjb+GILDb62b4AUN8FgATNBidRhde6tpzR Gof2ILa+9oibnLpGLvuPeau4AUEvD52AmW6mIHbq92D6ZNRQL5t095Md/tf1UKu3gWO1 wHMDrAF5cunJWie4Y3DUeuoLX/CGFijLe8fDUUwvV6zeC1ivAiKDnLD000mU0BOo93dz 64VuAf+5yYRGGS2bX4XVEofR1FHzgNvYmj7nYpw/L0QsICNsU0B71j24Mm495aMXA+4K rQyvgfm09X9jzvT+Me9xUqgg7Ht1FQUmQgeUJpZnDqZtT0++ZYeSmD4C8ouQ7ipdqX5A TiFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=QPRSVzXcyD14zgWjFMeYAQTcyvIGsx3ocDkIgXd3Fcc=; b=N2vRR4sxp7ZB0vstjWpwdRKvIvw978+08VhZv+REQ609KBDDIJolH9K6DtnAwvrpAp 4n8js3kJQKaW/XKxp3RkZWEUfu9s9ecgZ85o1ZG1/8sTNsPDYFJLgwNDgqv2kdc9cKjE k4BruaEUhQw/8SrinXoeq9nE5v1aXWNuUHyHrpB5srrsid1HI2MaawWiJF4isfYQ90OV nMTf/W9YNDdF8auL/3IKX8DhaydrNeb4ocnPAp3VuiheHsWivtWnSmTBUMrJgwTL2EEB KIFxV9vTzeZLyiOPrXx55PBDiltTI/PlZ718Af2iuATv0jGxzIfAuupnKJR5UKTkX3Tl nS3A== X-Gm-Message-State: ACgBeo0uYQXmzPXSKNFlDJiPg8kFNvNarpXb46ZYimqmeTw7Wtx7fak4 arkqa2dGY3VvURVTFQH+Ae2YraRQxAM= X-Google-Smtp-Source: AA6agR6IOHyiSVf7lJHj/B39JATf6O1DKrWNG9BH8Mo3TuwKOvHXBlPwrsyhP7a1zjrPOcr4vybRAQ== X-Received: by 2002:a05:6870:3914:b0:11c:7f09:96fa with SMTP id b20-20020a056870391400b0011c7f0996famr9416521oap.50.1661851923454; Tue, 30 Aug 2022 02:32:03 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id 37-20020a9d0c28000000b006394136eae0sm6970134otr.57.2022.08.30.02.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:02 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 14/51] test: completion: switch __gitcomp_nl prefix test Date: Tue, 30 Aug 2022 04:31:01 -0500 Message-Id: <20220830093138.1581538-15-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org By default COMP_WORDBREAKS includes =, so it's not realistic to test for a prefix that almost never will be there. In bash there are no functional changes, but in zsh this makes the test pass. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 6 +++--- t/t9904-zsh-completion.sh | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 031f05cf47..2fe056ab59 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -565,9 +565,9 @@ test_expect_success '__gitcomp_nl - trailing space' ' ' test_expect_success '__gitcomp_nl - prefix' ' - test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF - --fixup=main Z - --fixup=maint Z + test_gitcomp_nl "branch.m" "$refs" "branch." "m" <<-EOF + branch.main Z + branch.maint Z EOF ' diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index e9df29c135..dbd0671ab6 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -180,10 +180,10 @@ test_expect_success '__gitcomp_nl - trailing space' ' EOF ' -test_expect_failure '__gitcomp_nl - prefix' ' - test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF - --fixup=main Z - --fixup=maint Z +test_expect_success '__gitcomp_nl - prefix' ' + test_gitcomp_nl "branch.m" "$refs" "branch." "m" <<-EOF + branch.main Z + branch.maint Z EOF ' From patchwork Tue Aug 30 09:31:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19BD0C0502C for ; Tue, 30 Aug 2022 09:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbiH3Jck (ORCPT ); Tue, 30 Aug 2022 05:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbiH3Jc0 (ORCPT ); Tue, 30 Aug 2022 05:32:26 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D873BDEA69 for ; Tue, 30 Aug 2022 02:32:05 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11eb44f520dso11113644fac.10 for ; Tue, 30 Aug 2022 02:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=TOdWyA4vLzoKhdbmwho4LOtuzKicaiLbf4P0+UFvws8=; b=nmlODru8ZjQMKRYfcQCcIO2yLoyK9DQdqrgtcdAdo1EI51Xq+79SA6k0Zk26Et72iV y8NfQOECRrYseCb66JFqqQ5eCVDDTCpCSy3ohSj7d0htRldKMtl2NiSz0uCzmmlhMP7W ioT60kzN5uPAJBBw/XOkNyu0Bi54ONzebgbdhJfPwRNIYZcHvP8RHU6613aS3QShYIij Hy5VIt41OHTIbyNvIVcaGa90FkcsOzHO+G1rk/uFnPgkUWA4LyWYszSAda06kYSZf9r2 1g08ES1JoReGv1lF3dz1BOTtnWWZUPe5NPfmq2459vieirMr+3xReXuP5xhp0i2TiB2H 46OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=TOdWyA4vLzoKhdbmwho4LOtuzKicaiLbf4P0+UFvws8=; b=BifaVvpoPSJyBCILaei9G10/Y/JiRh6AVqOToGB5n1BJRXjxp/F7vpGvdoS6W8WtKl MsBjIDxXmFyK6UYFGeX2NOErVGKpnTNGiQ1FjAECEHmJ6fXQU3sP0JCgKpJ5Usubj/yY hwZt1t+1M2OgkKj5NfCFub2+MmbHUVFW2IkAPeiM5HxOlHgnXZRVQ+44MqoxEi42LtQJ 0ei16/vrNr5sCCBDu4yZ5+bcVmOiTQAG6PQI8BOMBJLfOFylk++jUKYc7KLVccRWeWh/ 3CjrQV6w8QH03rS+4rM8GNA+aox8+mQDMMSJi1IUKSzAOMSfYmnoxa8gkbfNHINo01iJ MJ2g== X-Gm-Message-State: ACgBeo2Cn7Jui66syRZIws+1I7Z0wdNNS2w45QS8qBvv5RZRCSmyIbQk vCy2NqSGoV2+Shj13sK9QjLVMJ6LEcc= X-Google-Smtp-Source: AA6agR615htzUKVPqrd9FML8S0TTk7LGK+TtKh9vHle32j0KQJyBPH3ns0gazexxMf0PzKbkn2psmQ== X-Received: by 2002:a05:6870:9590:b0:de:27ca:c60c with SMTP id k16-20020a056870959000b000de27cac60cmr9965855oao.108.1661851925110; Tue, 30 Aug 2022 02:32:05 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id h11-20020a9d6f8b000000b0061c9f9c54e4sm7137223otq.80.2022.08.30.02.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:04 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 15/51] test: completion: add run_func() helper Date: Tue, 30 Aug 2022 04:31:02 -0500 Message-Id: <20220830093138.1581538-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Pretty straightforward: runs functions. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 58 ++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 2fe056ab59..91dfb618c1 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -75,6 +75,12 @@ run_completion () __git_wrap__git_main && print_comp } +run_func () +{ + local -a COMPREPLY && + "$@" && print_comp +} + # Test high-level completion # Arguments are: # 1: typed text so far (cur) @@ -452,8 +458,7 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' ' EOF ( cur=should_be_ignored && - __gitcomp_direct "$(cat expected)" && - print_comp + run_func __gitcomp_direct "$(cat expected)" ) && test_cmp expected out ' @@ -547,7 +552,7 @@ test_expect_success '__gitcomp - equal skip' ' ' test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' - __gitcomp "$invalid_variable_name" + run_func __gitcomp "$invalid_variable_name" ' read -r -d "" refs <<-\EOF @@ -586,7 +591,7 @@ test_expect_success '__gitcomp_nl - no suffix' ' ' test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' ' - __gitcomp_nl "$invalid_variable_name" + run_func __gitcomp_nl "$invalid_variable_name" ' test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from config file' ' @@ -1087,8 +1092,7 @@ test_expect_success '__git_complete_refs - simple' ' EOF ( cur= && - __git_complete_refs && - print_comp + run_func __git_complete_refs ) && test_cmp expected out ' @@ -1100,8 +1104,7 @@ test_expect_success '__git_complete_refs - matching' ' EOF ( cur=mat && - __git_complete_refs && - print_comp + run_func __git_complete_refs ) && test_cmp expected out ' @@ -1114,8 +1117,7 @@ test_expect_success '__git_complete_refs - remote' ' EOF ( cur= && - __git_complete_refs --remote=other && - print_comp + run_func __git_complete_refs --remote=other ) && test_cmp expected out ' @@ -1133,8 +1135,7 @@ test_expect_success '__git_complete_refs - track' ' EOF ( cur= && - __git_complete_refs --track && - print_comp + run_func __git_complete_refs --track ) && test_cmp expected out ' @@ -1146,8 +1147,7 @@ test_expect_success '__git_complete_refs - current word' ' EOF ( cur="--option=mat" && - __git_complete_refs --cur="${cur#*=}" && - print_comp + run_func __git_complete_refs --cur="${cur#*=}" ) && test_cmp expected out ' @@ -1159,8 +1159,7 @@ test_expect_success '__git_complete_refs - prefix' ' EOF ( cur=v1.0..mat && - __git_complete_refs --pfx=v1.0.. --cur=mat && - print_comp + run_func __git_complete_refs --pfx=v1.0.. --cur=mat ) && test_cmp expected out ' @@ -1176,8 +1175,7 @@ test_expect_success '__git_complete_refs - suffix' ' EOF ( cur= && - __git_complete_refs --sfx=. && - print_comp + run_func __git_complete_refs --sfx=. ) && test_cmp expected out ' @@ -1190,8 +1188,7 @@ test_expect_success '__git_complete_fetch_refspecs - simple' ' EOF ( cur= && - __git_complete_fetch_refspecs other && - print_comp + run_func __git_complete_fetch_refspecs other ) && test_cmp expected out ' @@ -1202,8 +1199,7 @@ test_expect_success '__git_complete_fetch_refspecs - matching' ' EOF ( cur=br && - __git_complete_fetch_refspecs other "" br && - print_comp + run_func __git_complete_fetch_refspecs other "" br ) && test_cmp expected out ' @@ -1216,8 +1212,7 @@ test_expect_success '__git_complete_fetch_refspecs - prefix' ' EOF ( cur="+" && - __git_complete_fetch_refspecs other "+" "" && - print_comp + run_func __git_complete_fetch_refspecs other "+" "" ) && test_cmp expected out ' @@ -1230,8 +1225,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified' ' EOF ( cur=refs/ && - __git_complete_fetch_refspecs other "" refs/ && - print_comp + run_func __git_complete_fetch_refspecs other "" refs/ ) && test_cmp expected out ' @@ -1244,8 +1238,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' ' EOF ( cur=+refs/ && - __git_complete_fetch_refspecs other + refs/ && - print_comp + run_func __git_complete_fetch_refspecs other + refs/ ) && test_cmp expected out ' @@ -1931,8 +1924,7 @@ test_path_completion () # unusual characters in path names. By requesting only # untracked files we do not have to bother adding any # paths to the index in those tests. - __git_complete_index_file --others && - print_comp + run_func __git_complete_index_file --others ) && test_cmp expected out } @@ -2457,8 +2449,7 @@ do words=(git push '$flag' other ma) && cword=${#words[@]} cur=${words[cword-1]} && __git_cmd_idx=1 && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' @@ -2471,8 +2462,7 @@ do words=(git push other '$flag' ma) && cword=${#words[@]} cur=${words[cword-1]} && __git_cmd_idx=1 && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' From patchwork Tue Aug 30 09:31:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66854ECAAA1 for ; Tue, 30 Aug 2022 09:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbiH3Jcm (ORCPT ); Tue, 30 Aug 2022 05:32:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbiH3Jc0 (ORCPT ); Tue, 30 Aug 2022 05:32:26 -0400 Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88075A6AC9 for ; Tue, 30 Aug 2022 02:32:11 -0700 (PDT) Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-11f11d932a8so6967252fac.3 for ; Tue, 30 Aug 2022 02:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=vISy3uR92Ws5Lgv961BLrAugQCJgxovBDOxDeoem3FE=; b=EoERlk8CnzJysXIs/trLnkUByMYovsUtyOg0ahsVyiUTL9sdt2s887QdFu4xdDLiOP RhcljnmtP+6TmDNTQXAmkkDIcDCH528MGj+mlpaYfH7tlBcuVYxRnvZgw4DxOUWXjbM9 3A/d10mqKYokvusLlzPGMTp8qxWuWBDLadkcH1FKRwYVCeDZTD4NinYBLBDnwbwQwrWg 3EXmlCRjb8Tytas2OzrhbB/jfg142dL0k4AGxvMSHfM9MQVndMGdGdL0vmKA3WaQkSgZ EefS9iCIlFRKxm7u9Iq5WLgWdvMLqlb9ERCDexAxNPmCgPwN0Xx1OQuRINQkeIqQyWu4 IsZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=vISy3uR92Ws5Lgv961BLrAugQCJgxovBDOxDeoem3FE=; b=gQOiuOWU4UglzgSksBqv+EkXivoNKEUKLU3foGhEv9thtglZG5R6TDYIM12dp2N6Aa 3yD0JShyIoZl90Ti/RGbB/epcjsOlu9bapQJD2uHXdT9Fi2Mz5zfbnmwFdK2K8QLwlLz xcPb7Qh0StS86lxCuBzJ3bPNr2aBhbaZHLoOUJfd1DEXXagsP1TADRj9sJc7p6031i9c nrBnYVrD4RyL/aJ73exqZD8e9pMX0kckzKlcnxKWZ4sg/3xG+ch7bhBJA8QWtk2zAe9O 87q1EDSAT3bOZeWv+IkrCaAJZb9HwAqDBwtfIu2VypBcQUukBG4X+VZMByanQ/Dil5oq LEew== X-Gm-Message-State: ACgBeo1qgLPF3Nt6+gbuTXRPXOfanKt6QtCT42GEgh+1YjizWjr0V2Sc eeAlO6ajJErqU/Ksf2nzZUUTzJE8pcg= X-Google-Smtp-Source: AA6agR6z8GagKY0IesMmys09t2fVSfVTOe94R7K8Sdrtxs9Q62GKbwiSU9hgN8lKiV/vYS0wGOE3dA== X-Received: by 2002:a05:6870:9613:b0:10d:cc11:62ec with SMTP id d19-20020a056870961300b0010dcc1162ecmr9688047oaq.9.1661851926693; Tue, 30 Aug 2022 02:32:06 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id y64-20020a9d22c6000000b006369d5d6372sm5986187ota.50.2022.08.30.02.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:06 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 16/51] completion: bash: remove non-append functionality Date: Tue, 30 Aug 2022 04:31:03 -0500 Message-Id: <20220830093138.1581538-17-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no point in setting COMPREPLY only to override it later, and in fact... we don't do that. Therefore there's no functional difference between __gitcomp_direct() and __gitcomp_direct_append(), since __gitcomp_direct() *always* operates on empty COMPREPLY. The same goes for __gitcomp_nl(). This patch makes the functionality of append and non-append functions the same. No functional changes. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index ef0b7aa192..6571dc1b2d 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -312,7 +312,7 @@ __gitcomp_direct () { local IFS=$'\n' - COMPREPLY=($1) + COMPREPLY+=($1) } # Similar to __gitcomp_direct, but appends to COMPREPLY instead. @@ -464,7 +464,6 @@ __gitcomp_nl_append () # appended. __gitcomp_nl () { - COMPREPLY=() __gitcomp_nl_append "$@" } From patchwork Tue Aug 30 09:31:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 892E1ECAAA1 for ; Tue, 30 Aug 2022 09:32:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231927AbiH3Jcq (ORCPT ); Tue, 30 Aug 2022 05:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231888AbiH3Jc1 (ORCPT ); Tue, 30 Aug 2022 05:32:27 -0400 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF542A8322 for ; Tue, 30 Aug 2022 02:32:12 -0700 (PDT) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-11c4d7d4683so15349775fac.8 for ; Tue, 30 Aug 2022 02:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=SLJEDnLQfpSiBmexI1aeGP+0l58FPjkw4kNppwp6ZWg=; b=BMsd0lJ1ZO9UJehVuvvvus1pdTPjmKaFZTP8irj0mK38MCkMH+1egMjr/2hassWwSs HhwL60O/Jv9YxHUmYd6LxFJTN8x/BUO2VtYRHS6ymqtrETwTdBcDugWKH1ih5+UBJkxv NLJ0Hgt3I1031VMCYGAvoGLenGh5+LcF5GvyYKd73rVxzIRCX1UoqkUOZ6VNU/d2lNyH Se1W4gNVgucYZn3PmtgVmONIhGL73sNU8e5gvXaq2tpjTRq8DZA9v3bDr2F8aTUE/Csw pII3IvdJ2BNzLHeN0nXdtx34IjjdrI6HxXaMtWI+jCvTy0sYXYOW/V8PNwNCo9ZOXW67 oGbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=SLJEDnLQfpSiBmexI1aeGP+0l58FPjkw4kNppwp6ZWg=; b=UTe0yzjGfo9+PYflsKv0vzslsFSjXiO3G5vk9OlGbO7L2U4BvE2hEm3dtOlN6UHv3H 2GRQtE09aWzV+xLwrUUUTMEwiiXWiYvqh3nOb4FHiylxSlNVyzO/Pj35c7i7hUMz3t3h tdMF1mrMiSP3gs/ehRBQUFVPbJbIPFpEhmixxx5vYcfZsSvYauQlvT2/MXG2m9NAHR9a VutxQKqVnes6zqthAatMjBd0Dkd35ROMAycvlQ1uulpiwkxIxykWEMK9M0S2jrRmbWt5 HEbQP6ttnzXxOD19NTETsF8X6wXfSuDRj9A9q3HYvoWDXOiB0meGFxUNw2xDiC7EB38Q MOAg== X-Gm-Message-State: ACgBeo1REPN95JSmFxZcOoeTefqJE5sxpAAkwIOW4cGuDcByU/6xNgJ6 X+qPhoPNuKt8uiHnC3ozWuPsnAU4NpU= X-Google-Smtp-Source: AA6agR7r0cAMIhOPrXzF4wpTmfZ6XLKbl+72RVSqElAvyaRYoVz9EsvptnCbSCVCA6mabsL8KHppFg== X-Received: by 2002:a05:6870:e997:b0:10c:6f42:b05e with SMTP id r23-20020a056870e99700b0010c6f42b05emr9295755oao.89.1661851928428; Tue, 30 Aug 2022 02:32:08 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id bi5-20020a056808188500b00344afa2b08bsm6002641oib.26.2022.08.30.02.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:07 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 17/51] completion: bash: get rid of _append() functions Date: Tue, 30 Aug 2022 04:31:04 -0500 Message-Id: <20220830093138.1581538-18-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no need to have duplicated functionality. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 35 ++++++-------------------- contrib/completion/git-completion.zsh | 10 -------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 6571dc1b2d..4a7e75b48d 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -301,8 +301,7 @@ _get_comp_words_by_ref () } fi -# Fills the COMPREPLY array with prefiltered words without any additional -# processing. +# Appends prefiltered words to COMPREPLY without any additional processing. # Callers must take care of providing only words that match the current word # to be completed and adding any prefix and/or suffix (trailing space!), if # necessary. @@ -315,19 +314,6 @@ __gitcomp_direct () COMPREPLY+=($1) } -# Similar to __gitcomp_direct, but appends to COMPREPLY instead. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct_append () -{ - local IFS=$'\n' - - COMPREPLY+=($1) -} - __gitcompappend () { local x i=${#COMPREPLY[@]} @@ -445,16 +431,8 @@ __gitcomp_builtin () __gitcomp "$options" } -# Variation of __gitcomp_nl () that appends to the existing list of -# completion candidates, COMPREPLY. -__gitcomp_nl_append () -{ - local IFS=$'\n' - __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" -} - # Generates completion reply from newline-separated possible completion words -# by appending a space to all of them. +# by appending a space to all of them. The result is appended to COMPREPLY. # It accepts 1 to 4 arguments: # 1: List of possible completion words, separated by a single newline. # 2: A prefix to be added to each possible completion word (optional). @@ -464,7 +442,8 @@ __gitcomp_nl_append () # appended. __gitcomp_nl () { - __gitcomp_nl_append "$@" + local IFS=$'\n' + __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" } # Fills the COMPREPLY array with prefiltered paths without any additional @@ -851,7 +830,7 @@ __git_complete_refs () # Append DWIM remote branch names if requested if [ "$dwim" = "yes" ]; then - __gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")" + __gitcomp_direct "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")" fi } @@ -2650,7 +2629,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" - __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }" return ;; guitool.*.*) @@ -2700,7 +2679,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." - __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl "pushDefault" "$pfx" "$cur_" "${sfx- }" return ;; url.*.*) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 2de1a72c09..35300a08cd 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -122,16 +122,6 @@ __gitcomp_file () compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } -__gitcomp_direct_append () -{ - __gitcomp_direct "$@" -} - -__gitcomp_nl_append () -{ - __gitcomp_nl "$@" -} - __gitcomp_file_direct () { __gitcomp_file "$1" "" From patchwork Tue Aug 30 09:31:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F719C0502A for ; Tue, 30 Aug 2022 09:32:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbiH3Jcs (ORCPT ); Tue, 30 Aug 2022 05:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbiH3Jc1 (ORCPT ); Tue, 30 Aug 2022 05:32:27 -0400 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF698A896E for ; Tue, 30 Aug 2022 02:32:12 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id d18-20020a9d72d2000000b0063934f06268so7690058otk.0 for ; Tue, 30 Aug 2022 02:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=4Ii+7GiIUf2Kag52CRz43gixuv5IGmAUflOSyrgKks0=; b=A18zemkQJC9e/JxqFnpc3A90JOJQ7SxfJDwckcOp17cuT7W868cGNSjPUcC/j/8Khu i5ffH6Z59lkMLj7dBnYfcd8lH9Gyr+ktFcXOYLG0Z5lo2NQgIdSrTay6rrIB6sMi4Zef +oNdhE9DDoHTam5fbmBGsmo5uJFlL/5JOxk6fUSLNxZW1I/jwpgH2kH9JM1UdI8UKLkb KackZPP5gApIMpgJu3Wbk2xXo+VIfWk4rkjKfN7Tm+nqRFvn8yct6YgLK4B3K+TRmxLt CIMT5zn9W6BBDpwylUoy2/CzdlDqdQqWH0A7Qn7QMxfCVZVSyiCzofSCDR53OjNyQRe1 l+XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=4Ii+7GiIUf2Kag52CRz43gixuv5IGmAUflOSyrgKks0=; b=w8hpY5wka3ZUKgW0+Zoi66PxPv6Q9HxRo5TArmmicocDFl8IxoATNf9/kusvMHcrQH twwJ/n2KDv/zRgR/jJJqBz5WOwoktgAfUBK50AOwhWjOoHoCWkWaezDLlED57Lxtc6jv cdmO8C7X10Wx205aT61lxv5dsso391BMw8XFw1LbO8HrkMsTO8jVRqU74Mzt54t0EXle X9R6sdlu8aFJAwO5dBYdrwpVg+VduuBtSqui5zrQ4s4WVyhJVQq5gYwssfv5wFhvOJrN ZDdPPpaAjhE4p2AS7FQpnhyzj8z0WYUMWabxoJ4vjpakzthG62tK79a6HUtBKnkPY4v8 6DYQ== X-Gm-Message-State: ACgBeo1T6Kw+q/tKJcBT6HTz7r9coRJcAJr9aclwMHl1Hpjb2Sl8WPTY EtgCzZmMVzNKivzAR1wHvEBbwxmVCyM= X-Google-Smtp-Source: AA6agR75J5QLPhzDbTF2Uqs6OHZaUuRYOVxg7hhmq00pN0YoFQexPRA1shOVz+lApEMjTchMsxk5CQ== X-Received: by 2002:a9d:6a97:0:b0:636:ed2e:94ec with SMTP id l23-20020a9d6a97000000b00636ed2e94ecmr8052418otq.272.1661851930065; Tue, 30 Aug 2022 02:32:10 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id cp6-20020a056830660600b0063b34c35575sm1563395otb.42.2022.08.30.02.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:09 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 18/51] completion: bash: get rid of any non-append code Date: Tue, 30 Aug 2022 04:31:05 -0500 Message-Id: <20220830093138.1581538-19-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 4a7e75b48d..ed126bbec4 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -314,7 +314,7 @@ __gitcomp_direct () COMPREPLY+=($1) } -__gitcompappend () +__gitcompadd () { local x i=${#COMPREPLY[@]} for x in $1; do @@ -324,12 +324,6 @@ __gitcompappend () done } -__gitcompadd () -{ - COMPREPLY=() - __gitcompappend "$@" -} - # Generates completion reply, appending a space to possible completion words, # if necessary. # It accepts 1 to 4 arguments: @@ -443,7 +437,7 @@ __gitcomp_builtin () __gitcomp_nl () { local IFS=$'\n' - __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" } # Fills the COMPREPLY array with prefiltered paths without any additional @@ -456,7 +450,7 @@ __gitcomp_file_direct () { local IFS=$'\n' - COMPREPLY=($1) + COMPREPLY+=($1) # use a hack to enable file mode in bash < 4 compopt -o filenames +o nospace 2>/dev/null || From patchwork Tue Aug 30 09:31:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF20FECAAD4 for ; Tue, 30 Aug 2022 09:32:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230297AbiH3Jcu (ORCPT ); Tue, 30 Aug 2022 05:32:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231895AbiH3Jc2 (ORCPT ); Tue, 30 Aug 2022 05:32:28 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64B37A1A61 for ; Tue, 30 Aug 2022 02:32:12 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11edd61a9edso9321799fac.5 for ; Tue, 30 Aug 2022 02:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=G9nlGz7A7j2RJ5umqF/L4Fw9IL4RiOh2I0NPMQFzOTI=; b=EE3ohUCJ+TfjmrCHvdzBSa/JGKXMAaPspr/ljpPoBdonW17PFAPWlSCkgDc29X+2d/ Mf2UdQK/TcMZ8aTrEnSeCh+syPkhxY6tWIZMxdROtLqaosKnkhe3QEOQE/A37wuooCgy Ls3vM/cp3gal9deydHzqtnVi65YTWzNcQ5fGb/9VRhv4dnJ0TALzRq5FouNsJzM7eEgT VKCVfBBNGfuhngMsjqPSpLkMX9zmo7MWAwr9l7e/pnsGVc+/+3/hDT25+bjc2jydLJ7s emPUKisI/kVvg5aBxPoCj8WOwqZaHlvVfLdvZnJgp6hLfPfLAbtFlH/N7Xrii9SrQaEL l4ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=G9nlGz7A7j2RJ5umqF/L4Fw9IL4RiOh2I0NPMQFzOTI=; b=kRoElV/OSPNIhWaXFwwFKJGJ4hQM8V7PNGkuEisXyGnxk5EtnLSvohHfOvQTNR6Mo1 wpDLAZRgSF4UJOeG28ya4A8lB5dB3qeeK7PnVkbjiKtcUIPbCabgd1IHtXJMkT+kI3ZD 6REhBddmUZAuMeL+7pFBujsHcYEX5wdRq1kM3yGpND+1X+6NFoTReAWND+H/25hT2Non 6LQywcUtXQ0X898mTm3sLy2847pAYs82ydl1SI8WHwtr85G8w8G7tJg+8XhQvJaS3too 1lnlTtSfpKiy6vc6EVysIc4nesh7K3DPAtjaUz55N2/4RknaRfFBo18QuYKJhurQfFtW lBow== X-Gm-Message-State: ACgBeo3R735w+Sho4wrW5OEfe4rK2XiUf1rdWhtRJDY6OSrwgDLrYqBf wrKuONeg8O/Buf/fkBP/LwFwSnfp0CM= X-Google-Smtp-Source: AA6agR74VXymCRnpkwry9qqFPpHWfSAurm3UzO3lKou+zZaaL0QbsLSQmRH7275QpEptJQUUIkA5SQ== X-Received: by 2002:a05:6870:5705:b0:11e:553:1a6f with SMTP id k5-20020a056870570500b0011e05531a6fmr9445972oap.97.1661851931546; Tue, 30 Aug 2022 02:32:11 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id c5-20020a9d4805000000b0061c3753c30dsm7041791otf.17.2022.08.30.02.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:11 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 19/51] completion: zsh: fix options with arguments Date: Tue, 30 Aug 2022 04:31:06 -0500 Message-Id: <20220830093138.1581538-20-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org They support both '--git-dir=value' and '--git-dir value'. Fix the arguments to support both. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 35300a08cd..10ad15face 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -215,15 +215,15 @@ __git_zsh_main () _arguments -C \ '(-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' \ + '--git-dir=[set the path to the repository]: :_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' \ + '--exec-path=[path to where your core git programs are installed]:: :_directories' \ '--html-path[print the path where git''s HTML documentation is installed]' \ '--info-path[print the path where the Info files are installed]' \ '--man-path[print the manpath (see `man(1)`) for the man pages]' \ - '--work-tree=-[set the path to the working tree]: :_directories' \ - '--namespace=-[set the git namespace]' \ + '--work-tree=[set the path to the working tree]: :_directories' \ + '--namespace=[set the git namespace]:' \ '--no-replace-objects[do not use replacement refs to replace git objects]' \ '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ '(-): :->command' \ From patchwork Tue Aug 30 09:31:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05CFDC0502A for ; Tue, 30 Aug 2022 09:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231747AbiH3Jc6 (ORCPT ); Tue, 30 Aug 2022 05:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231727AbiH3Jca (ORCPT ); Tue, 30 Aug 2022 05:32:30 -0400 Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27DF3DF0B8 for ; Tue, 30 Aug 2022 02:32:14 -0700 (PDT) Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-11edd61a9edso9321937fac.5 for ; Tue, 30 Aug 2022 02:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=oTRE06/q9ntf0vVxS5BAWAQYIHk6BB6j42GcRK3OcPY=; b=N57JwuX5eU1vQUgnQWp7wWOdUZmjAGN94IVJy1h0KeCedMhanusI0u7VAGtMtB34gy 9RQWCeqDQIFORIkazssvE0XraLmkwBf09bCl7yakHmvkRrCFSTVOkRWHUyh4Fh4qoB/P pbW/Frhr9TKfRmWiWzg0lbsPlaOHC+FgeuJy5futXW5COWjKFc26AuOz1fKPdlrcgbIU OhMQlf6JsOvOKIYPTMph21fV9Z5P1SqOtUSQdfhSXJxBM0dlbxtNOgpBkU0zNr2dXX17 PMaFUN9kw19fh79PnOw/vDpo1EDiPOhFyvp8Dri0bKi4twAMarqUmIek0LFld5kX1P/i yX4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=oTRE06/q9ntf0vVxS5BAWAQYIHk6BB6j42GcRK3OcPY=; b=7WaMbYuByEfzwg9FSFA/MYfwx4Ww+C8s1+RMY6PQltAnRfBwvbLG3iEMchFWEkxGcO oJ7AmMw/xWgjabKzp6bX4Eh3Xx7hd457mOh3AWznqhYZ1+3PfLq05FrjgjBiHJqw4rqd rOpHkfMEjjUYmmxhHEWOvAP9axb/KuO+57CGYLtNjTR/xXKqprvCRcBwkbbZNuIQ7unX 8rvy0ueDyPQoYdx4xX+aJA+JazVLvyiVAiTIZHk2cRkzp+qoAd3UBv19Fs8X0SGC3tAE mokaIeCVy1cep+nr3H/8RExqCpe0k5hBCjyY/QJxZkH/nwD6ys/iE5wJihAuLvjiSl/n jtVA== X-Gm-Message-State: ACgBeo2gYqgRY9h/CcHCYTijyMVDnkVq3Fmsfbbkwr2rjpzamhfLXAgh hPRfJSLNUH3lGuH3otOShoIsc5SlOz0= X-Google-Smtp-Source: AA6agR7INhKmNQCNo+vZXx2BdDRV46ansWh5udPOdYG7Gqd5ibTzTVg30dE5MVw+aKBqvy/QmJ+bRA== X-Received: by 2002:aca:d0a:0:b0:343:4049:689b with SMTP id 10-20020aca0d0a000000b003434049689bmr8830838oin.56.1661851933318; Tue, 30 Aug 2022 02:32:13 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id u187-20020acaabc4000000b00342df642fd3sm5844662oie.48.2022.08.30.02.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:12 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 20/51] completion: zsh: expand --git-dir file argument Date: Tue, 30 Aug 2022 04:31:07 -0500 Message-Id: <20220830093138.1581538-21-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 10ad15face..0e72b9add7 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -245,7 +245,7 @@ __git_zsh_main () if (( $+opt_args[--bare] )); then __git_dir='.' else - __git_dir=${opt_args[--git-dir]} + __git_dir=${~opt_args[--git-dir]} fi (( $+opt_args[--help] )) && command='help' From patchwork Tue Aug 30 09:31:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56D45ECAAA1 for ; Tue, 30 Aug 2022 09:33:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbiH3JdB (ORCPT ); Tue, 30 Aug 2022 05:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231867AbiH3Jcb (ORCPT ); Tue, 30 Aug 2022 05:32:31 -0400 Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C7E9DF661 for ; Tue, 30 Aug 2022 02:32:16 -0700 (PDT) Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-11e7e0a63e2so14519113fac.4 for ; Tue, 30 Aug 2022 02:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=jJzKaJIKYSSPAQm/JyDvzt6kwDenfCV005u8TajJqZo=; b=pmPTn3IR0halDVEBp3YaSq9HIM7xc2zg26QrvUy4Zmj76OuVHtzOgtur5U5NXDwfjQ hoTcqmHDsJNjL890boH5gWNmcPyL9NA1yQJ3PwIGZtZqINaopRwzcFW7VkMRGhlsHCX6 57XdaBOTExCk/xb0Ttz9mPgeyw2h7zScfgTPt8Wz2O3NYQecLmuFTZBD6iVrkV6PpMLD 53MGmNoq9oa6YKQn645awEA/8QgmMo++VEvou24L+lSB+igpUD9v1LaCqz+W0mrGVodw 3PTSTPtg5HrZZVRvj7L7CHEcZnB32f82EKtdRw1t3xbwQ2XnNlvfo+IthyzBo0dAC4pe Q66g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=jJzKaJIKYSSPAQm/JyDvzt6kwDenfCV005u8TajJqZo=; b=6BL+cc92dXvDeJYyqTFyIrpTEPH/VF7APJHZijvtjyLrq0BRzECrXC3wXYkLnvR/Km XO+JVoCZ1We2gFSPKo9Gvj3O20YXvFH0Yk4D+sHtJ186drtT8IC5jP8/j4qYfWyssM3s qEpJGyPKXho2TAH1Jn5cSdPEqLAAv6EZPQje3ZlR8cR7qezyL1sD9nEhd2U3NFVJ5o8E rF1pxK0y17OdrLNWN08XHpvH13O5HnVjIWWNEDT7Be2INgsaLk6GaS8MWZ7LROtzozyy OnjryWw2qSyyZ/iX7Oce4yEAokUYAd2DBBwMcoQztELkOydR3UgkSzdXSg4re1pmcY45 2oTQ== X-Gm-Message-State: ACgBeo1bt/jaY4v9BZ+dWK3R56H9/vu0ugZZi/tr9OcLpx8XhDkxrIc3 BDFAOx2O6ooXKrqCKjaVE7aNYxouAL0= X-Google-Smtp-Source: AA6agR7nuRh6butW/S2Pkz1jgFpGu3Wv4fX54255cg8Bfd10FDJRlY48uXnQoM+MmdYV7BpBIL84xQ== X-Received: by 2002:a05:6870:e408:b0:11c:37ad:773a with SMTP id n8-20020a056870e40800b0011c37ad773amr9957265oag.44.1661851935812; Tue, 30 Aug 2022 02:32:15 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id k4-20020a056870958400b000fb2aa6eef2sm7485966oao.32.2022.08.30.02.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:14 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 21/51] completion: zsh: add support for general -C opts Date: Tue, 30 Aug 2022 04:31:08 -0500 Message-Id: <20220830093138.1581538-22-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 6 ++++++ t/t9904-zsh-completion.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 0e72b9add7..e771a2a53a 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -211,6 +211,7 @@ __git_zsh_main () { local curcontext="$curcontext" state state_descr line typeset -A opt_args + local -a __git_C_args _arguments -C \ '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ @@ -226,6 +227,7 @@ __git_zsh_main () '--namespace=[set the git namespace]:' \ '--no-replace-objects[do not use replacement refs to replace git objects]' \ '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ + '*-C[run as if git was started in the given path]: :_directories' \ '(-): :->command' \ '(-)*:: :->arg' && return @@ -248,6 +250,10 @@ __git_zsh_main () __git_dir=${~opt_args[--git-dir]} fi + for x in ${(s.:.)opt_args[-C]}; do + __git_C_args+=('-C' ${~x}) + done + (( $+opt_args[--help] )) && command='help' words=( git ${words[@]} ) diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index dbd0671ab6..cd223b6e2a 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -844,7 +844,7 @@ test_expect_success 'checkout completes ref names' ' EOF ' -test_expect_failure 'git -C checkout uses the right repo' ' +test_expect_success 'git -C checkout uses the right repo' ' test_completion "git -C subdir -C subsubdir -C .. -C ../otherrepo checkout b" <<-\EOF branch-in-other Z EOF From patchwork Tue Aug 30 09:31:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958982 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4952ECAAA1 for ; Tue, 30 Aug 2022 09:33:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231903AbiH3Jdb (ORCPT ); Tue, 30 Aug 2022 05:33:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbiH3Jcf (ORCPT ); Tue, 30 Aug 2022 05:32:35 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE0DB274A for ; Tue, 30 Aug 2022 02:32:23 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11e7e0a63e2so14519281fac.4 for ; Tue, 30 Aug 2022 02:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=vbg4T3709lqU4B0+MCq7YjsWAhF1cwjUXEVMTobpfY4=; b=W7BhaMMN9F0fC2QP9bMqlA6tzijKTa++kVFBRielAkDwUnxw4lORq5LVH7ESwY+Lau NolpevzTB+4oQT2ZxINptHu4JlNu04FJxGFKQCTvSIT82yFx0fYD4JUFmSUFEKvVkKnE eXdWZLdZL7MseGhMrHJnYXDZebu//U6LYXkFMhKcNVmimQpZKnngYNG3T/1Hq96wjBKw q34RnLHBMuNG6fzCpQAT+lgWcnYVIgtWCpHxo8gMFbqczBDE2FosFIEePRQNmbUtsDxb 1CUHNqbZeki92TtijBCJPHbFtE72TaqnQZMHNPeRACOSe3jwrO7JazemVUDe6RXTfLZL HDAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=vbg4T3709lqU4B0+MCq7YjsWAhF1cwjUXEVMTobpfY4=; b=hr/xI984sSmobUiHwoyd/ivJr1aOxIlzdOLVex+MxtqJurVI7uBnNWGP4HknkNf23p f1MZKKBbAI6aRi7blJKqE1biip5UnJe4XNRJMqPX/0RIaOoq8Cu9pnenonFEzsSe6vba +XD1ND4ohD+2LP8UOgFf+E/xt9JAdofdK/69Rx0tenw69vp+kmdCFPDBqMjr5UDMH+ZO 6/mXgmyr9aO0nBRkG1s2MybgIvuWfsPwaBWiunjHXHqPOCxpJi2eaNZIanavc9Qt6sln hZeBu5B99tSUW3U1oVhHpPjw1HipcEcYbKct4KnI4DzALyop0xHVDPtp+DVcjoWR/GP/ FSSQ== X-Gm-Message-State: ACgBeo3LNlFFMgL/c6KYymLGsJF1b1ijfX2p5DrnLLaHmYC4uuReNfk6 eoogxif1zFSi4MhpVfIBZnLeoEePbBk= X-Google-Smtp-Source: AA6agR4omMu0laT5AaaPXNn28oDvv4myUz6W6mCxve3tgfMw6ZCEIjzxKMHaOyC6irg/ispbmV+M7w== X-Received: by 2002:a05:6808:138d:b0:344:973a:366c with SMTP id c13-20020a056808138d00b00344973a366cmr9145759oiw.134.1661851938261; Tue, 30 Aug 2022 02:32:18 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id by6-20020a056830608600b00638e49d4cadsm6944185otb.36.2022.08.30.02.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:17 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 22/51] completion: zsh: fix for undefined completions Date: Tue, 30 Aug 2022 04:31:09 -0500 Message-Id: <20220830093138.1581538-23-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The parseopt helper can generate the completions even if the function is unspecified. git version -- Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 3 +++ t/t9904-zsh-completion.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index e771a2a53a..30607aa93d 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -141,6 +141,9 @@ __git_complete_command () if (( $+functions[$completion_func] )); then emulate ksh -c $completion_func return 0 + elif emulate ksh -c "__git_support_parseopt_helper $command"; then + emulate ksh -c "__git_complete_common $command" + return 0 else return 1 fi diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index cd223b6e2a..14f5e5d9b8 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -1015,7 +1015,7 @@ test_expect_success 'completion used completion for alias: !f() { : git X-Patchwork-Id: 12958980 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6FFCECAAA1 for ; Tue, 30 Aug 2022 09:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbiH3JdR (ORCPT ); Tue, 30 Aug 2022 05:33:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230418AbiH3Jcc (ORCPT ); Tue, 30 Aug 2022 05:32:32 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA6FE01D2 for ; Tue, 30 Aug 2022 02:32:20 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11eb44f520dso11114888fac.10 for ; Tue, 30 Aug 2022 02:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=16p2c6L0W5J0LiTr+3BZfTV9XPOHs57NzZeTdEr51cg=; b=EwhHfHLjFTFM/WkB5Rhn/IKGMmcAs5dkScKKv67gFTkfY/2M8ugUB0lRhaMpZuHFCs LivtsW6hcA0fAzry2vu+Re71frAxRZUx0WNL3Slt/DPxspmd7XebGo27o1S6bNJAaEAv rhAjUrv4XE70OSKHgumMEmpUcSfM+b9tUTowFPVMEzw5h/2ZjL6JocfOTuwKkSG01fgo KwGm3KNTUo+cIkl8FPJvQD96Kr4RD3pHCT9FT8X4T6fKxLGJ/D68ifMAWE/uWXoaq0/e MQzJ7j3SOsyVDuCN8OY2aBp1J691pDcL4B3cPkQjsadmZvBK2EAAp1pHaQ38gexlwGA3 VjfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=16p2c6L0W5J0LiTr+3BZfTV9XPOHs57NzZeTdEr51cg=; b=y6v1EvjjRzyUO5NV8cMRdow3pDJxCmE9lqyEPH3T0DTr18J4acx/qJx8gGMsfE4TqM EAmheVz68kL5Ov4Pyolnc7LXSGZ8/T8gVzm2/bRNgv6HDePVq26JXrxQKOON1SxBiXuF PPRjzk2LnJrL8y5Bi97QK6mvrjntwVBpVv6OXw5R3bb83JpHg9S8rEKGLi2sBUaps+B/ 2fpKDliy5kz9xLtLpPjKgBeu5iK+rCfcT1PBaB018+FiTBb3+1qHtcFkaZWtLTMlXSAS ZXfAHiY224z7QO4cdSbjxBUZMjiK03duNhGdORm146y9lK2fM9E6nqIwcpbhOS42PFwT pBeg== X-Gm-Message-State: ACgBeo2F/kxdJRDrhzgoOwA9wFFuHt0paYvjwT3OUUqtJv00z7Ey2JS6 pbjJJ/iKntzAGjOuretzOPnJu7WS/cY= X-Google-Smtp-Source: AA6agR5YQg5VkiMwyO9WKw8Y/iwvlpZp8iQbAeD0Zv+RiTgaJ/pmGpyOCkcpfOtYgt3N2RNSjqp6xA== X-Received: by 2002:a05:6870:6087:b0:10b:aef4:db0a with SMTP id t7-20020a056870608700b0010baef4db0amr9468606oae.17.1661851939834; Tue, 30 Aug 2022 02:32:19 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id t28-20020a056870f21c00b000f5e89a9c60sm7519464oao.3.2022.08.30.02.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:19 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 23/51] completion: zsh: add support for general -c opts Date: Tue, 30 Aug 2022 04:31:10 -0500 Message-Id: <20220830093138.1581538-24-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org So we can specify configurations. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 5 +++++ t/t9904-zsh-completion.sh | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 30607aa93d..b062090a13 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -231,6 +231,7 @@ __git_zsh_main () '--no-replace-objects[do not use replacement refs to replace git objects]' \ '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ '*-C[run as if git was started in the given path]: :_directories' \ + '*-c[pass a configuration parameter to the command]: :->config' \ '(-): :->command' \ '(-)*:: :->arg' && return @@ -244,6 +245,10 @@ __git_zsh_main () let _ret || break done ;; + (config) + compset -P '*[=:]' + emulate ksh -c __git_complete_config_variable_name_and_value + ;; (arg) local command="${words[1]}" __git_dir __git_cmd_idx=1 diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index 14f5e5d9b8..4c7cf4234e 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -1071,7 +1071,7 @@ test_expect_success 'git config - value' ' EOF ' -test_expect_failure 'git -c - section' ' +test_expect_success 'git -c - section' ' test_completion "git -c br" <<-\EOF branch.Z browser.Z @@ -1086,7 +1086,7 @@ test_expect_failure 'git -c - variable name' ' EOF ' -test_expect_failure 'git -c - value' ' +test_expect_success 'git -c - value' ' test_completion "git -c color.pager=" <<-\EOF false Z true Z From patchwork Tue Aug 30 09:31:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C645AECAAA1 for ; Tue, 30 Aug 2022 09:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231867AbiH3JdW (ORCPT ); Tue, 30 Aug 2022 05:33:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231742AbiH3Jcc (ORCPT ); Tue, 30 Aug 2022 05:32:32 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D0A4DFB7A for ; Tue, 30 Aug 2022 02:32:21 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11ba6e79dd1so15328252fac.12 for ; Tue, 30 Aug 2022 02:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ZEvynSs2hSAJBxY5Z1n8aBnLEOJKjM1ygizJX+kjujY=; b=CHNZ+A4AWxyEuQZnvXnNaX07xEA8e58ykAubV1xZGCjWMyyq2+MgP6MnhvOOq/r0hk AwY3V76rEi8lEbvxzpT5jnZ1QrF63C0wA2Iq1tZ80cowMUtgGbMZWZF76553fwIC1EQR sJBnQSvaalVzP6obJHJ/YRjVG3j+IOI3iEdzV+YI+kW4xH7NVkhXI/78rVqKkhobqqDH JwMC6+B/QMt8ta6oC1eQjSRUz5Sc1pjw4bJSEH7RzIvDJ2K24GKMhW4KJ4AooejguoMO /NfcU5+OrYeFnniaiO5PoSLB5BHxgv+y0jxZYtHcKNyj3DNiVZcZ0p1RWW44pfz4RVGO vbTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ZEvynSs2hSAJBxY5Z1n8aBnLEOJKjM1ygizJX+kjujY=; b=VV+tIlNiSD0lEFq1DFkHQ7UCSf2GH7+SW0SwdaJMDWgSZIlHaj6wUBiHbF9qmuRMi1 Jbq93RRdfVWaxcTWkncD8cFUoFMjRIxGl2qfRh8oJx2e8RbGhQN30JOrGAOQFFYppOWC GEi2IjYDazeZO1q5rKchkUhtyDm+Wnrv/xjBykHEIY2KiXdvpmXZXO7UY1+WBf5GOv9+ ReqeoeQlWRl+aelm5mfv9Wfn7KNBBqox0FqqWAIVe0OBEt2vpLPa6cfvjp9SfaN2icbh qE23OLF5FC338GB1NPaR9zsyYTg7GQ5S8Dmfbd1M9cmTuykHruBhvmCjjFaJhixm/Ydk Z9zQ== X-Gm-Message-State: ACgBeo3sBueJei08VfxYHrD4XP/NHAa/g7V6/zJyeBkbFxbl3wrmJmz9 ctUU2bVmermFtoyMblGEWcpkMOWABz4= X-Google-Smtp-Source: AA6agR6fnaFPYxvmZ6lq8JxZwYXDBx/aoOkhxZbFjHJqqnHrUvTEIfVQykD8HAhsD3LwqwpEup1mNg== X-Received: by 2002:a05:6870:d291:b0:11d:25d6:e521 with SMTP id d17-20020a056870d29100b0011d25d6e521mr9848659oae.198.1661851941308; Tue, 30 Aug 2022 02:32:21 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id v6-20020a4aad86000000b00448a3ecdc9dsm6386317oom.22.2022.08.30.02.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:20 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 24/51] completion: zsh: fix extra space on foo= Date: Tue, 30 Aug 2022 04:31:11 -0500 Message-Id: <20220830093138.1581538-25-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Upstream commit e1e00089da fixed the issue for Bash, but not for Zsh. When we are typing configurations an = at the end signifies we still want to type the value. Can be tested with: git -c log.d Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- t/t9904-zsh-completion.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index b062090a13..f732881958 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -87,7 +87,7 @@ __gitcomp () fi c="$c${4-}" case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac array+=("$c") diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index 4c7cf4234e..7283af3342 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -1078,7 +1078,7 @@ test_expect_success 'git -c - section' ' EOF ' -test_expect_failure 'git -c - variable name' ' +test_expect_success 'git -c - variable name' ' test_completion "git -c log.d" <<-\EOF log.date=Z log.decorate=Z @@ -1100,7 +1100,7 @@ test_expect_success 'git clone --config= - section' ' EOF ' -test_expect_failure 'git clone --config= - variable name' ' +test_expect_success 'git clone --config= - variable name' ' test_completion "git clone --config=log.d" <<-\EOF log.date=Z log.decorate=Z From patchwork Tue Aug 30 09:31:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D79BBC0502A for ; Tue, 30 Aug 2022 09:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiH3Jd6 (ORCPT ); Tue, 30 Aug 2022 05:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231920AbiH3Jco (ORCPT ); Tue, 30 Aug 2022 05:32:44 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB3E9E096E for ; Tue, 30 Aug 2022 02:32:29 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id z22-20020a056830129600b0063711f456ceso7667427otp.7 for ; Tue, 30 Aug 2022 02:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=DdMx+UE5my843uOVT+nSBERu9OMnfYEPVHx6qQSvIdY=; b=S01SjpeHPOOIjnEweUXCENIT3AQE4DKkmlLsdqaNe5iDc7D7QWMXCZXuge5Wl0pBDv zp5REtu5aEQyCKac18sLo3E6QqceCnwAQYUMl9lHFw4LId9B2W9ISxRflc0p4AB69cED m2L3Myxpgq4Y7H/AHfP2k8xx0JH1GLmMmbmE660cjwZPNbImaZom7X4Ca8s9TJNc0zSS tzgkXWg0QIVWu5BE9Ral8wYDIG3JqvZnfzM/RX1R2qsiykLFYitCt7Aa9gGcqUxzEoit 2JQo8EyPDKy/FFIKpoyITBqL/xFV4kiQ9y7NiDRazxSoqHxpaX1GK9N9ZSPeB++PM3hk kEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=DdMx+UE5my843uOVT+nSBERu9OMnfYEPVHx6qQSvIdY=; b=NASjZvfxCkEyLknPuVPAId+tvISzbEq4iK24SfExHQ2+3SAdkHE4wmQG1xCmI5DqFl 21x97Lroyx1hK1FgD172Ah91Wr2PcCMYomds12eobNkCW6B/myGUbN/ST0m4cpg0Ep1H 56hqfDhOtLCszrLSo2acA3++LCrmaw///9jSa7c+m7JtJ4F8EsdHCuX642xexRCCpy1L U42SQYuzqQxCuBZNq5k83u1U/9P1mCIWwyOYAdzIKvDZTmIqf6HLib+p6FeGharR0UUH Vs20TsDDZMRUq86aJAvph4rE+GeKZ2B+msGd6+0q4veZq0ouvnBdGWvf9h2bCHsVEm+W HooQ== X-Gm-Message-State: ACgBeo1M7rLrhJD2Tv3Fbq0BPgvFbhhcQbUm0S8Dt2VkwBSPLNxOI75X rbQ00qQjWuI/gce5njVIb7ZtVrtJ8LA= X-Google-Smtp-Source: AA6agR5HkZHwYN8ItJn8xgikZbKK0+DIrdrBWosWZeOvUobmpXuI0SriDrZMhN+PITG6XFJ9mCz5ew== X-Received: by 2002:a05:6830:1145:b0:639:6fc2:3ac9 with SMTP id x5-20020a056830114500b006396fc23ac9mr7376152otq.303.1661851942847; Tue, 30 Aug 2022 02:32:22 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id a6-20020a05680804c600b00344cc0c4606sm5771341oie.58.2022.08.30.02.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:22 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 25/51] completion: zsh: add excluded options Date: Tue, 30 Aug 2022 04:31:12 -0500 Message-Id: <20220830093138.1581538-26-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add more excluded options, for example: --bare excludes --git-dir. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 17 +++++++++-------- t/t9904-zsh-completion.sh | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index f732881958..d2eb221d79 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -217,15 +217,16 @@ __git_zsh_main () local -a __git_C_args _arguments -C \ - '(-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' \ - '--bare[treat the repository as a bare repository]' \ + '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ + '(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \ + '(--bare)--git-dir=[set the path to the repository]: :_directories' \ + '(--git-dir)--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' \ - '--html-path[print the path where git''s HTML documentation is installed]' \ - '--info-path[print the path where the Info files are installed]' \ - '--man-path[print the manpath (see `man(1)`) for the man pages]' \ + '--exec-path=[path to where your core git programs are installed]: :_directories' \ + '(- :)--exec-path[print the path where your core git programs are installed]' \ + '(- :)--html-path[print the path where git''s HTML documentation is installed]' \ + '(- :)--info-path[print the path where the Info files are installed]' \ + '(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \ '--work-tree=[set the path to the working tree]: :_directories' \ '--namespace=[set the git namespace]:' \ '--no-replace-objects[do not use replacement refs to replace git objects]' \ diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index 7283af3342..d0795ee014 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -802,7 +802,7 @@ test_expect_success 'general options' ' test_completion "git --no-r" "--no-replace-objects" ' -test_expect_failure 'general options plus command' ' +test_expect_success 'general options plus command' ' test_completion "git --version check" "" && test_completion "git --paginate check" "checkout" && test_completion "git --git-dir=foo check" "checkout" && From patchwork Tue Aug 30 09:31:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4304ECAAD4 for ; Tue, 30 Aug 2022 09:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231816AbiH3JeC (ORCPT ); Tue, 30 Aug 2022 05:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbiH3Jcs (ORCPT ); Tue, 30 Aug 2022 05:32:48 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 401F5E0974 for ; Tue, 30 Aug 2022 02:32:29 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-11f4e634072so1124368fac.13 for ; Tue, 30 Aug 2022 02:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=AYTAj8pNRPhv1uZS4iNq67j+h5ZYkolLi9KqWbVN8E0=; b=WBvsvLuchrWLZx5o0c5hNSbyi2zSidcsAky5FdS8qAaUq/VQf2gm6TUy5z/Gk02kMI mqIvZyfI/WRtlEnt9pxk4kunr/G16+pbD6eUfJA64PwEDkhT2kMA4AWBJWUMIV9aLqVh ppMJ7cCTMlcX1z43E0zzRqw/dGu6rlkCcFIXWmPqTtXRzMv0ju8K2ZlNYbCDlvL2H4K0 RXXkDEvF9pP/+vwzMc/dLs2Pr3lMWaA4VGbqzu1VPM6i+ldXUR6wXtcHZRVbPz153elv pe+MIgdlFSczLRnksy3cBad7S/ErZzyRlxFNI2cKAtUBboO1XLNZZg3twA8vq33MS+LM /p4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=AYTAj8pNRPhv1uZS4iNq67j+h5ZYkolLi9KqWbVN8E0=; b=0sf8+Q4aVPxEbn7YrHDqcMCKPWXAQPzC4L0dT8Kscv96Wt4WNey0Na12jqVg0uq6/z NODEnJfBeaosagJWEM5LyJVrpcsyhLsUQ4X+x7YvBg5JBKU1cCAVjC081h68/W2mwjPz Y0ZuK30kWzS8uO734czir+UIPgaetDu/ItyqxJVu/80jinzo3k44TDbfAS472Vyl5Kua gGIjHJqz+n3l59XPYCElTDVC93pf6Eg/AV/8/nSKyIL4HaYG6OSSlQlXTSOdOtd0JLGr uzGTpO5tvoLeHxfkKUBu6qzwjl8nqKbvgonblbL926xIbWbupF6olMhSYngBbmsFY4lc Kjcw== X-Gm-Message-State: ACgBeo3dpt0REjbf/CgUSk1ijJjw6WT25B9ecNHBY2uy8SrG6XcABVPw NLJwC2hEeU/+28aPi7qgR97YjuTQsCI= X-Google-Smtp-Source: AA6agR6EXza8UkxLN4zgv1kEF/udETt8B8Rz0tKucOMhquAVJR3BJd1Xg8E4LsovrTykeY+ybd8tjg== X-Received: by 2002:a05:6870:8890:b0:101:db34:3ed6 with SMTP id m16-20020a056870889000b00101db343ed6mr10196912oam.151.1661851944466; Tue, 30 Aug 2022 02:32:24 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id e6-20020a9d7306000000b006393ea22c1csm6886888otk.16.2022.08.30.02.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:23 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 26/51] completion: zsh: always set compset Date: Tue, 30 Aug 2022 04:31:13 -0500 Message-Id: <20220830093138.1581538-27-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org So we don't have to set it every time. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index d2eb221d79..41272b00e3 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -73,7 +73,6 @@ __gitcomp () esac array+=("$c") done - compset -P '*[=:]' compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 ;; *) @@ -92,7 +91,6 @@ __gitcomp () esac array+=("$c") done - compset -P '*[=:]' compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 ;; esac @@ -102,7 +100,6 @@ __gitcomp_direct () { emulate -L zsh - compset -P '*[=:]' compadd -Q -S '' -- ${(f)1} && _ret=0 } @@ -110,7 +107,6 @@ __gitcomp_nl () { emulate -L zsh - compset -P '*[=:]' compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 } @@ -118,7 +114,6 @@ __gitcomp_file () { emulate -L zsh - compset -P '*[=:]' compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } @@ -136,6 +131,8 @@ __git_complete_command () { emulate -L zsh + compset -P '*[=:]' + local command="$1" local completion_func="_git_${command//-/_}" if (( $+functions[$completion_func] )); then From patchwork Tue Aug 30 09:31:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1FA0C0502C for ; Tue, 30 Aug 2022 09:34:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbiH3JeB (ORCPT ); Tue, 30 Aug 2022 05:34:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbiH3Jct (ORCPT ); Tue, 30 Aug 2022 05:32:49 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 825F7DEA5A for ; Tue, 30 Aug 2022 02:32:31 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-11ee4649dfcso8939688fac.1 for ; Tue, 30 Aug 2022 02:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=xOOQy0bHkm0uCW1U9teSHCZpjTZp+M+JSRfr2K08IMw=; b=eftkLHklRCQqte16NOvfGjGXYhwHx5Bo3P4v82q0YhgDUJnctgR4E+kkBNPgJC+SMp uVcVPITXoucDnt3yozt4sRvTKK9k49LzFAAL5oaItxMJWbbo7npRXv/vUqS77fhXHUnI dxyaDSZZ4ojoFMRg97n8U0FVphTbDZ1cZ+U8RpQY+GDdTqEyhnShyepTp4zzCMNwE9og S/OwGBYF3EfibCExkkVpoOUgpH0R8jnjHwgOGvQMZfjc97VOrO2aG1nAXKrearwdq4nc etDo1V2hRSyq4YEQL0wV/jf38NjWecNgLHLq90DdAVHr2CQtG2KZoXt1XPkLzNbjM8tO xeGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=xOOQy0bHkm0uCW1U9teSHCZpjTZp+M+JSRfr2K08IMw=; b=qjvglKwq6ig31bXA5S4TzjmpfhUaNmTk7aQsRxUolDNuOUdJqcTKceBM1ncQM6Yss0 bOrg03m95QlO6s2wfeoYjy9ow6ndNtUyz9qHTovGI0E1hBNB7saCGK+O0EnbYBeXZ16q zPJewZsmulNbikTLhFiztVKyZ84RcKlSTEwDtrhd+aBFVOeMwXGfU5/tkvgsvsGqgdRd b2SICS7vkHQ6p2FUiO4hWhsfiJ0wAe7gbZItMCsLSwOzqFWAFlNLn8AIxL3J8WAxLxcH lISYnr2JON4A2yfGoTqtMEkAFSk03ctHWnlcZXmuIvgWq38XSlUifLzF/k/8LqwWnSZA L0NA== X-Gm-Message-State: ACgBeo1LbUWXg0D3awTZzPyB1LoNzxjq5mV9LKD5DoIv2le3Tf/KgOd6 lb63MEB37rYP+yzCpxvrHvS8WVqThXQ= X-Google-Smtp-Source: AA6agR6y6/Wh6zDshVIoztHwUIY5YaPk42hR6lHf+fdG4eDU7y8dM345GLyLRVOnwnWcCFxqZIsrUg== X-Received: by 2002:a05:6870:89a1:b0:10e:4357:45b3 with SMTP id f33-20020a05687089a100b0010e435745b3mr9437782oaq.127.1661851945945; Tue, 30 Aug 2022 02:32:25 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id c38-20020a9d27a9000000b0061c80e20c7dsm6911003otb.81.2022.08.30.02.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:25 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 27/51] completion: factor out check in __gitcomp Date: Tue, 30 Aug 2022 04:31:14 -0500 Message-Id: <20220830093138.1581538-28-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This way we can reorganize the rest of the function. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 6 ++++-- contrib/completion/git-completion.zsh | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index ed126bbec4..86c335cfce 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -335,9 +335,11 @@ __gitcomp () { local cur_="${3-$cur}" + if [[ "$cur_" == *= ]]; then + return + fi + case "$cur_" in - *=) - ;; --no-*) local c i=0 IFS=$' \t\n' for c in $1; do diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 41272b00e3..808cf87f84 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -56,9 +56,9 @@ __gitcomp () local cur_="${3-$cur}" + [[ "$cur_" == *= ]] && return + case "$cur_" in - *=) - ;; --no-*) local c IFS=$' \t\n' local -a array From patchwork Tue Aug 30 09:31:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D399ECAAD4 for ; Tue, 30 Aug 2022 09:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231807AbiH3Jdd (ORCPT ); Tue, 30 Aug 2022 05:33:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231550AbiH3Jch (ORCPT ); Tue, 30 Aug 2022 05:32:37 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4807E9F768 for ; Tue, 30 Aug 2022 02:32:28 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11f11d932a8so6968929fac.3 for ; Tue, 30 Aug 2022 02:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=E16kH/87tdgBU8pb58q+jzlJaHKzU5A9XRzYyEfic90=; b=ac367KDHby3tRahcOsy0JRv+HloG9+e6QZKe5TJ+MxdYxUIV/BdaUQf8xWG0S5LTvK SmTzwO2uce0WMlvXdbBL+EsEY/qsaegLx3wxnUjPbc8/7LXoN8r+9sTUzfKY9FWoPrdc E3GdoSbUktUACgFRl7RCrCEekO8MRZCA4Yqv2mc/Lc7w6s9cLf23BewEIaTbldUtDQB+ Xpx0/qZZfHFEqeHpiyxdMAlENxxjLkKH68BbjIr1oOTmU7FeVkSvVwxX0oIdSUiMH/wA xsT/kyL1B2FFD0g1y3QDIb76t4eQBwrJJ3xRn1Q987uMZANh+sj4DfMuUrAYNxfu4/Ew civg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=E16kH/87tdgBU8pb58q+jzlJaHKzU5A9XRzYyEfic90=; b=uyYSjmQclHXI5f74dRhOj3pCwrVp3bMP5eHpPOUWKz23+anaw6GMzjb7lW9m/LF075 iSB9VZPNx1J7vxsWMctf7Ard/0aXD+hFGrbLp4QqJYGVmjBkw8E38s/pqQH5peBT8SDX +Be/vMKK9SDMWC55rK6/qZA+J/woJI0u4KQ5yfV6oytEUlDLBkjiVww8iDv8QXh0Pgnl qAJNIfX7gvKG3KFLXDfkKeSrj5QaNU6iDOryR41SzrG4mbPD1h3xpebZN/H+tl+ndyO/ mrNnTMuEhaEg5CfC1WZjxMthwe1Go8I5rYdFFDJ3O7gEqmRxbD2qUDoOZLmGY45DT3Ke kzdw== X-Gm-Message-State: ACgBeo2el2LV8ifJI8JOSsie7WYtBUHJ/+3YPkzYpCuYCemjyqwukPT+ uJcpJqI7XMTcvaPUrBIWVkeCgCgES6c= X-Google-Smtp-Source: AA6agR60RNv0/I1cw4P8E7zEb8aHaly+5w0CvvPzFgJlgMVCkFg8VmVkh05R7c+lRfdJhXcYI1eBVA== X-Received: by 2002:a05:6808:1381:b0:344:d4b5:9a30 with SMTP id c1-20020a056808138100b00344d4b59a30mr8919005oiw.223.1661851947453; Tue, 30 Aug 2022 02:32:27 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id k23-20020a9d7dd7000000b00636d6571ff7sm7019231otn.70.2022.08.30.02.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:26 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 28/51] completion: simplify equal suffix check Date: Tue, 30 Aug 2022 04:31:15 -0500 Message-Id: <20220830093138.1581538-29-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We know the prefix is already '--no-', there's no need to check for the first '--'. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 2 +- contrib/completion/git-completion.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 86c335cfce..2a5e32e457 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -349,7 +349,7 @@ __gitcomp () c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 808cf87f84..a8ff9c089a 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -68,7 +68,7 @@ __gitcomp () fi c="$c${4-}" case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac array+=("$c") From patchwork Tue Aug 30 09:31:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66728ECAAA1 for ; Tue, 30 Aug 2022 09:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbiH3JeE (ORCPT ); Tue, 30 Aug 2022 05:34:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbiH3Jcx (ORCPT ); Tue, 30 Aug 2022 05:32:53 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C869CE0FC8 for ; Tue, 30 Aug 2022 02:32:32 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-11ee4649dfcso8939948fac.1 for ; Tue, 30 Aug 2022 02:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=c1wJDXoelCxDFmK2xhU6H5bL2Z4njTSgXtQ9jmesGwo=; b=WYs0viWY/6+jt6ZUAictWUxZs7Wo5iDxzWEiBXMtsc1AHjs7SIluj1VKpqh2NqST2A 37zedxonsLJ+W72QqfsqPvUuMhSlJTqo9iyaCGIv49AeZwhIgwtMYOn57qqvF+47gk3B w1OCbXkX+XOJfYskCqTED8NDc+yFgIW4ygp4TA3V249A7U6A5WUKBcpKME4CLS3W1Emh SN5LhHEPpCCHCH+AMbK+HhxDNg5X/1KU/JbQGiBWYfQ/BAjoE4AF+k4B29su/P7lltSh KfutaN8Ar1gYsogEUGwIHGMznLWfLdplN8AfbArFYrlwh2jS2A7mAK0nv1KGP3b2loq7 E7og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=c1wJDXoelCxDFmK2xhU6H5bL2Z4njTSgXtQ9jmesGwo=; b=uylVc4uOqDUXC9fV4qKtaR8Fc2t4m1rM5CKibrVK8cnUDrSv4eu2kKxrXYiTuirqXD PWyi09iIyP91UOLpOM2ymU619W0WbemapEccspz3sogRl6jHGySg82FZeE0T4c7CVg/I xTq0zmWr0659cMomtVeoaRIYmJQWN+g4PS+W8CURQgDaijeLyuuiGgt9zNYyu8MAdOwA aaJbldn8x9JpWFqmBzcF+lWYzc0CL2LWEhdOpoqIKar3EYu5dN5fifGCHxfLRcJ1O9Rn 5StV6w/1gaXMByH8krVlMGUjN1BfdCey3jySCMuvQZDRM8xWkl7AILZOlG2O1pYux59m Y6Mg== X-Gm-Message-State: ACgBeo1/SqLq3b/d3gtfbbN3layle4orpdK39x6Ev7BPG+6RXhocgvcO yEndOdGgvKvi9pKi/yTPTFoM2DFTmTs= X-Google-Smtp-Source: AA6agR4uIAB+T7sMXFZTJxKfJhnXple9hjh0AJ/S7rikNzpLRZiLyUrYwO4fgfxCiIjCgYTrGkueuw== X-Received: by 2002:a05:6870:fb90:b0:11d:23bd:9266 with SMTP id kv16-20020a056870fb9000b0011d23bd9266mr9960633oab.177.1661851949780; Tue, 30 Aug 2022 02:32:29 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id r8-20020a056830236800b0063922f00ee2sm7101366oth.39.2022.08.30.02.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:28 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 29/51] completion: refactor __gitcomp Date: Tue, 30 Aug 2022 04:31:16 -0500 Message-Id: <20220830093138.1581538-30-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We have two chunks of code doing exactly the same, there's no need for that. No functional changes. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 52 +++++++++----------------- contrib/completion/git-completion.zsh | 52 ++++++++------------------ 2 files changed, 34 insertions(+), 70 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 2a5e32e457..54b2c4e589 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -339,44 +339,28 @@ __gitcomp () return fi - case "$cur_" in - --no-*) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then + local c i=0 IFS=$' \t\n' + for c in $1; do + if [[ $c == "--" ]]; then + if [[ "$cur_" == --no-* ]]; then continue fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; - *) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - if [[ $c == "$cur_"* ]]; then - COMPREPLY[i++]="${2-}$c " - fi - break - fi - c="$c${4-}" + + c="--no-...${4-}" if [[ $c == "$cur_"* ]]; then - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" + COMPREPLY[i++]="${2-}$c " fi - done - ;; - esac + break + fi + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + *=|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done } # Clear the variables caching builtins' options when (re-)sourcing diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index a8ff9c089a..7616f87fa2 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -58,42 +58,22 @@ __gitcomp () [[ "$cur_" == *= ]] && return - case "$cur_" in - --no-*) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - if [[ $c == "--" ]]; then - continue - fi - c="$c${4-}" - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") - done - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - *) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - array+=("$c ") - break - fi - c="$c${4-}" - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") - done - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - esac + local c IFS=$' \t\n' + local -a array + for c in ${=1}; do + if [[ $c == "--" ]]; then + [[ "$cur_" == --no-* ]] && continue + array+=("--no-...${4-} ") + break + fi + c="$c${4-}" + case $c in + *=|*.) ;; + *) c="$c " ;; + esac + array+=("$c") + done + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 } __gitcomp_direct () From patchwork Tue Aug 30 09:31:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958984 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C6E0ECAAD4 for ; Tue, 30 Aug 2022 09:33:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbiH3Jdw (ORCPT ); Tue, 30 Aug 2022 05:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbiH3Jcu (ORCPT ); Tue, 30 Aug 2022 05:32:50 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1226FA925E for ; Tue, 30 Aug 2022 02:32:31 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11edd61a9edso9323404fac.5 for ; Tue, 30 Aug 2022 02:32:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=GfeEVP6EZqBYQmVSPhhlu6DeEjAa/HvoKDOCbz7UDOk=; b=ksRmT2RRzAe5OMZb9dfgFCWkFkp6ceqWy7fah0I/Vq0W4S7QCWfhMXCF6imLxzjjv+ KZnC8buCOiafZOpnf6M8O/i5pdU5oVWNaxPQ68VZMTDJdXogaZBACPNPvnm/L5Txawcv ZYMfIh1TpP0FhZMhEmvOxO/0sCON+e4r8RpcstcsDW51R+8xaCte4EXxA/6WmuU96pE6 mtDFk5xDGFi7/Aarvi5fA+OCax59ipgaB0IUpO/mJN3xk0of+8kfdkctDe+jo3lwc3KR jsy6oKIhx0xzQT6kS9phMwNXh3sSH6amEI4MZlYEO1CNnrolQ4HDIA6ivjhCNTdSGGEy mJFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=GfeEVP6EZqBYQmVSPhhlu6DeEjAa/HvoKDOCbz7UDOk=; b=u0ILd3hIk8pbWLf/IqhvrZp+5kPrJuWR1bXrTAvskr6GmvssVtsrJ04f3+hF7NCOQK uUPuqd2mhTEYiQQSB1xlXLlvmJxHFAlYItLJa2LrA2M+Wlv4GNMvwknNQ02wZmis7SLy xkHjK/oYoy3nHzM8MecIXvutkU040Hp4f3jpK3uEYpJN1sjVNTH6yTA1Fo71wELFhb4u nd8iQKg1N1nQieSAimn4iF6mQFq9+LCzQElmhh6S0mCd/JnI0goRae1RCvr8sQpWA2eJ lSbmKLmAnFhOlGu2X5GNIej0x0DvRfbdIReu9wpTAPkBMCsBdkueO+BShkR+k4Ir4y0g QBHw== X-Gm-Message-State: ACgBeo2TEt0TCwyCCatAULjb8Z6y4s9GpfckjzN4Rta59iCFh3YlxZk/ /0MTVrrSf6zB4PEnjkuAP+MZoFBSR0Y= X-Google-Smtp-Source: AA6agR5qQUKOi5W+a6x5sItqvGBR03eRERZIa8gJ1WZ8JSwcaNtEKYTiM1dRdmlpfQEJeaI6JDZfuw== X-Received: by 2002:a05:6808:1486:b0:344:dc19:d7de with SMTP id e6-20020a056808148600b00344dc19d7demr8854259oiw.238.1661851951321; Tue, 30 Aug 2022 02:32:31 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id x11-20020a056830114b00b00636d0984f5asm6943048otq.11.2022.08.30.02.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:30 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 30/51] completion: simplify __gitcomp Date: Tue, 30 Aug 2022 04:31:17 -0500 Message-Id: <20220830093138.1581538-31-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's not possible for $cur_ to have anything more than --no- at this point, so there's no need to add a suffix, nor check anything else. All we are doing is checking that $cur_ matches --no, and adding a completion if so. This way the code reflects what we are doing. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 5 ++--- contrib/completion/git-completion.zsh | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 54b2c4e589..c9315d4f9a 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -346,9 +346,8 @@ __gitcomp () continue fi - c="--no-...${4-}" - if [[ $c == "$cur_"* ]]; then - COMPREPLY[i++]="${2-}$c " + if [[ --no == "$cur_"* ]]; then + COMPREPLY[i++]="--no-... " fi break fi diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 7616f87fa2..d5f4270ee5 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -63,7 +63,7 @@ __gitcomp () for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - array+=("--no-...${4-} ") + array+=("--no-... ") break fi c="$c${4-}" From patchwork Tue Aug 30 09:31:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E031AECAAD4 for ; Tue, 30 Aug 2022 09:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230418AbiH3JeF (ORCPT ); Tue, 30 Aug 2022 05:34:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231941AbiH3Jcu (ORCPT ); Tue, 30 Aug 2022 05:32:50 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA47DE0FD1 for ; Tue, 30 Aug 2022 02:32:33 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-11dca1c9c01so15400871fac.2 for ; Tue, 30 Aug 2022 02:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=wi+XzLVgE6DRx/VrNp27C5yxPWOfQ4ztVhHFdeluvI0=; b=TuQ99KbfEK/+FsOD7SRUmnsWd7ZkL1aaHCQKHj0A/q98HeuEyxa3fmyaRBeSiBM8aC KjRjJYsAtL6+vKbGzFIqpnGf0MQP2jJQCzAPsIpK6a9cLU7ozyx20MvmDqhGMCXyEInJ uOoC8+oaEOiXmJf5XP4RDa5jrcET6h68RnU7uEsP6WP53GwvPUBOso41vjnQ6tGXJ5A5 zgDTb/3EVUByd90U8XGjkGwnOaHmUKig+jAq7PtxI3WEf8G+4JqCkqhNv2vuC8RCiOmn XBLrM3fFtBaQeegZIkJo0+s0i74INXkg7CEc89hjcth7crEcv8QjWnGshOmfiehoS4eA tecA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=wi+XzLVgE6DRx/VrNp27C5yxPWOfQ4ztVhHFdeluvI0=; b=t8EwEt8wk8vIJDDjHmIVAztKD8TfMSyEunZ7hRBg2w5nInhnrc52eoPirzk53HwqBO vEXYP1vjv6muQ8lzMiOGD7YYRzTdbUfMdT5Ta58+7M/9xIwJqIh4kYSLcKqeGswfVWvM aXqlDxYHSoFGbXCjAC8bxUM9LeyJkn7F05pVhLAl6Zsx7Gywm+S30tNoET9OrFcbPfJa ZaTg6elp3Tzr4ZtOQLvQMIlz2b6n8WP08T5R5WBFvODl4FVpH6gZBF//0uLnnZ29UQkw dLF7yqOaa0e9H1+mi2RT9HAr6BXsEMw4UkQZQf0PnCthxAMuCYdMDN3wFotbeFPd1OJ0 toQA== X-Gm-Message-State: ACgBeo3zuFV6DJrOPYID07W81oIXB5rk15QtZa0VJ/xfiul6BiOeXFWd YoCKjagKJ3Bv9GDTxXIwdpjpfw7yiZA= X-Google-Smtp-Source: AA6agR6MB32q7mIF3RrZiFdD3ZdbGeaBijDEr8DLXD91jYiur7mo6kgUMKAwL8TK3hU9qRar6XBqLA== X-Received: by 2002:aca:b6c2:0:b0:343:5897:a366 with SMTP id g185-20020acab6c2000000b003435897a366mr9061858oif.184.1661851953042; Tue, 30 Aug 2022 02:32:33 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id c20-20020a4a8f94000000b0044528e04cdasm6531997ooj.23.2022.08.30.02.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:32 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 31/51] completion: bash: change suffix check in __gitcomp Date: Tue, 30 Aug 2022 04:31:18 -0500 Message-Id: <20220830093138.1581538-32-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We don't match the prefix, we shouldn't match the suffix either. There are no functional changes since all the callers that add a suffix add an =, and if $cur_ ended with that suffix, we would return immediately. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index c9315d4f9a..2ff7de1274 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -351,8 +351,8 @@ __gitcomp () fi break fi - c="$c${4-}" if [[ $c == "$cur_"* ]]; then + c="$c${4-}" case $c in *=|*.) ;; *) c="$c " ;; From patchwork Tue Aug 30 09:31:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E6D3C0502C for ; Tue, 30 Aug 2022 09:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230472AbiH3Jdy (ORCPT ); Tue, 30 Aug 2022 05:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231902AbiH3Jcx (ORCPT ); Tue, 30 Aug 2022 05:32:53 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF33E0FF7 for ; Tue, 30 Aug 2022 02:32:35 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11dca1c9c01so15401030fac.2 for ; Tue, 30 Aug 2022 02:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=JCh1ivWBDv+L39NAu03mlj3UkKBLCyhrCVizbIhoLbs=; b=qzoiTv4pzX3n9T0buxFg9DEZPeqJoPlAf15QPZIl4qtbpp3pODOadZHfZOrR7stbg5 FYr1AUz+PKhQHiSRWcbfqad2nLsFepnAmqcA2rOI3vYIrH/nCuIj9j2crLokG+DNOte/ USHihQoye2EN20u5fhIvOyX9M/NxT8EiEBzRbCn4kpACk1+MNvFCcokXZPsP++3oB+bu bceWkVsZ8c2uMtOXe7vXHqisl+H5O/F6NetEZTrYJwHzIeYNMisyN14nrJk7/4DKhHmg vzF3wUprfYlRpsJ7AVMhaBwI6cOXN5sjlnnyyQt5ZjScxYL+sQAavhe9bZ9Vq7TeLAlr ZAtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=JCh1ivWBDv+L39NAu03mlj3UkKBLCyhrCVizbIhoLbs=; b=eLgKXlkj5QP/klx3ebG7Gf+EXgjTUhoqqmnYX0KK47cn5jKxOudf0m/x9ijMVi/0Pd se8bfkewP83hRUg9DzpEEDUuimnveFM0mCaZyNiaykcS2CE75RQeukAfUCIjB+uGvJCy qPCfUpxWki3TEN2CSdk8KceZvc3YgIf/48cs/t+Z27Hq+6CerrZdVNiVUEOInAAZ8aRL HNH+rv0Gzq+h3bCPyUP2tXmTistj9S9r4VRYHmvOubs72xOr81zuYSBWEWUfLWfa0nZO tmnueVb0HIBzF1m810D75rVgQkqyaTWIh3+BtSEid1BI7UhHrEchzFNGBtpwXqjnQyts bIdw== X-Gm-Message-State: ACgBeo3WaO/gkI45Rttfj1fmdPFTSC/AondgyRE8bGWrVBgwEFH4At4h b3Tm5e+BtbklCx04YCFKRok7hmY0WZo= X-Google-Smtp-Source: AA6agR52PgFMuRoL4l+kMoSI+8wfy3BnIrUCkKnGNW1ZYAAqFNLLKWIJOMJ9NS/GTLU1DHsq209EYg== X-Received: by 2002:a05:6870:b021:b0:11f:479d:fe28 with SMTP id y33-20020a056870b02100b0011f479dfe28mr622452oae.23.1661851954922; Tue, 30 Aug 2022 02:32:34 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id m6-20020a9d7ac6000000b00638a1c49383sm7000519otn.78.2022.08.30.02.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:34 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 32/51] completion: improve __gitcomp suffix code Date: Tue, 30 Aug 2022 04:31:19 -0500 Message-Id: <20220830093138.1581538-33-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no point in adding a suffix after a suffix. If a suffix is provided: we add it, if not: then the default heuristic is used. There's no functional change since most callers don't specify a suffix, and the ones that do, use an =, which by default doesn't add an additional suffix. The only exception is __git_complete_config_variable_name, so make sure we pass the correct suffix. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 19 +++++++++++-------- contrib/completion/git-completion.zsh | 18 +++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 2ff7de1274..d43ec03c12 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -339,7 +339,7 @@ __gitcomp () return fi - local c i=0 IFS=$' \t\n' + local c i=0 IFS=$' \t\n' sfx for c in $1; do if [[ $c == "--" ]]; then if [[ "$cur_" == --no-* ]]; then @@ -352,12 +352,15 @@ __gitcomp () break fi if [[ $c == "$cur_"* ]]; then - c="$c${4-}" - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" + if [[ -z "${4+set}" ]]; then + case $c in + *=|*.) sfx="" ;; + *) sfx=" " ;; + esac + else + sfx="$4" + fi + COMPREPLY[i++]="${2-}$c$sfx" fi done } @@ -2586,7 +2589,7 @@ __git_complete_config_variable_value () # subsections) instead of the default space. __git_complete_config_variable_name () { - local cur_="$cur" sfx + local cur_="$cur" sfx=" " while test $# != 0; do case "$1" in diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index d5f4270ee5..41aae0f454 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -58,7 +58,7 @@ __gitcomp () [[ "$cur_" == *= ]] && return - local c IFS=$' \t\n' + local c IFS=$' \t\n' sfx local -a array for c in ${=1}; do if [[ $c == "--" ]]; then @@ -66,12 +66,16 @@ __gitcomp () array+=("--no-... ") break fi - c="$c${4-}" - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") + + if [[ -z "${4+set}" ]]; then + case $c in + *=|*.) sfx="" ;; + *) sfx=" " ;; + esac + else + sfx="$4" + fi + array+=("$c$sfx") done compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 } From patchwork Tue Aug 30 09:31:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4251BECAAD4 for ; Tue, 30 Aug 2022 09:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231166AbiH3Jd4 (ORCPT ); Tue, 30 Aug 2022 05:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231901AbiH3Jcw (ORCPT ); Tue, 30 Aug 2022 05:32:52 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C83FDCFF9 for ; Tue, 30 Aug 2022 02:32:36 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11eb44f520dso11116228fac.10 for ; Tue, 30 Aug 2022 02:32:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=LqSQCnVeE2gvRPhlpaUtKCEbH9Zrzc3pPAdhPF+hAvI=; b=brNFrzrvM5B2T71Hc9LAUpTQWVUxtQppVdcOdLcaxw9Mqe5ACK0tb+IeCPvRi8fFfi JcvADGd9yywjiZk0DyMriRd9TWz3LWApzO+Qw5k6CUAqqT/AvVy+aD34qb6evQ7Em31U a2YWXicAPcV2LPmL5kH+EwjM5p/uxD4iJgIwHE6FjLcRl7WIanm0AafYOG6WmHl6+e8H AYF7vaSvJMdfrwZqNQs9svLog8reyDeFH48tUfwdtiVaPTD5SEOnIlvzT073rf1Z69bE jC/+zQ9svqUeN1A2/mfAlbvNDoTu/z7a44fDYuVG33lUN4QUqm+jgeaNI/D6DKAVT2o9 KHTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=LqSQCnVeE2gvRPhlpaUtKCEbH9Zrzc3pPAdhPF+hAvI=; b=DrFqA+Fo5uynq1B7RvDsd3d3420xk7L0Hb1hKXmRfnJ+9FIITd70jbLuYzjg7iyM2M cAbWAOv1tYtDjNM+EDdW6axHRGjORaAIR0yoW6uVwC1sjB5bhZGK30UPAiTyIY3YQZLu /K4KcNrIkMh1t/AgH7Y+lcFJrKW9BtHBZokc20AbxSx6Fu8yLxEddt8yU1AUGzMihzkK 1kSvmKcBtRpqIXfLdSoETBFSKSK5pBlN3p4SYaPW3jAwAyrgeGZwRf5ciw+mDUmJVeaJ DxjNT0rKnYtJ6TpIIFPKsTDmVJdbOFP1vgediePYxLWLntFN/z1S2/RM5YHzmIYlinqj U2JQ== X-Gm-Message-State: ACgBeo0lvPujIcaoTvOJL5Oocr1XAOidUqCVNQ28fTK0xZUK11xVB/2w zvuBY7xgnfQqt8NOHnX+GFGhsjhOrCA= X-Google-Smtp-Source: AA6agR7QCz8CEqMA12qlhYTt3VEXntovg1ojfTZa1MXR/04cBAsjIl/S7CfR0QbSApV3xRnbMlrYSw== X-Received: by 2002:a05:6870:d7a5:b0:11d:a0b:f62b with SMTP id bd37-20020a056870d7a500b0011d0a0bf62bmr9245115oab.190.1661851956516; Tue, 30 Aug 2022 02:32:36 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id h7-20020a4abb87000000b00435a8024bc1sm6401965oop.4.2022.08.30.02.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:35 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 33/51] test: completion: add missing test Date: Tue, 30 Aug 2022 04:31:20 -0500 Message-Id: <20220830093138.1581538-34-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Once the correct suffix in __git_complete_config_variable_name() is set, we can add the test again. Now it should work even in bash < 4.0. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 7 +++++++ t/t9904-zsh-completion.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 91dfb618c1..e1e9c6e365 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2503,6 +2503,13 @@ test_expect_success 'git config - value' ' EOF ' +test_expect_success 'git config - direct completions' ' + test_completion "git config branch.autoSetup" <<-\EOF + branch.autoSetupMerge Z + branch.autoSetupRebase Z + EOF +' + test_expect_success 'git -c - section' ' test_completion "git -c br" <<-\EOF branch.Z diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index d0795ee014..42917833e8 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -1071,6 +1071,13 @@ test_expect_success 'git config - value' ' EOF ' +test_expect_success 'git config - direct completions' ' + test_completion "git config branch.autoSetup" <<-\EOF + branch.autoSetupMerge Z + branch.autoSetupRebase Z + EOF +' + test_expect_success 'git -c - section' ' test_completion "git -c br" <<-\EOF branch.Z From patchwork Tue Aug 30 09:31:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34663ECAAA1 for ; Tue, 30 Aug 2022 09:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231492AbiH3JeL (ORCPT ); Tue, 30 Aug 2022 05:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231395AbiH3JdI (ORCPT ); Tue, 30 Aug 2022 05:33:08 -0400 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6226E193F for ; Tue, 30 Aug 2022 02:32:40 -0700 (PDT) Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-11e9a7135easo12874152fac.6 for ; Tue, 30 Aug 2022 02:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Xs7RKtRo2OpXdWWIGm4+Iq5x9rk9iFK6sJU7xTXkLtU=; b=SDmghbX0ZUcLPWzbKnlK54jp/eWE1jFjr2NDLSCCjdtIR/ICs2DX1nz8kgO/WlFWf5 08EHA6iMRJREjeGzuu74szNt7tCBs/lB6eOUMN0z5IU6UwGfor070hJw2DMLHgh66PEy wlXoX3vPj4qh02WItjfqVD28Oh9/HhiMIdz9YvnajSwlTm8PQgy6eVbieJNpOGPIq5RF 7w7hkosukouDXoSlUBLI2jPt8aZaMmchDJgvQT+zOplS6umBi2FiPbwRiG2uSiQyB5tG TVge5AkUWIgPbOehJ9rN4l4hiSFrO8DyKE5kKPAeJqnq+881WJdD3tnHtJIvjx1L38gl NSjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Xs7RKtRo2OpXdWWIGm4+Iq5x9rk9iFK6sJU7xTXkLtU=; b=uS588woBsON401Ew9fWjuBmVLPdKUpIdFqQB79pI8cQA7gJv7iWV9kIp3yVeZvdcMB I83n4Pjjq9y0Y9p3P/pP4TkVUVLfmzQbQYOVtdrTPbss+f50OODWmrnrlH4VBcb4f382 REOVNKbyVwOvMyTMTAg4Qez/FEuR4G3068T2ltz7lJf479bFYmLrpqadKSnMBrpSmbzl jG3h9d6rR6v/r+Gqmy3TDj6QX2ToSb5zwCI0FqOW5llSCnnKfpcXqYFhYBAd3szI4Xf5 PFVBB93kOojsxKYZh+TtoX1YjRLq/OJfAnC41LFlTo8ZoshmOqtyI1RZi3QpaLNTerKC LVWA== X-Gm-Message-State: ACgBeo0Xzexn0f5Ge1Smb32hH9eSQ9TWV03J9aicjouinLgOXLMgPvBZ M1wABI6Z1TbkTVXUrvZRQH25QhO+QPQ= X-Google-Smtp-Source: AA6agR6N6fQo04Y9fk7eP9Nl1Zk/C1KzRQPQQgkBo+Q0mnMFQnWrRMunW2KlJGk6zMwlyYIrOtGeyA== X-Received: by 2002:a05:6870:310:b0:f1:f473:a53f with SMTP id m16-20020a056870031000b000f1f473a53fmr9679318oaf.34.1661851958666; Tue, 30 Aug 2022 02:32:38 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id x11-20020a056830114b00b00636d0984f5asm6943133otq.11.2022.08.30.02.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:37 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 34/51] completion: bash: simplify config_variable_name Date: Tue, 30 Aug 2022 04:31:21 -0500 Message-Id: <20220830093138.1581538-35-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now sfx is never null. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index d43ec03c12..9e15538f53 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2611,7 +2611,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" - __gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx" return ;; guitool.*.*) @@ -2645,7 +2645,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __git_compute_all_commands - __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "$sfx" return ;; remote.*.*) @@ -2661,7 +2661,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." - __gitcomp_nl "pushDefault" "$pfx" "$cur_" "${sfx- }" + __gitcomp_nl "pushDefault" "$pfx" "$cur_" "$sfx" return ;; url.*.*) From patchwork Tue Aug 30 09:31:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83543ECAAA1 for ; Tue, 30 Aug 2022 09:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231879AbiH3JeO (ORCPT ); Tue, 30 Aug 2022 05:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbiH3JdV (ORCPT ); Tue, 30 Aug 2022 05:33:21 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91C4DE1AA1 for ; Tue, 30 Aug 2022 02:32:42 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id h20-20020a056830165400b00638ac7ddba5so7668972otr.4 for ; Tue, 30 Aug 2022 02:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=En/qzvd2MWFQVk4Ig8VWybp1FCNQVM/mH8JkN+VK72o=; b=bG433KIx+FyrYZamBkPTPwGFeb+9ap+U2SmXgVrLMMQw5T6aGQrEX+9rjuxVW5Q+/q pKWyN2lb4tscNu8zSFqfBLQ3QLs01iKOjfCFPxICbCtTamOjNSWkG5SFvMMiVP+S+cou 9yBrZU7BIDAnoPAIWegu+FzxFXay9et9i3DRFT080jmE36VkJ5QB9uxZAMW+sGSN1htD Mw+lDLAtwsFdco5oHMpHsAa0RjXctV4S1DWT7MTgvoTB45U051552DfVwXZsyf7kroZ8 CORPFJC+CzZn2cZLZJwA/E228ulmSvjicjFyciXOiq/qzPjJlfrn4ZGqwuZPw7C/jsRR cuxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=En/qzvd2MWFQVk4Ig8VWybp1FCNQVM/mH8JkN+VK72o=; b=ve6G0xVdGxm2yi6Kpd08a/ZFbB1oCkIEECyCz/a3stRFOzw0mn9QQQDr4hyeXSBBsV zHzukN22EsN3sTTDXgOql2bGnotmUFNlQAi4kcbZv7QdTWO7+o19wxv2fOuQ5vF89Rol ky+BYDyjlyAItg9j2YVEK/8JVQRvaOwOqCIfffCFyh59fKU4Bx43DCj8Bg7G7+3X0FYz QLI3tZjJ+IaX1aLHwkDc79XuUo5yauo/IrvWkgHYoQiPp20CMQETKqsTckybwZTVCc7G Y/Q2ZTrYfheEjpfJlh3uTZZOG9JZYSBn9K3g0U9jix1j63+zx0x40zDRlyxr/kILzBbi BGRA== X-Gm-Message-State: ACgBeo3PPJej16FNCBIm1GIoeL+60l8IA8rPTzeToY+N3jh8H1dygpmp sWgu5rW3KNp6HZbNAdr1H6EHqK3C3LU= X-Google-Smtp-Source: AA6agR5OeI+sLvsm+lfZ882HvniADwZVXwfw95JgJ3xKf45lTtqMgkBfv76UONJ0bnFuJa/fMVRyTw== X-Received: by 2002:a9d:5f8e:0:b0:638:87d9:11ed with SMTP id g14-20020a9d5f8e000000b0063887d911edmr7809562oti.354.1661851960224; Tue, 30 Aug 2022 02:32:40 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id r2-20020a056830134200b006370815815asm7033167otq.61.2022.08.30.02.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:39 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 35/51] completion: bash: improve __gitcomp description Date: Tue, 30 Aug 2022 04:31:22 -0500 Message-Id: <20220830093138.1581538-36-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It does a lot more than what is stated now. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 9e15538f53..6610054e0e 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -324,8 +324,7 @@ __gitcompadd () done } -# Generates completion reply, appending a space to possible completion words, -# if necessary. +# Creates completion replies, reorganizing options and adding suffixes as needed. # It accepts 1 to 4 arguments: # 1: List of possible completion words. # 2: A prefix to be added to each possible completion word (optional). From patchwork Tue Aug 30 09:31:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4006BC0502A for ; Tue, 30 Aug 2022 09:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbiH3JeH (ORCPT ); Tue, 30 Aug 2022 05:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbiH3JdF (ORCPT ); Tue, 30 Aug 2022 05:33:05 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92136E1AAD for ; Tue, 30 Aug 2022 02:32:42 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-11ee4649dfcso8940871fac.1 for ; Tue, 30 Aug 2022 02:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=4LggF5ZXBnEm2SPdHNSdF/O3Bocbl/f1xI78pOSnbdo=; b=K0xK+KqI0FnNbeOO95mfYGutjkGYmCtGR9oQGKMMMIRuK+ciQg6ebYCEwMo7Z0XchC 3Y4aIGQx0r/Nc6AT9cZ3A7N7IB9zvvtLloFoLGa2lrkBp7HMChBknDDfnlulQQ0SXmdO A1ZIdkz24ZQ+Nk0pcsHDd6mWFsMm13VtfK+W2hk14yJwWRd9jPKl3t0luZ2nWtsvthfD dpUwd9A9MFc+/eYqoa7F0D90JEF3g9IApeHEA0JokRjSLxbFRZnCGkPL52x8+4mKh/iP vIAbJnTWdPvSYJUbSCAjYZvH5aFjeuc/wSwwLu/dUmdiICEsqV78w+xmZ4BKkkMFEXRa DW8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=4LggF5ZXBnEm2SPdHNSdF/O3Bocbl/f1xI78pOSnbdo=; b=7ViX2eXjaoHFUSKcWAvp4ZJZ0UGu/e431xhfF7CW3mfQFyBMeZxR/kHs8HVLhws/OK ckgaQ+9HcjAURFEIPsZeThhJSRp4lTLnGWpM8EWcfRIjsWBK1tW1RSIhs3q/oaMrLt7v VG6qu3zpmJJrV2oPJ6+8X0kt1up6MjigCWNzE8LDJT6sCGGGN5rvprNAq5cTWP9oase6 3qNR0etnlI7JYiog7425uRwznP5JCt+FOEjfo8EQcRXxHbaPEDDQFSlif9VaWZkQgz5/ gAoqgHBFtc9vRw91WtTHYFOyqV0FEtf9C8YG9aXG7yeEecOs3r0TjmVZoV7YywFKA7bL MEhA== X-Gm-Message-State: ACgBeo3eScHtCr7CTpxJPXxVe2uuK8GO/UZi7l8W69VXCd2ajNsOvyzf LlUA+9UdMkcxev8q6xz7OY/fmnJdP30= X-Google-Smtp-Source: AA6agR6Z+IvG2u8dH4ANNEOCNu9M8a7/2m4kgYco9awOuoOSJpbbJUHErm2sGnHjOFSuR+wKTSXtMg== X-Received: by 2002:a05:6870:5702:b0:11e:dd17:d4b6 with SMTP id k2-20020a056870570200b0011edd17d4b6mr5030901oap.112.1661851961729; Tue, 30 Aug 2022 02:32:41 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id s8-20020a056830148800b0063911de9fd8sm7068596otq.24.2022.08.30.02.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:41 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 36/51] completion: add __gitcomp_opts Date: Tue, 30 Aug 2022 04:31:23 -0500 Message-Id: <20220830093138.1581538-37-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Create a new simplified version of __gitcomp for most callers, and __gitcomp_opts for the ones that need reorganizing all the options. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 94 +++++++++++++++----------- contrib/completion/git-completion.zsh | 8 +++ t/t9902-completion.sh | 58 ++++++++-------- t/t9904-zsh-completion.sh | 54 +++++++-------- 4 files changed, 117 insertions(+), 97 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 6610054e0e..2cedbd6cc8 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -324,13 +324,25 @@ __gitcompadd () done } -# Creates completion replies, reorganizing options and adding suffixes as needed. +# Creates completion replies. # It accepts 1 to 4 arguments: # 1: List of possible completion words. # 2: A prefix to be added to each possible completion word (optional). # 3: Generate possible completion matches for this word (optional). # 4: A suffix to be appended to each possible completion word (optional). __gitcomp () +{ + local IFS=$' \t\n' + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Creates completion replies, reorganizing options and adding suffixes as needed. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp_opts () { local cur_="${3-$cur}" @@ -374,7 +386,7 @@ fi # This function is equivalent to # -# __gitcomp "$(git xxx --git-completion-helper) ..." +# __gitcomp_opts "$(git xxx --git-completion-helper) ..." # # except that the output is cached. Accept 1-3 arguments: # 1: the git command to execute, this is also the cache key @@ -409,7 +421,7 @@ __gitcomp_builtin () eval "$var=\"$options\"" fi - __gitcomp "$options" + __gitcomp_opts "$options" } # Generates completion reply from newline-separated possible completion words @@ -1046,7 +1058,7 @@ __git_complete_strategy () return 0 ;; -X) - __gitcomp "$__git_merge_strategy_options" + __gitcomp_opts "$__git_merge_strategy_options" return 0 ;; esac @@ -1056,7 +1068,7 @@ __git_complete_strategy () return 0 ;; --strategy-option=*) - __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}" + __gitcomp_opts "$__git_merge_strategy_options" "" "${cur##--strategy-option=}" return 0 ;; esac @@ -1298,7 +1310,7 @@ _git_am () { __git_find_repo_path if [ -d "$__git_repo_path"/rebase-apply ]; then - __gitcomp "$__git_am_inprogress_options" + __gitcomp_opts "$__git_am_inprogress_options" return fi case "$cur" in @@ -1558,7 +1570,7 @@ _git_cherry_pick () { __git_find_repo_path if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then - __gitcomp "$__git_cherry_pick_inprogress_options" + __gitcomp_opts "$__git_cherry_pick_inprogress_options" return fi @@ -1717,7 +1729,7 @@ _git_diff () return ;; --*) - __gitcomp "$__git_diff_difftool_options" + __gitcomp_opts "$__git_diff_difftool_options" return ;; esac @@ -2011,7 +2023,7 @@ _git_log () return ;; --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options @@ -2074,7 +2086,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" + __gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui" return ;; esac @@ -2222,7 +2234,7 @@ _git_range_diff () { case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --creation-factor= --no-dual-color $__git_diff_common_options " @@ -2239,11 +2251,11 @@ _git_rebase () { __git_find_repo_path if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then - __gitcomp "$__git_rebase_interactive_inprogress_options" + __gitcomp_opts "$__git_rebase_interactive_inprogress_options" return elif [ -d "$__git_repo_path"/rebase-apply ] || \ [ -d "$__git_repo_path"/rebase-merge ]; then - __gitcomp "$__git_rebase_inprogress_options" + __gitcomp_opts "$__git_rebase_inprogress_options" return fi __git_complete_strategy && return @@ -2857,7 +2869,7 @@ _git_revert () { __git_find_repo_path if [ -f "$__git_repo_path"/REVERT_HEAD ]; then - __gitcomp "$__git_revert_inprogress_options" + __gitcomp_opts "$__git_revert_inprogress_options" return fi __git_complete_strategy && return @@ -2889,7 +2901,7 @@ _git_shortlog () case "$cur" in --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options --numbered --summary --email @@ -2927,7 +2939,7 @@ _git_show () return ;; --*) - __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit + __gitcomp_opts "--pretty= --format= --abbrev-commit --no-abbrev-commit --oneline --show-signature --expand-tabs --expand-tabs= --no-expand-tabs $__git_diff_common_options @@ -3053,7 +3065,7 @@ _git_submodule () if [ -z "$subcommand" ]; then case "$cur" in --*) - __gitcomp "--quiet" + __gitcomp_opts "--quiet" ;; *) __gitcomp "$subcommands" @@ -3064,29 +3076,29 @@ _git_submodule () case "$subcommand,$cur" in add,--*) - __gitcomp "--branch --force --name --reference --depth" + __gitcomp_opts "--branch --force --name --reference --depth" ;; status,--*) - __gitcomp "--cached --recursive" + __gitcomp_opts "--cached --recursive" ;; deinit,--*) - __gitcomp "--force --all" + __gitcomp_opts "--force --all" ;; update,--*) - __gitcomp " + __gitcomp_opts " --init --remote --no-fetch --recommend-shallow --no-recommend-shallow --force --rebase --merge --reference --depth --recursive --jobs " ;; set-branch,--*) - __gitcomp "--default --branch" + __gitcomp_opts "--default --branch" ;; summary,--*) - __gitcomp "--cached --files --summary-limit" + __gitcomp_opts "--cached --files --summary-limit" ;; foreach,--*|sync,--*) - __gitcomp "--recursive" + __gitcomp_opts "--recursive" ;; *) ;; @@ -3127,64 +3139,64 @@ _git_svn () case "$subcommand,$cur" in fetch,--*) - __gitcomp "--revision= --fetch-all $fc_opts" + __gitcomp_opts "--revision= --fetch-all $fc_opts" ;; clone,--*) - __gitcomp "--revision= $fc_opts $init_opts" + __gitcomp_opts "--revision= $fc_opts $init_opts" ;; init,--*) - __gitcomp "$init_opts" + __gitcomp_opts "$init_opts" ;; dcommit,--*) - __gitcomp " + __gitcomp_opts " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url --revision --interactive $cmt_opts $fc_opts " ;; set-tree,--*) - __gitcomp "--stdin $cmt_opts $fc_opts" + __gitcomp_opts "--stdin $cmt_opts $fc_opts" ;; create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ show-externals,--*|mkdirs,--*) - __gitcomp "--revision=" + __gitcomp_opts "--revision=" ;; log,--*) - __gitcomp " + __gitcomp_opts " --limit= --revision= --verbose --incremental --oneline --show-commit --non-recursive --authors-file= --color " ;; rebase,--*) - __gitcomp " + __gitcomp_opts " --merge --verbose --strategy= --local --fetch-all --dry-run $fc_opts " ;; commit-diff,--*) - __gitcomp "--message= --file= --revision= $cmt_opts" + __gitcomp_opts "--message= --file= --revision= $cmt_opts" ;; info,--*) - __gitcomp "--url" + __gitcomp_opts "--url" ;; branch,--*) - __gitcomp "--dry-run --message --tag" + __gitcomp_opts "--dry-run --message --tag" ;; tag,--*) - __gitcomp "--dry-run --message" + __gitcomp_opts "--dry-run --message" ;; blame,--*) - __gitcomp "--git-format" + __gitcomp_opts "--git-format" ;; migrate,--*) - __gitcomp " + __gitcomp_opts " --config-dir= --ignore-paths= --minimize --no-auth-cache --username= " ;; reset,--*) - __gitcomp "--revision= --parent" + __gitcomp_opts "--revision= --parent" ;; *) ;; @@ -3424,7 +3436,7 @@ __git_main () esac case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --paginate --no-pager --git-dir= @@ -3481,7 +3493,7 @@ __gitk_main () fi case "$cur" in --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_gitk_options $merge diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 41aae0f454..2ad24f1510 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -54,6 +54,14 @@ __gitcomp () { emulate -L zsh + local IFS=$' \t\n' + compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 +} + +__gitcomp_opts () +{ + emulate -L zsh + local cur_="${3-$cur}" [[ "$cur_" == *= ]] && return diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index e1e9c6e365..eb8e173e6b 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -98,17 +98,17 @@ test_completion () test_cmp expected out_sorted } -# Test __gitcomp. +# Test __gitcomp_opts. # The first argument is the typed text so far (cur); the rest are -# passed to __gitcomp. Expected output comes is read from the +# passed to __gitcomp_opts. Expected output comes is read from the # standard input, like test_completion(). -test_gitcomp () +test_gitcomp_opts () { local -a COMPREPLY && sed -e 's/Z$//' >expected && local cur="$1" && shift && - __gitcomp "$@" && + __gitcomp_opts "$@" && print_comp && test_cmp expected out } @@ -463,8 +463,8 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' ' test_cmp expected out ' -test_expect_success '__gitcomp - trailing space - options' ' - test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message= +test_expect_success '__gitcomp_opts - trailing space - options' ' + test_gitcomp_opts "--re" "--dry-run --reuse-message= --reedit-message= --reset-author" <<-EOF --reuse-message=Z --reedit-message=Z @@ -472,8 +472,8 @@ test_expect_success '__gitcomp - trailing space - options' ' EOF ' -test_expect_success '__gitcomp - trailing space - config keys' ' - test_gitcomp "br" "branch. branch.autosetupmerge +test_expect_success '__gitcomp_opts - trailing space - config keys' ' + test_gitcomp_opts "br" "branch. branch.autosetupmerge branch.autosetuprebase browser." <<-\EOF branch.Z branch.autosetupmerge Z @@ -482,32 +482,32 @@ test_expect_success '__gitcomp - trailing space - config keys' ' EOF ' -test_expect_success '__gitcomp - option parameter' ' - test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \ +test_expect_success '__gitcomp_opts - option parameter' ' + test_gitcomp_opts "--strategy=re" "octopus ours recursive resolve subtree" \ "" "re" <<-\EOF recursive Z resolve Z EOF ' -test_expect_success '__gitcomp - prefix' ' - test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ +test_expect_success '__gitcomp_opts - prefix' ' + test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z EOF ' -test_expect_success '__gitcomp - suffix' ' - test_gitcomp "branch.ma" "master maint next seen" "branch." \ +test_expect_success '__gitcomp_opts - suffix' ' + test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z EOF ' -test_expect_success '__gitcomp - ignore optional negative options' ' - test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore optional negative options' ' + test_gitcomp_opts "--" "--abc --def --no-one -- --no-two" <<-\EOF --abc Z --def Z --no-one Z @@ -515,44 +515,44 @@ test_expect_success '__gitcomp - ignore optional negative options' ' EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF --abc Z --abcdef Z EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--n" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-... Z EOF ' -test_expect_success '__gitcomp - expand all negative options' ' - test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand all negative options' ' + test_gitcomp_opts "--no-" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-two Z EOF ' -test_expect_success '__gitcomp - expand/narrow all negative options' ' - test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand/narrow all negative options' ' + test_gitcomp_opts "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z EOF ' -test_expect_success '__gitcomp - equal skip' ' - test_gitcomp "--option=" "--option=" <<-\EOF && +test_expect_success '__gitcomp_opts - equal skip' ' + test_gitcomp_opts "--option=" "--option=" <<-\EOF && EOF - test_gitcomp "option=" "option=" <<-\EOF + test_gitcomp_opts "option=" "option=" <<-\EOF EOF ' -test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' - run_func __gitcomp "$invalid_variable_name" +test_expect_success '__gitcomp_opts - doesnt fail because of invalid variable name' ' + run_func __gitcomp_opts "$invalid_variable_name" ' read -r -d "" refs <<-\EOF diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index 42917833e8..894f3287f4 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -37,16 +37,16 @@ test_completion () test_cmp expected out_sorted } -# Test __gitcomp. +# Test __gitcomp_opts. # The first argument is the typed text so far (cur); the rest are -# passed to __gitcomp. Expected output comes is read from the +# passed to __gitcomp_opts. Expected output comes is read from the # standard input, like test_completion(). -test_gitcomp () +test_gitcomp_opts () { sed -e 's/Z$//' >expected && local cur="$1" && shift && - run_completion "git func __gitcomp $(printf "%q " "$@") $cur" && + run_completion "git func __gitcomp_opts $(printf "%q " "$@") $cur" && test_cmp expected out } @@ -78,8 +78,8 @@ test_expect_success 'setup for __git_find_repo_path/__gitdir tests' ' git init -b main otherrepo ' -test_expect_success '__gitcomp - trailing space - options' ' - test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message= +test_expect_success '__gitcomp_opts - trailing space - options' ' + test_gitcomp_opts "--re" "--dry-run --reuse-message= --reedit-message= --reset-author" <<-EOF --reuse-message=Z --reedit-message=Z @@ -87,8 +87,8 @@ test_expect_success '__gitcomp - trailing space - options' ' EOF ' -test_expect_success '__gitcomp - trailing space - config keys' ' - test_gitcomp "br" "branch. branch.autosetupmerge +test_expect_success '__gitcomp_opts - trailing space - config keys' ' + test_gitcomp_opts "br" "branch. branch.autosetupmerge branch.autosetuprebase browser." <<-\EOF branch.Z branch.autosetupmerge Z @@ -97,32 +97,32 @@ test_expect_success '__gitcomp - trailing space - config keys' ' EOF ' -test_expect_success '__gitcomp - option parameter' ' - test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \ +test_expect_success '__gitcomp_opts - option parameter' ' + test_gitcomp_opts "--strategy=re" "octopus ours recursive resolve subtree" \ "" "re" <<-\EOF recursive Z resolve Z EOF ' -test_expect_failure '__gitcomp - prefix' ' - test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ +test_expect_failure '__gitcomp_opts - prefix' ' + test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z EOF ' -test_expect_failure '__gitcomp - suffix' ' - test_gitcomp "branch.ma" "master maint next seen" "branch." \ +test_expect_failure '__gitcomp_opts - suffix' ' + test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z EOF ' -test_expect_success '__gitcomp - ignore optional negative options' ' - test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore optional negative options' ' + test_gitcomp_opts "--" "--abc --def --no-one -- --no-two" <<-\EOF --abc Z --def Z --no-one Z @@ -130,38 +130,38 @@ test_expect_success '__gitcomp - ignore optional negative options' ' EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF --abc Z --abcdef Z EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--n" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-... Z EOF ' -test_expect_success '__gitcomp - expand all negative options' ' - test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand all negative options' ' + test_gitcomp_opts "--no-" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-two Z EOF ' -test_expect_success '__gitcomp - expand/narrow all negative options' ' - test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand/narrow all negative options' ' + test_gitcomp_opts "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z EOF ' -test_expect_success '__gitcomp - equal skip' ' - test_gitcomp "--option=" "--option=" <<-\EOF && +test_expect_success '__gitcomp_opts - equal skip' ' + test_gitcomp_opts "--option=" "--option=" <<-\EOF && EOF - test_gitcomp "option=" "option=" <<-\EOF + test_gitcomp_opts "option=" "option=" <<-\EOF EOF ' From patchwork Tue Aug 30 09:31:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EBD2ECAAA1 for ; Tue, 30 Aug 2022 09:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbiH3JeI (ORCPT ); Tue, 30 Aug 2022 05:34:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231751AbiH3JdI (ORCPT ); Tue, 30 Aug 2022 05:33:08 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43164A896E for ; Tue, 30 Aug 2022 02:32:44 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11f11d932a8so6970096fac.3 for ; Tue, 30 Aug 2022 02:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=TWKgmqMPhVEcP7ybhsAz+OTCIFigxtGhzHsAzZ0iTxw=; b=YXmSrn7mkmtAheJja5e3VGkYXHbEGyvs5YAk0Mdqj8Iy3zuvDcxSJG1XT6gtT64h1H XDGpHEIQDM/lT/vOuXlxhJNOD9mciJKTHuJvsnOeep1+7mddKaSZJ3MiT8l0QmckuUVn SbfYN/eIR8G9dV1clk8Kmbg1/yFXBMElWh+EgHN9R1yIPVGZ0RawXyZyi39jnSLMCrrT MO67fAF4BSIbxvIi/SRVzstrNT31cF7dd5tgQtsHveyu4MZb844zxeG6rNjSZJWpyk2H xQfTclI0kMz8JtbmbCLFVIR1m5+YezHKVm4Z700ZWQuCi1ov2jLGhrBUNhX7anRVw2n0 +2eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=TWKgmqMPhVEcP7ybhsAz+OTCIFigxtGhzHsAzZ0iTxw=; b=wbmNeL4PBVrDA+tqjsj1DsmeYRh6oCrEPKndc0NtJQI/tuqyTQ3qkEDesp1gC9ydIt uc6E46qRhBEruRs6XU4cbTkKBF/OuK2VvGoZOxlrRT0xvLoSFkTGgU+4K39kgOnQcMGQ QVSyLZSR2FmrybP8XmSEXlgTYgSv1jTviW0G+kpwK63pFfbJUfOXC+lnHAunmiDvaTVx YQGklo2y2gFyS5GVaEvA6UusrBAfvWNRrY0NH/63DHeOyETPSMbtlU3qCJXp65BpSRBU Z6QU4YMETCa+siRjpxdjmJHoxYvTo3jJLpwg+yPvn9NasczRcKRCqp7IGK2Kg6i6wsvQ 5cyg== X-Gm-Message-State: ACgBeo0aQlUwPWWcYcV8y0EFKc+THZfIsrOP4bEiRBUgMvzVqyVFJxC7 vk7yZTrwfHD7UJ2FK37x4gvbngNm9W4= X-Google-Smtp-Source: AA6agR55aTKivPIKYF0OdjqbyRaZDb6WX2eaRyTlJU4j1ynJrOO2RBkfidow850EYqTR/012wCn+5Q== X-Received: by 2002:a05:6870:3042:b0:11d:d1d:a29d with SMTP id u2-20020a056870304200b0011d0d1da29dmr9421936oau.79.1661851963362; Tue, 30 Aug 2022 02:32:43 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id e6-20020a05683013c600b00638ac7ddb77sm6876390otq.10.2022.08.30.02.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:42 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 37/51] completion: bash: cleanup __gitcomp* invocations Date: Tue, 30 Aug 2022 04:31:24 -0500 Message-Id: <20220830093138.1581538-38-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Some __gitcomp calls should be __gitcomp_nl, and vice versa. No functional changes. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 2cedbd6cc8..499ccd3a93 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1374,7 +1374,7 @@ _git_archive () { case "$cur" in --format=*) - __gitcomp "$(git archive --list)" "" "${cur##--format=}" + __gitcomp_nl "$(git archive --list)" "" "${cur##--format=}" return ;; --remote=*) @@ -1788,9 +1788,7 @@ _git_format_patch () { case "$cur" in --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --base=*|--interdiff=*|--range-diff=*) @@ -2296,7 +2294,7 @@ _git_send_email () { case "$prev" in --to|--cc|--bcc|--from) - __gitcomp "$(__git send-email --dump-aliases)" + __gitcomp_nl "$(__git send-email --dump-aliases)" return ;; esac @@ -2320,9 +2318,7 @@ _git_send_email () return ;; --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --to=*|--cc=*|--bcc=*|--from=*) @@ -2622,7 +2618,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" - __gitcomp_nl $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx" + __gitcomp "autoSetupMerge autoSetupRebase" "$pfx" "$cur_" "$sfx" return ;; guitool.*.*) @@ -2672,7 +2668,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." - __gitcomp_nl "pushDefault" "$pfx" "$cur_" "$sfx" + __gitcomp "pushDefault" "$pfx" "$cur_" "$sfx" return ;; url.*.*) @@ -2687,7 +2683,7 @@ __git_complete_config_variable_name () ;; *) __git_compute_config_sections - __gitcomp "$__git_config_sections" "" "$cur_" "." + __gitcomp_nl "$__git_config_sections" "" "$cur_" "." ;; esac } @@ -2781,7 +2777,7 @@ _git_remote () __gitcomp_builtin remote_update ;; update,*) - __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")" + __gitcomp_nl "$(__git_remotes) $(__git_get_config_variables "remotes")" ;; set-url,--*) __gitcomp_builtin remote_set-url @@ -3464,7 +3460,7 @@ __git_main () then list_cmds=builtins,$list_cmds fi - __gitcomp "$(__git --list-cmds=$list_cmds)" + __gitcomp_nl "$(__git --list-cmds=$list_cmds)" fi ;; esac From patchwork Tue Aug 30 09:31:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958996 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE0BEECAAD4 for ; Tue, 30 Aug 2022 09:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231697AbiH3Jem (ORCPT ); Tue, 30 Aug 2022 05:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbiH3Jdi (ORCPT ); Tue, 30 Aug 2022 05:33:38 -0400 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C26E3405 for ; Tue, 30 Aug 2022 02:32:46 -0700 (PDT) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11e7e0a63e2so14521510fac.4 for ; Tue, 30 Aug 2022 02:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=YhkTed68p2Uxo1IBn+fWuwHT+eSWenyWzCMg4VkHXNg=; b=euuM28Pj7IbZ9g+ZGs7Kpjjrxjg6ktAL6bR8YAgpJup4zhba42sSir3aF+858SEJw6 Oq67FxE9dFS7U62iWhSR9tMDfdrLEJkLwOnp1vWUc+ukhPoAPVfgUPIxeO0j22S/Z9iu dBOyJq+3MDnFsRxLzUZtsbX+YfFZAfFaOXy1gxanSX0AMa9FNLYFop6C2ufFVLS/lB5I fk4BK1slRsTKTnUYitZ1sokO+OQzgSzClpUrkH7HV3pYjQfVB1bSG8eHRcpJ43Jj8NlO O01hAdhKkBlEfC3qFIhzWxYxs2bO3HppoJPQxoDRYOS0mtC1nGjzy9476C7bFTbM7WLD eBhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=YhkTed68p2Uxo1IBn+fWuwHT+eSWenyWzCMg4VkHXNg=; b=5cArOkYDAmg2ZqyEwhysT7AOF6msKWhNTYkYtNjlzuj8GiZ7ggNkb89u1uHsRISlMS LUFlQwreh4NVplqG77dRpo7zQM8eYPeiYZL30X9qu0550Us8pF16d8gAXBRZQX8rt8tq jp/z3xRCCXQ1U65b1f/6M52HxAf2akuP+LMfL5r41katKpTDv5BJNJbB5zTdJ3/uGLsl RhcNOSSRJA4G56vkiUSbJUVFbzxJYvH+g2dm7gm5jT+uwPHd7jseJxhtLsGbcWgAW1dg vIUYy7/rHlCB1klf8gUbWhyuB7RzYnLwqY7dLXiBJyJeHjEfm2b5/RBsNou/olkIZN7v z7oA== X-Gm-Message-State: ACgBeo1dtTFDbnmd2PeC5ujX+UZVtlY5eZ6XINl0zsBHX8sMRYcB47Hn CCvo2Y9YaytNdshg1GU/DpAY5BMg7UM= X-Google-Smtp-Source: AA6agR4uMWPBz/Qte/hABwpQOMVm7u6PKDbp19173kuyHfbPxF4Q4HcCGe1Fp+T1jRUCFeyO4QxZ7g== X-Received: by 2002:a05:6870:6193:b0:11f:4944:705f with SMTP id a19-20020a056870619300b0011f4944705fmr569579oah.100.1661851964934; Tue, 30 Aug 2022 02:32:44 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id o4-20020acabe04000000b00342d18cc2fdsm5886076oif.53.2022.08.30.02.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:44 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 38/51] completion: bash: shuffle __gitcomp functions Date: Tue, 30 Aug 2022 04:31:25 -0500 Message-Id: <20220830093138.1581538-39-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org They are the ones that actually do the completion, put them at the top. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 270 +++++++++++++------------ 1 file changed, 139 insertions(+), 131 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 499ccd3a93..1fb99265e4 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -59,6 +59,145 @@ # When set to "1" suggest all options, including options which are # typically hidden (e.g. '--allow-empty' for 'git commit'). +# The following functions are meant to modify COMPREPLY, which should not be +# modified directly. The purpose is to localize the modifications so it's +# easier to emulate it in Zsh. Every time a new __gitcomp* function is added, +# the corresponding function should be added to Zsh. + +__gitcompadd () +{ + local x i=${#COMPREPLY[@]} + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +# Creates completion replies. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp () +{ + local IFS=$' \t\n' + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. The result is appended to COMPREPLY. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words, separated by a single newline. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word instead of +# the default space (optional). If specified but empty, nothing is +# appended. +__gitcomp_nl () +{ + local IFS=$'\n' + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Appends prefiltered words to COMPREPLY without any additional processing. +# Callers must take care of providing only words that match the current word +# to be completed and adding any prefix and/or suffix (trailing space!), if +# necessary. +# 1: List of newline-separated matching completion words, complete with +# prefix and suffix. +__gitcomp_direct () +{ + local IFS=$'\n' + + COMPREPLY+=($1) +} + +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + __gitcompadd "$1" "${2-}" "${3-$cur}" "" + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Fills the COMPREPLY array with prefiltered paths without any additional +# processing. +# Callers must take care of providing only paths that match the current path +# to be completed and adding any prefix path components, if necessary. +# 1: List of newline-separated matching paths, complete with all prefix +# path components. +__gitcomp_file_direct () +{ + local IFS=$'\n' + + COMPREPLY+=($1) + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Creates completion replies, reorganizing options and adding suffixes as needed. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp_opts () +{ + local cur_="${3-$cur}" + + if [[ "$cur_" == *= ]]; then + return + fi + + local c i=0 IFS=$' \t\n' sfx + for c in $1; do + if [[ $c == "--" ]]; then + if [[ "$cur_" == --no-* ]]; then + continue + fi + + if [[ --no == "$cur_"* ]]; then + COMPREPLY[i++]="--no-... " + fi + break + fi + if [[ $c == "$cur_"* ]]; then + if [[ -z "${4+set}" ]]; then + case $c in + *=|*.) sfx="" ;; + *) sfx=" " ;; + esac + else + sfx="$4" + fi + COMPREPLY[i++]="${2-}$c$sfx" + fi + done +} + +# __gitcomp functions end here +# ============================================================================== + # Discovers the path to the git repository taking any '--git-dir=' and # '-C ' options into account and stores it in the $__git_repo_path # variable. @@ -301,81 +440,6 @@ _get_comp_words_by_ref () } fi -# Appends prefiltered words to COMPREPLY without any additional processing. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct () -{ - local IFS=$'\n' - - COMPREPLY+=($1) -} - -__gitcompadd () -{ - local x i=${#COMPREPLY[@]} - for x in $1; do - if [[ "$x" == "$3"* ]]; then - COMPREPLY[i++]="$2$x$4" - fi - done -} - -# Creates completion replies. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word (optional). -__gitcomp () -{ - local IFS=$' \t\n' - __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" -} - -# Creates completion replies, reorganizing options and adding suffixes as needed. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word (optional). -__gitcomp_opts () -{ - local cur_="${3-$cur}" - - if [[ "$cur_" == *= ]]; then - return - fi - - local c i=0 IFS=$' \t\n' sfx - for c in $1; do - if [[ $c == "--" ]]; then - if [[ "$cur_" == --no-* ]]; then - continue - fi - - if [[ --no == "$cur_"* ]]; then - COMPREPLY[i++]="--no-... " - fi - break - fi - if [[ $c == "$cur_"* ]]; then - if [[ -z "${4+set}" ]]; then - case $c in - *=|*.) sfx="" ;; - *) sfx=" " ;; - esac - else - sfx="$4" - fi - COMPREPLY[i++]="${2-}$c$sfx" - fi - done -} - # Clear the variables caching builtins' options when (re-)sourcing # the completion script. if [[ -n ${ZSH_VERSION-} ]]; then @@ -424,62 +488,6 @@ __gitcomp_builtin () __gitcomp_opts "$options" } -# Generates completion reply from newline-separated possible completion words -# by appending a space to all of them. The result is appended to COMPREPLY. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words, separated by a single newline. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word instead of -# the default space (optional). If specified but empty, nothing is -# appended. -__gitcomp_nl () -{ - local IFS=$'\n' - __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" -} - -# Fills the COMPREPLY array with prefiltered paths without any additional -# processing. -# Callers must take care of providing only paths that match the current path -# to be completed and adding any prefix path components, if necessary. -# 1: List of newline-separated matching paths, complete with all prefix -# path components. -__gitcomp_file_direct () -{ - local IFS=$'\n' - - COMPREPLY+=($1) - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - -# Generates completion reply with compgen from newline-separated possible -# completion filenames. -# It accepts 1 to 3 arguments: -# 1: List of possible completion filenames, separated by a single newline. -# 2: A directory prefix to be added to each possible completion filename -# (optional). -# 3: Generate possible completion matches for this word (optional). -__gitcomp_file () -{ - local IFS=$'\n' - - # XXX does not work when the directory prefix contains a tilde, - # since tilde expansion is not applied. - # This means that COMPREPLY will be empty and Bash default - # completion will be used. - __gitcompadd "$1" "${2-}" "${3-$cur}" "" - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - # Execute 'git ls-files', unless the --committable option is specified, in # which case it runs 'git diff-index' to find out the files that can be # committed. It return paths relative to the directory specified in the first From patchwork Tue Aug 30 09:31:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66E77ECAAA1 for ; Tue, 30 Aug 2022 09:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbiH3Jeq (ORCPT ); Tue, 30 Aug 2022 05:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbiH3Jdl (ORCPT ); Tue, 30 Aug 2022 05:33:41 -0400 Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06F12E343B for ; Tue, 30 Aug 2022 02:32:48 -0700 (PDT) Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-11eb44f520dso11116972fac.10 for ; Tue, 30 Aug 2022 02:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ZzPrzCgtMa+zxt2GO2FhyxlV1r0KEBZJC0JeSY0yM4I=; b=GAHhGFc+rf5HSngJx89X55pviVm8K89eQhHCw4l6Sx+S0uiqGiouEAmgmQ0dFilLMq A3AlozS2zaD2aTTLAKVYvd2l2rBNowV8CezG1tKNYGV4BZgpWRRpo6SXNIE2W269epiJ nzAahYI3A7dEAV5nxYD6RFHfSKxlWUa6GHN1lrPCE7ltjnVVtIdTYi/gRVs7twbYQkTH r+Q/KRDRpC9xTpq6FLojgTi0b22JP0k1ElnyljQJ9EMQJ398oi2c4b19/eToOmjzsrLW jH+sqkErytosKLvodWmpgSKa5acVWjSe0THihFNr1Y35zA98el5Kq+m92/Hfo0njOVuJ 1hjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ZzPrzCgtMa+zxt2GO2FhyxlV1r0KEBZJC0JeSY0yM4I=; b=akRXKDXmrYUrKRJzsPkU82gA/k3fqVCYJCKoxwNu/1ueBlYi94bng6tLScqv6eF9wS WdQrRrGPnxlqJyso/DZc959E3MsVSHnpy9eEVkhgnOp9y/etJxEEvsqfRZXBKjo0NHLA Syistsx4gKjr4cWdy22ke2ea+FB7t7g8LnUV4xls4Bgnf8bROJMIWQMHu8c5830qytgR jPcVDl1teFhh/vQoNJ6n2qfBPv2d7xSl3aixf++GrnJL1KexXrthRQgm+0DNNrdHpyOx TO0f7qStXlTPAJ1Wcni11Cm9/SoPbDv99GgDk+jK3w+7aFUB95RA9vNvydmsMuQraeK7 z++A== X-Gm-Message-State: ACgBeo3kWYZUQ4jNn6/ugKEqCTjR64CSBXBYX5XCSukhvZSjsqQrRRoO eB3bGYfPiwNL7mjZuf/5BEwW3FHiD4Y= X-Google-Smtp-Source: AA6agR5GbGeZDwDF8jkaIvSH9k6EOUG30kH2pjs2syXGKKYkiztcefML68s0S+dGPeRwQrXAlxOTqw== X-Received: by 2002:aca:1901:0:b0:344:d4b5:9a1f with SMTP id l1-20020aca1901000000b00344d4b59a1fmr8722184oii.170.1661851966714; Tue, 30 Aug 2022 02:32:46 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id n6-20020a9d4d06000000b00636c81d4109sm7319586otf.46.2022.08.30.02.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 39/51] completion: zsh: simplify __gitcomp_direct Date: Tue, 30 Aug 2022 04:31:26 -0500 Message-Id: <20220830093138.1581538-40-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Not much different from __gitcomp_nl. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 2ad24f1510..3619c93ea9 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -90,9 +90,7 @@ __gitcomp_opts () __gitcomp_direct () { - emulate -L zsh - - compadd -Q -S '' -- ${(f)1} && _ret=0 + __gitcomp_nl "$1" "" "" "" } __gitcomp_nl () From patchwork Tue Aug 30 09:31:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B740ECAAD4 for ; Tue, 30 Aug 2022 09:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231898AbiH3JfC (ORCPT ); Tue, 30 Aug 2022 05:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231996AbiH3Jdo (ORCPT ); Tue, 30 Aug 2022 05:33:44 -0400 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1285E3422 for ; Tue, 30 Aug 2022 02:32:53 -0700 (PDT) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11edd61a9edso9324700fac.5 for ; Tue, 30 Aug 2022 02:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=8ybJbGXWQyp92D7MkB9mePNrwxxbMoFh3jEqwBQ1s0M=; b=DLdtyOtdjOsCDgQYfRSklPSZKpz98EVzC/2jsNFv90Y5Tg08raktWMR+kUc1WpY35t qzCHlrhOvAnUSRLjuBwt1mNg6krwi6Uwani4IRBcuOyRiQRj5Isfryo+hHo8rpKezKqp re5q89zwnRJwEL8DKHUNP4x4boWgv5avRbptk9Nr/0uSQyLxq8Jq3a1Cy4jHypS4Jyj6 hnlf47lYVpc1QqxPwYwW02B8klBXUciPmfv8BHwfZs/CSmcNYfBH6NrCVyaCIIeNVPPD 0FL9kbd0I67bf/y9U03PL49YcDlfLWE1Hbd+Qhur+5KMryHfeez+6PP8Yjc8YU/uhn5Y WvMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=8ybJbGXWQyp92D7MkB9mePNrwxxbMoFh3jEqwBQ1s0M=; b=TAo8LI0qg/N63SNgGV23MUCfszEk423htyL088oaGJv+q/mNXKyM5wQFHuQ9YrogZ9 fA6XWX3ZCBcb9SbuFrjtcKEUAWo3pSOELFe6tmcETBO4EnDGmB0OC0Uli8veSeef0rOJ ODgXqxs2OQZzEN0Wgj9sJL66nHFxxipkOX26i6+iWNcaTjSG4CHjmXde0ERepL4NQFbD B4IEsLffTsCvB+GrxyvHosyR6y3RQQHJd5G6l7tZoa+SQw4BvsPoVgt6dpc1QpABuuwv +VcmaNGsu9Vd4yaP3qZbTw+kDaBPUqbMTzDewYFJ1gfMYUlZEHwAdoR/7AIAJkQPu3Kq glNw== X-Gm-Message-State: ACgBeo3X1NKCNIMMGVC4gKWAAV1jKA8+p9Xs1qOWzVlkVqz7tZY3CrT/ IJF3X6PktAnROStPlIjT9OkdIPuV/WU= X-Google-Smtp-Source: AA6agR7xv3EvURVjtgzIFV/ssKQttTc/37zEDIQWVvOtTWovswejjoURV8Tr2OeoDHVHofls74+z4g== X-Received: by 2002:a05:6808:170b:b0:333:53cf:8022 with SMTP id bc11-20020a056808170b00b0033353cf8022mr9368495oib.28.1661851968724; Tue, 30 Aug 2022 02:32:48 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id a16-20020a0568300b9000b0063975d170a8sm5962378otv.7.2022.08.30.02.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:47 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 40/51] completion: zsh: shuffle __gitcomp* functions Date: Tue, 30 Aug 2022 04:31:27 -0500 Message-Id: <20220830093138.1581538-41-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 3619c93ea9..645b4bac31 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -88,11 +88,6 @@ __gitcomp_opts () compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 } -__gitcomp_direct () -{ - __gitcomp_nl "$1" "" "" "" -} - __gitcomp_nl () { emulate -L zsh @@ -107,6 +102,11 @@ __gitcomp_file () compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } +__gitcomp_direct () +{ + __gitcomp_nl "$1" "" "" "" +} + __gitcomp_file_direct () { __gitcomp_file "$1" "" From patchwork Tue Aug 30 09:31:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1809BECAAA1 for ; Tue, 30 Aug 2022 09:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231837AbiH3JfR (ORCPT ); Tue, 30 Aug 2022 05:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231854AbiH3JeE (ORCPT ); Tue, 30 Aug 2022 05:34:04 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD1BAE3940 for ; Tue, 30 Aug 2022 02:32:55 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id 92-20020a9d0be5000000b0063946111607so7658090oth.10 for ; Tue, 30 Aug 2022 02:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=h0o2dfYhUCQdsu9/5qAPOewvAtrTC1t2Eyd4ohoXrGA=; b=Cwmld5ObIomsE0MY75hauAh3O+u6UtbuY853wv6qoZd2fpjS53NyQeV/20ltOBIs8F WiKfWx7S3XIHJXuUDh8C22d2IKgH9hpqTPm3MBzjBhsNJ86yjb7U30k/HnmieP5jNc8I pvcyftt09St+/Nu6BMHWuKVXUNQvYUx6+uikA8JXkWgansnV9nBUKDrN+BLzNjFzpJ0O LpK9Zg+SmidytuVgdF28r1FczUJlSXRgzEJZd07mi/chG+NSCP50Aln4dqV8kb7fAuDq yIrKxqrket2nXy5wIJBQtkaaQM1rKNb0zj5qQnRb4lWrgt5EFEnPI1mOMIgyY0qQOubl 8w8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=h0o2dfYhUCQdsu9/5qAPOewvAtrTC1t2Eyd4ohoXrGA=; b=16cWDxL9EkIfoAsP7O7/3t2nU8ADuoBiZgPPVhhsnewjACevvUAZaf6FIJ/VuHt7A7 i5mvMAW/FtxgOwcRAxlexjg+Vcy/kAtog9ckJT4I00JWhQT24BxWP8gJxYrQtixS8GRG YWl9AP2PkU/Aeu8TqtH2x1hzsTEjoVN1mCVrJb4bhMqW6N6326TiO3fxRecc1I46h4Bt OtL73NzSR2k5Th2RHWQ5nMlqhShsSClIHByPZKu159kvCfb2eXvhnaehKtyOWZ5tZeoZ QI3c2q0X9jZZWbPc2qHX86XTVY1qEU8WJMhPD2gJg3l5EDAWkCGGsLSQsN9WzxMe9EOB RniQ== X-Gm-Message-State: ACgBeo3rpLZRCCIOosQOJK0MhSdkGdLd5XzN7miLYu5FT6pilOyf47hJ yTTiZvU/w+iZyk1nF3w/l+VGgRmToHA= X-Google-Smtp-Source: AA6agR4XNvUmVXPHvRy/pNoHFUVxRaXrByhkUonMxxjcFe30cmRKuMp8rHDbVsphi6yiJfOrbbqpKQ== X-Received: by 2002:a9d:7a8d:0:b0:636:eb5c:df96 with SMTP id l13-20020a9d7a8d000000b00636eb5cdf96mr8016986otn.173.1661851970270; Tue, 30 Aug 2022 02:32:50 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id s19-20020a056870e6d300b0011dca1bd2cdsm7540459oak.0.2022.08.30.02.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:49 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 41/51] completion: zsh: fix direct quoting Date: Tue, 30 Aug 2022 04:31:28 -0500 Message-Id: <20220830093138.1581538-42-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Apparently using "compadd -Q" is almost always wrong, we want zsh to add quoting when necessary. However, if we remove the -Q option, that would make zsh add an extra "\ " at the end of some completions. We can manually remove the spaces from the completions that have them, and then add the suffix with the -S option, thus there's no more need for the -Q option. This makes completions like "stash@{0}" complete correctly: git stash show Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 645b4bac31..27ca6efe89 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -55,7 +55,7 @@ __gitcomp () emulate -L zsh local IFS=$' \t\n' - compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } __gitcomp_opts () @@ -85,14 +85,17 @@ __gitcomp_opts () fi array+=("$c$sfx") done - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 + compadd -S '' -p "${2-}" -a -- array && _ret=0 } __gitcomp_nl () { emulate -L zsh - compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 + # words that don't end up in space + compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0 + # words that end in space + compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0 } __gitcomp_file () From patchwork Tue Aug 30 09:31:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958998 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 751F5ECAAA1 for ; Tue, 30 Aug 2022 09:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231598AbiH3Je5 (ORCPT ); Tue, 30 Aug 2022 05:34:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231986AbiH3Jdn (ORCPT ); Tue, 30 Aug 2022 05:33:43 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95102E396B for ; Tue, 30 Aug 2022 02:32:52 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11eb44f520dso11117343fac.10 for ; Tue, 30 Aug 2022 02:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=u7c4d2dsQmi2klbljrl3ge854mHL9xVjW+BQ90H26dE=; b=ieyo61QrxZ0ceEt5J8gNJ4xEL/tXUhL7QTSSPgYzUFjXk5p7xhek23KShDNvSnc/mj dUQfwVATfJHUVCSM3iokXYPN9093jZNxal456VlB5vo9u80vyQzyF2y4A0CWf3hcO1PS 6ufxYaV7zKzpIqw0BxwdA5Xj052EFzKKdZuy8BuA3WJxrLlzLrErjQY2i5B/t5/x7yS2 NsfDogCCaEOgqIOQnKmfqRc9+s9UzXv/8xweXcGTLvNI8aH07tUEhg1VFuaZxUxHOQJG 4gjmUJbgu1oKon/zJb143zZnIukqAYX90jGjmfHdCHL0jL0/sZ7+e4tagiTLh8/kTb4C xMVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=u7c4d2dsQmi2klbljrl3ge854mHL9xVjW+BQ90H26dE=; b=pORf/LKZDcjQZ7c4llGRdM66vTTuis47VnJ2VV6IyfRmqT+PSmCeL9Co0QyOTiiUuE Fj6M4PxYcFzAm0WUJn4235tAaryZJjESSqpfX/jx4ZZS+qqanpz+/w3hXunHc0wy8jW1 6o+NOHijLyC680U2RCdKmvDB8sWQa/P93m8LixHvkhNJK+SodXo9oqubbOG10BimMaSK j+/3qzEsUwObTygznwLfvRbvePQBPpghSPOUp7Fvnhj1/pOinyP41FDjVuSSfp7g50E6 /mSkbldK29SKYeUGTu5tkD/twHhHI/wHem+4IGDWsBMhdVKStMrFbq9Xej/ir6TqQGsX U6NQ== X-Gm-Message-State: ACgBeo1FyfbK4VKFapRQFyG6y0uZrykl28hESY3rEP0wHFJXBCsSjlpt nb5tAeMIdX2UUBjV8jgC4WHaBI8mBeA= X-Google-Smtp-Source: AA6agR7nSfsGdgJftPjEdKk4VI7oFQTsrdXSdLh5mA69lbrBbRPyoMc4fL3GNJ3sBCBhiWQl6xCBPQ== X-Received: by 2002:a05:6808:8db:b0:344:fb71:2159 with SMTP id k27-20020a05680808db00b00344fb712159mr8989937oij.34.1661851971704; Tue, 30 Aug 2022 02:32:51 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id k8-20020a05687015c800b0011bb6582378sm7493008oad.51.2022.08.30.02.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:51 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 42/51] completion: zsh: add elements individually in __gitcomp_opts Date: Tue, 30 Aug 2022 04:31:29 -0500 Message-Id: <20220830093138.1581538-43-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's useful to specify specific suffixes for specific words. This will be useful later on. Additionally two tests now pass because we are not using an array anymore. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 6 ++---- t/t9904-zsh-completion.sh | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 27ca6efe89..42bf9b95eb 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -67,11 +67,10 @@ __gitcomp_opts () [[ "$cur_" == *= ]] && return local c IFS=$' \t\n' sfx - local -a array for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - array+=("--no-... ") + compadd -S " " -- "--no-..." && _ret=0 break fi @@ -83,9 +82,8 @@ __gitcomp_opts () else sfx="$4" fi - array+=("$c$sfx") + compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0 done - compadd -S '' -p "${2-}" -a -- array && _ret=0 } __gitcomp_nl () diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh index 894f3287f4..dc1578f41d 100755 --- a/t/t9904-zsh-completion.sh +++ b/t/t9904-zsh-completion.sh @@ -105,7 +105,7 @@ test_expect_success '__gitcomp_opts - option parameter' ' EOF ' -test_expect_failure '__gitcomp_opts - prefix' ' +test_expect_success '__gitcomp_opts - prefix' ' test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z @@ -113,7 +113,7 @@ test_expect_failure '__gitcomp_opts - prefix' ' EOF ' -test_expect_failure '__gitcomp_opts - suffix' ' +test_expect_success '__gitcomp_opts - suffix' ' test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z From patchwork Tue Aug 30 09:31:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12958999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5654AECAAA1 for ; Tue, 30 Aug 2022 09:35:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231890AbiH3JfA (ORCPT ); Tue, 30 Aug 2022 05:35:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbiH3Jdo (ORCPT ); Tue, 30 Aug 2022 05:33:44 -0400 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8D4FA7215 for ; Tue, 30 Aug 2022 02:32:58 -0700 (PDT) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11f4e634072so1126595fac.13 for ; Tue, 30 Aug 2022 02:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=y67mxaPhuEftXuTH0ZC/K37o+Ktly1XybGycaFlE8b0=; b=SMRnBKycEhFCiAR0vUCsl2LLlZxfezzSlRssAYW4QFAXX5eBWa0uaFzN9XnJycFsaG j7L4fqtGupQcINt3NlCd3JxQpDvPbrS5I4qqhvvclR4HWmfgRZ8UW1QRQo+//cV7l954 VuJOfB4Eqvg7mXpeQwPoyHaPmD4GpgXDhIFn4WFlu6Uj2vzLpoHsumHrCrGOKeqCnScy EZSs6+XbDU4ktYiuCzur10sbv3r8UDPsqbFWf1E8Aj+oWvMdy5xHeBBJqjsPq45pD/AN QBW2n88VMIjG5J/BHudsJ4tCkU3JptWJfLRp0Y32LaYK+9gw3EUHiTtiaJ58zPveroRp Txtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=y67mxaPhuEftXuTH0ZC/K37o+Ktly1XybGycaFlE8b0=; b=m5bCWkm3jEV8420E3GVkGR64c7WhJ4jhewQ2VK/1ZyRd0XCseIztdKitSv9BkOlwvy 5/s2hjFx6ti3xapHobUTZxm4jKH8mOQkXUjGKe+UcQ30QhdxE0G5k0M8DcsDKEAelk6x awc7RwEede5uq+LdNOj0ck823rXstB50el5wjeJvBlQhS75RtZttxzzpBB367X8zgnxw 7mRqYVdRLbVpLpvqLuDA1r4KaYB/IPUZalzakGT3tTYybRNFJ3SeFlKzx85w5Zs8Mx83 g/tTGE+63Y2wjemCV0+SRktEV4ho3N+zYDs5SJdMP2Iu/Umo4wbG8wCZZoMOY5+dXxov w+vA== X-Gm-Message-State: ACgBeo3w/KyRoIquS1MjTVRBjrWCcr/BwqNmwau341pnuqWo3PrJwFi+ p3y8TXYo9HESU3oJFgyNYpU7wUotBLA= X-Google-Smtp-Source: AA6agR4BnrO2KMyMgTOvHwYnzOmjjYz83D832Tr+UmK1KU65f8eEemAc5eO3f27LhAMKQsmR1/5XKQ== X-Received: by 2002:a05:6808:1488:b0:344:dc19:d7d9 with SMTP id e8-20020a056808148800b00344dc19d7d9mr8903620oiw.196.1661851974413; Tue, 30 Aug 2022 02:32:54 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id 63-20020aca0642000000b00326cb6225f8sm5873461oig.44.2022.08.30.02.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:53 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 43/51] completion: zsh: add __gitcompadd helper Date: Tue, 30 Aug 2022 04:31:30 -0500 Message-Id: <20220830093138.1581538-44-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org So we don't have to do the same over and over. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 42bf9b95eb..e66044ee89 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -50,12 +50,16 @@ COMP_WORDBREAKS=':' GIT_SOURCING_ZSH_COMPLETION=y . "$script" functions[complete]="$old_complete" +__gitcompadd () +{ + compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0 +} + __gitcomp () { emulate -L zsh - local IFS=$' \t\n' - compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }" } __gitcomp_opts () @@ -70,7 +74,7 @@ __gitcomp_opts () for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - compadd -S " " -- "--no-..." && _ret=0 + __gitcompadd "--no-..." break fi @@ -82,7 +86,7 @@ __gitcomp_opts () else sfx="$4" fi - compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0 + __gitcompadd "$c" "${2-}" "$sfx" done } From patchwork Tue Aug 30 09:31:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A601ECAAA1 for ; Tue, 30 Aug 2022 09:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231285AbiH3JfS (ORCPT ); Tue, 30 Aug 2022 05:35:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231751AbiH3JeO (ORCPT ); Tue, 30 Aug 2022 05:34:14 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEACCE42E2 for ; Tue, 30 Aug 2022 02:33:01 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-11f4e634072so1126760fac.13 for ; Tue, 30 Aug 2022 02:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MQPMTQIwLdDmVBRI1pD0ywp0dt6ZsLI3M0bKtlfXG2s=; b=o7zAoxYVmfL5dVeuj0u9o9w/O3lxA8xBDj79cCyBSnUSQ9l4ZICycQPTuqizAMgegS 9OlBX/ASdOu2rjyf0JsAVekTtH5dO23P0lisQipi+rPUVQMGL+8b2SZtTbvgSem2XOCb xZs7xg9gsTydzO7gX4TxgVJHszvLBVXcVSEVKUpklpJb0L1mNq6V0BtGZCsts3cTnE4N CZ4TOWr5dOkIUfh2x8FUcsm/vY2MPZ2XKC0+z5lIdh1IiOLwzXTX6an0yX7lVMjbvnSG x1FF/vQ1Xg4OSn7TWyDpEB7/Z6NNbdelYIdnrDHijPtOMcmxYfOdd3h6hLNRvgphBQ2+ UoHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MQPMTQIwLdDmVBRI1pD0ywp0dt6ZsLI3M0bKtlfXG2s=; b=XDIZfHB4ewIkaIA6fbHzN85ybBznhEES/gUnTvfPFw/kF80fg0I7QyuhVDFCfW9KF1 MtlA/nEe66DLshBebbWEJDHRkVELgK6Vit11Vs52OFqEMVsCbrXrBnhVZfyHN1r6YzPB RbLNlIEboyYbluygPki5zgZpQ2KdzrfYJcYxe5P+nEICApoCGrCzjnSJikkf7hbbDAW/ zPOz9VB8Vszkcd/MxPghQ04qdP10KBKGy1c43+OnZjnLRa4iI9Y2yAMo3VdQtlmEqTAQ X3UN84Ot+sbDA7vtq+pUpYm/LDJH29ZD7qITn9sY0T2+monphf3AAwSxQ2tgoAM+7ejP H2eA== X-Gm-Message-State: ACgBeo3WJNdz+iTx1/m4VitMG/83bamsYv7KGJ6eGSj08ZkrNnHHURle WlHQGAkB38XpuRkx1OJrzrT2Ls6tZP4= X-Google-Smtp-Source: AA6agR6vikPMrx+GtFlQA2YNevQiYZbzyXx8M2P2Pi79khmqlwRKF3EY9BfJXjQ9Sd2TRtspRJxnuA== X-Received: by 2002:a54:4e8e:0:b0:343:fe9:9516 with SMTP id c14-20020a544e8e000000b003430fe99516mr9144806oiy.198.1661851976313; Tue, 30 Aug 2022 02:32:56 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id y5-20020a056830208500b00636fd78dd57sm7135860otq.41.2022.08.30.02.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:55 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 44/51] completion: zsh: add correct removable suffix Date: Tue, 30 Aug 2022 04:31:31 -0500 Message-Id: <20220830093138.1581538-45-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Zsh has a nice feature that allows a suffix to be automatically removed if followed by a space. For example: git log --prety= If a space is typed, the suffix '=' is removed. But we have to set the correct prefix first. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index e66044ee89..7d34522621 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -52,7 +52,7 @@ functions[complete]="$old_complete" __gitcompadd () { - compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0 + compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0 } __gitcomp () @@ -80,7 +80,8 @@ __gitcomp_opts () if [[ -z "${4+set}" ]]; then case $c in - *=|*.) sfx="" ;; + *=) c="${c%=}"; sfx="=" ;; + *.) sfx="" ;; *) sfx=" " ;; esac else From patchwork Tue Aug 30 09:31:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF6FBECAAD4 for ; Tue, 30 Aug 2022 09:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231918AbiH3JfG (ORCPT ); Tue, 30 Aug 2022 05:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbiH3Jdv (ORCPT ); Tue, 30 Aug 2022 05:33:51 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC8BBD83E2 for ; Tue, 30 Aug 2022 02:32:58 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-11dca1c9c01so15402729fac.2 for ; Tue, 30 Aug 2022 02:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=lqgV6bwWDdhSDhwKNmNPOfLUKx8xvgABH1zgJqg9wjE=; b=H2QF77ZoYC3Xm8CqUJq3k+vHA4Qr1KDR/4/GPlT/nEXIYw7fRjwSSc+qh6LqN8ANld mDE9mDgPzFhP7yWNVk653mnvhq2QrHe+C5j3qdOzVkbC0Hevdtk+R69/TT8PbtPEehrj f8HG1WN3Lpo9VvUmQN3CJlMi/nUM1NjhU1HDwCID5SMUJSC4xs90zUnd7N3iou4/W1Ny 2COpTMcMU2Mo3E0L4D4tabx04/A41FnYbmsgWyo4w5+mbhsge3myxH2yzq/ziso1Fnkz AQs56S9kwVyjbf/jtEyoG/eDY0bLtVnPTqRslIPYqTaZH4kN6uZQZOB96mjMO15Dt6m1 E+Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=lqgV6bwWDdhSDhwKNmNPOfLUKx8xvgABH1zgJqg9wjE=; b=IUuhFDH6JJbdyOK+r7sCyAynQfj0QwI/Dhn4DdOCt9F9hZvVTZYQS9p70fbU78h0Xi E3uAurCuXJ8RgHYgpWSV7AJkdeDsF2+OfUW6hcaZwvi3lGdl3GNjiVl/cf+/NTn4Wlgp O7ppUMVAOl9sJIJ84yrPxq+852YLwxDWPEhe+nD0K7nBQbEBi9swUfjPSVolVfyhsZ/I n4Wk8b9vXP4XJHkkWiVfD6hjvMNHbChzGev8r4tjwtxHXAVBdQ6u6mLHNmx3OtIJ+l9t +3gui09t6MHco7+bn8fS5UNKFS9caml4AbFe9G+RJfcK920thoA7iAr7gkB7DrSiWojF 7xWQ== X-Gm-Message-State: ACgBeo0EpgT6s6lRugUWj59D+aF6T2uqB3r6nFgfZFePwBnmtpCPmMcn hIXMN2mNeZfA66ot0RwugdgkWFWYKoY= X-Google-Smtp-Source: AA6agR7FkCK0nsGTFxv9XhEUvuPhpV5aZz6qh3FjevnpnLICQWxN4YF0SPWglvEmlh7E3AI9ycxOdQ== X-Received: by 2002:a05:6870:4308:b0:10b:8cbe:c945 with SMTP id w8-20020a056870430800b0010b8cbec945mr9463038oah.220.1661851978114; Tue, 30 Aug 2022 02:32:58 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id y16-20020a056870429000b0010bf07976c9sm7473781oah.41.2022.08.30.02.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:57 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 45/51] completion: bash: simplify _get_comp_words_by_ref() Date: Tue, 30 Aug 2022 04:31:32 -0500 Message-Id: <20220830093138.1581538-46-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We don't need the whole functionality of _get_comp_words_by_ref(), we know exactly what we need from that function, so only do that. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 30 ++++++-------------------- t/t9902-completion.sh | 21 ++++-------------- 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 1fb99265e4..45550f7839 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -413,30 +413,12 @@ __git_reassemble_comp_words_by_ref() if ! type _get_comp_words_by_ref >/dev/null 2>&1; then _get_comp_words_by_ref () { - local exclude cur_ words_ cword_ - if [ "$1" = "-n" ]; then - exclude=$2 - shift 2 - fi - __git_reassemble_comp_words_by_ref "$exclude" - cur_=${words_[cword_]} - while [ $# -gt 0 ]; do - case "$1" in - cur) - cur=$cur_ - ;; - prev) - prev=${words_[$cword_-1]} - ;; - words) - words=("${words_[@]}") - ;; - cword) - cword=$cword_ - ;; - esac - shift - done + local words_ cword_ + __git_reassemble_comp_words_by_ref "=:" + cword=$cword_ + cur=${words_[cword]} + prev=${words_[cword-1]} + words=("${words_[@]}") } fi diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index eb8e173e6b..fc09bafa07 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -40,23 +40,10 @@ GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase' # So let's override it with a minimal version for testing purposes. _get_comp_words_by_ref () { - while [ $# -gt 0 ]; do - case "$1" in - cur) - cur=${_words[_cword]} - ;; - prev) - prev=${_words[_cword-1]} - ;; - words) - words=("${_words[@]}") - ;; - cword) - cword=$_cword - ;; - esac - shift - done + cword=$_cword + cur=${_words[cword]} + prev=${_words[cword-1]} + words=("${_words[@]}") } print_comp () From patchwork Tue Aug 30 09:31:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79EF6ECAAD4 for ; Tue, 30 Aug 2022 09:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230182AbiH3Jf0 (ORCPT ); Tue, 30 Aug 2022 05:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbiH3Jee (ORCPT ); Tue, 30 Aug 2022 05:34:34 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31854E58A1 for ; Tue, 30 Aug 2022 02:33:05 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-11f4e634072so1127052fac.13 for ; Tue, 30 Aug 2022 02:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=HnH6dC7OHuStdtDb06m88U0BNK3ncjzQYgWcrLZaKCQ=; b=DRifiaLOMf0dVjz0lTgjyfJPw+cV1zDCOBF+4tzI8ym/5O0Wt3TBWEGBoHS9M8nx95 rDlLXHuJe5tVGWVG6oS0vF3zj6gSbD1Najy1PvSzej5KkxK1u2rJwPdZnrLNmLlLgi6n sOKAC3aR1jGi5tFHaiLhYbRHOv+RNlml05QKGd4R1puGvYeF+aW4lAPxQSt2da3I00Su WfhFwB725FKkUqh/Mf+65WoQMTlpuiPt+Jy4UFZoxH+s556NrjzolaMkLswsCsqyLd9L bqvfNqC2X+EjC0JkXFVFaMkk88VHhkCtp/8DEO/Y5aYyFvwy5F2Z/Kc+QZLjxrLYzbzU u6UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=HnH6dC7OHuStdtDb06m88U0BNK3ncjzQYgWcrLZaKCQ=; b=RhTA4+Qds/jrYSNoyhH2/PPgXHuNDGCZwzjkN49UGb1R9grOIrFZDoWTmsqfW7qRvV RYY+abyHkRNtgMnjedYQqNVqWNrBXvCdJSXNdyJsCkO1Adr5pPoMtmcJSCn3ZGt0mfT5 DGM9SgzVeUNRyHHdWw1NIwWY1wivbfV4LWkQWpdvhC97iMak4FXV9TObOY497RuCwYLo u9lfA/z6WKmZBcbA5BO5fEfbPdu36XpWEpqCsCX/CgCDBaXKtIjdeg26Hk7YeEMRS7P2 mg0P5aVG1mWQPi1P5WPA6AcDd9AsZ0xdTAy8r3yIBgZPdRvimYDLz/rBRevuwSmuBPwn KTSA== X-Gm-Message-State: ACgBeo3NjizTWU3W+FS1YuEHsYErBmTAXYjuwFh2Kal1uly3MqW3Vweh IF+gVAVMwTkKibn/9RSM2dgbOJ2IQ44= X-Google-Smtp-Source: AA6agR4bhwmmBCSOeN6gxMVIL/pqZjwNk7lzxS9AUv/pl7ma7ZqKACcmESdi+IUAK6NC7nmxAvs5YQ== X-Received: by 2002:a05:6870:4302:b0:10d:c587:d30e with SMTP id w2-20020a056870430200b0010dc587d30emr9904645oah.28.1661851979797; Tue, 30 Aug 2022 02:32:59 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id q22-20020a056870e61600b0011c65559b04sm8072803oag.34.2022.08.30.02.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:32:59 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 46/51] completion: bash: refactor _get_comp_words_by_ref() Date: Tue, 30 Aug 2022 04:31:33 -0500 Message-Id: <20220830093138.1581538-47-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We don't need a separate function to do what we already know we want to do. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 93 +++++++++++--------------- 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 45550f7839..4261143d97 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -339,21 +339,11 @@ __git_dequote () # # RELEASE: 2.x -# This function can be used to access a tokenized list of words -# on the command line: -# -# __git_reassemble_comp_words_by_ref '=:' -# if test "${words_[cword_-1]}" = -w -# then -# ... -# fi -# -# The argument should be a collection of characters from the list of -# word completion separators (COMP_WORDBREAKS) to treat as ordinary -# characters. +# This function reorganizes the words on the command line to be processed by +# the rest of the script. # # This is roughly equivalent to going back in time and setting -# COMP_WORDBREAKS to exclude those characters. The intent is to +# COMP_WORDBREAKS to exclude '=' and ':'. The intent is to # make option types like --date= and : easy to # recognize by treating each shell word as a single token. # @@ -361,60 +351,55 @@ __git_dequote () # shared with other completion scripts. By the time the completion # function gets called, COMP_WORDS has already been populated so local # changes to COMP_WORDBREAKS have no effect. -# -# Output: words_, cword_, cur_. -__git_reassemble_comp_words_by_ref() +if ! type _get_comp_words_by_ref >/dev/null 2>&1; then +_get_comp_words_by_ref () { + local words_ cword_ local exclude i j first + # Which word separators to exclude? - exclude="${1//[^$COMP_WORDBREAKS]}" + exclude="${COMP_WORDBREAKS//[^=:]}" cword_=$COMP_CWORD if [ -z "$exclude" ]; then words_=("${COMP_WORDS[@]}") - return - fi - # List of word completion separators has shrunk; - # re-assemble words to complete. - for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do - # Append each nonempty word consisting of just - # word separator characters to the current word. - first=t - while - [ $i -gt 0 ] && - [ -n "${COMP_WORDS[$i]}" ] && - # word consists of excluded word separators - [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] - do - # Attach to the previous token, - # unless the previous token is the command name. - if [ $j -ge 2 ] && [ -n "$first" ]; then - ((j--)) - fi - first= + else + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + break 2 + fi + done words_[$j]=${words_[j]}${COMP_WORDS[i]} if [ $i = $COMP_CWORD ]; then cword_=$j fi - if (($i < ${#COMP_WORDS[@]} - 1)); then - ((i++)) - else - # Done. - return - fi done - words_[$j]=${words_[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword_=$j - fi - done -} + fi -if ! type _get_comp_words_by_ref >/dev/null 2>&1; then -_get_comp_words_by_ref () -{ - local words_ cword_ - __git_reassemble_comp_words_by_ref "=:" cword=$cword_ cur=${words_[cword]} prev=${words_[cword-1]} From patchwork Tue Aug 30 09:31:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BEDCECAAD4 for ; Tue, 30 Aug 2022 09:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231818AbiH3JfZ (ORCPT ); Tue, 30 Aug 2022 05:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231431AbiH3JeO (ORCPT ); Tue, 30 Aug 2022 05:34:14 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB88E42F4 for ; Tue, 30 Aug 2022 02:33:01 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11f11d932a8so6971484fac.3 for ; Tue, 30 Aug 2022 02:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=366MRLfEN1K0YcOvitZAbjQZyBNnkO98Yq9qZOv58lE=; b=S3e1tDr4r2CbSaOU7ComQm24X0NUAg0fm2XbSzgp/YRkOuFBbLAe/qTJCqF+AjyaoI Ip9hAOr43r/6j1A1rHBHCEjOJo7IXvbI5HN6WBJVa6mrKBauJLxKCiFm6BystL/Ltag8 669FMUePw8LI7tUfdvIjlTGSq9PzChRAYMoMdH3OaURMfpikgnuBg9tzp+HwKzUCQ3wM FwofSZJsAoTx47CtDR36d2UaL/AVjgO+zWsh5v4C/MSuxWqx98hbQdEOe8HxQjyEZU1L U1kxbX9XBJwXAutjkwpQvJy2EKFw4PrlZLLgZ9A0hUnnQWzyZXCdPjszZ2LHi7Zd4Ufm bLug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=366MRLfEN1K0YcOvitZAbjQZyBNnkO98Yq9qZOv58lE=; b=PsMc+Wc0yw4rXfOhzfPMuBh3c6mqA1CrSPA6nkuBta51eg6WWLnp+ppWCDnzs73Jly BckULkKutnzbwzAS78P98QfCk6xOJYFuVohSiFePbvW1hAYMYl2NFZ7k46rdgSa8A0Cl 7x7QbWJqRZlGJExHtUqNfxb8ijRfK/C1a/IdEqhtrbCvDv2KQE9DDDCSI7JfrGIL/L9u 9rwRK4KLI6lpFGoLk+kj1I8YmnpHreTr5B+PzxCfj8ZphtTAL2VYaN4JvrQ49BTBQsjr KntW2mdeXe+QOkgn8y0+tocznuPNZFbfieZKUtTPlwCfSOrO4aTj0inV7i0/YroYEXg5 J6rg== X-Gm-Message-State: ACgBeo3UME5Pm61vwJAffpkOgZWr9Q53GTrq8zUSa1lOcDYqkJb2T1fd cGibeEV2unT+4ubEMJ/CdjNmM35AtmY= X-Google-Smtp-Source: AA6agR5V8/v+WClTUF3qCpKirOREpwpCisJNF8RKghXdNut9NeaXr1jVDOm5SbYqHbsnkWnR+xBXpQ== X-Received: by 2002:a05:6870:783:b0:11c:7d1c:6ede with SMTP id en3-20020a056870078300b0011c7d1c6edemr9420001oab.239.1661851981307; Tue, 30 Aug 2022 02:33:01 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id n14-20020a056870034e00b0010e046491f8sm4852900oaf.57.2022.08.30.02.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:33:00 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 47/51] completion: bash: cleanup _get_comp_words_by_ref() Date: Tue, 30 Aug 2022 04:31:34 -0500 Message-Id: <20220830093138.1581538-48-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove temporary variables. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 4261143d97..92831977d7 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -355,14 +355,13 @@ __git_dequote () if ! type _get_comp_words_by_ref >/dev/null 2>&1; then _get_comp_words_by_ref () { - local words_ cword_ local exclude i j first # Which word separators to exclude? exclude="${COMP_WORDBREAKS//[^=:]}" - cword_=$COMP_CWORD + cword=$COMP_CWORD if [ -z "$exclude" ]; then - words_=("${COMP_WORDS[@]}") + words=("${COMP_WORDS[@]}") else # List of word completion separators has shrunk; # re-assemble words to complete. @@ -382,9 +381,9 @@ _get_comp_words_by_ref () ((j--)) fi first= - words_[$j]=${words_[j]}${COMP_WORDS[i]} + words[$j]=${words[j]}${COMP_WORDS[i]} if [ $i = $COMP_CWORD ]; then - cword_=$j + cword=$j fi if (($i < ${#COMP_WORDS[@]} - 1)); then ((i++)) @@ -393,17 +392,15 @@ _get_comp_words_by_ref () break 2 fi done - words_[$j]=${words_[j]}${COMP_WORDS[i]} + words[$j]=${words[j]}${COMP_WORDS[i]} if [ $i = $COMP_CWORD ]; then - cword_=$j + cword=$j fi done fi - cword=$cword_ - cur=${words_[cword]} - prev=${words_[cword-1]} - words=("${words_[@]}") + cur=${words[cword]} + prev=${words[cword-1]} } fi From patchwork Tue Aug 30 09:31:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0194FECAAA1 for ; Tue, 30 Aug 2022 09:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbiH3JfX (ORCPT ); Tue, 30 Aug 2022 05:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231880AbiH3JeO (ORCPT ); Tue, 30 Aug 2022 05:34:14 -0400 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 945E6DFB6E for ; Tue, 30 Aug 2022 02:33:08 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id t11-20020a05683014cb00b0063734a2a786so7650783otq.11 for ; Tue, 30 Aug 2022 02:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=nGOuhaWOxo9xvzPGIKz68/nwuj1uDPNLb+Uj048LwjY=; b=av4MxFMJmfiQ1yJoIUxzn7cDJiGxtBd5kQD4K0T/e/hPR94iv/wzKm11+mue8uUefs G4+unDd5aZqwjQbTT0ucXJ+t2zETvNx0GmRBY/zgJc4EOy0cQ937gKnmHBZJpmJmEA58 VDz9garliVv4Jod5VwCx5lzlt5nvJPKMxdCqeGyqq1Zpvpym2vW8Cd9CxmOqsJCBaB6N h56JdUu8+myo52G+1ri02xRKNyx+1AwqmS/Tvz9Ef5bfgd6kw8P6ztl+WfxHlBigdc/l PQ3ZAaZmu/D6hJCIJVypT8IyFhpFx7eE9dHowJYjwqu1qGkuAb/g55C4bu+YhALG7DB4 /shw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=nGOuhaWOxo9xvzPGIKz68/nwuj1uDPNLb+Uj048LwjY=; b=sN7BLTymYX8JWbJAsKliQCyB7qCv688ngIvhZKCZxFfp9tHWvZQuFxc7tMVsjNrWss ihstMhIVKSferVhwV19tQuR0+DgAXcSD0QM4CAZphEz67WeDkgtUyp9ZBHEjd3jmrhq4 ELxlrUl79+tQxGUxCsxPMiiChRIVorV18Q2Pj8G59KSWyyK4v7/V4iu6VmCcfdFSxiVi rIk60WBp2iJ/zXLRLGpPdDIWGlL8mmai/sbSQU+2JMlFSSPFWxkKIkiBvTTLVxUXMKga cguEwa4FZBr+pYp6/PtvxmYASIkyCGdUDTdbEG92VfkNh9xy7dK9YXJALYvJ9K9jR6W5 q0Vw== X-Gm-Message-State: ACgBeo1Vfx33DEKyt4hffJHjYo/xE6pFpgao3C4AEKKDy6TdzfjUUbDo IMyyq7MaeyqoG6q03l/qWYnJUwVq+30= X-Google-Smtp-Source: AA6agR4ws/PJKYn7YOvylZqWpCnQkzzSAm2zmadrl3RiukCE228BTzX4mmDSkpWbe71/7f66fqtZEQ== X-Received: by 2002:a05:6830:3153:b0:63b:3f5:59cd with SMTP id c19-20020a056830315300b0063b03f559cdmr5973901ots.129.1661851982915; Tue, 30 Aug 2022 02:33:02 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id e6-20020a05683013c600b00638ac7ddb77sm6876703otq.10.2022.08.30.02.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:33:02 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 48/51] completion: bash: trivial cleanup Date: Tue, 30 Aug 2022 04:31:35 -0500 Message-Id: <20220830093138.1581538-49-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The most typical case first (COMP_WORDBREAKS contains our wanted words). Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 92831977d7..395a356106 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -360,9 +360,7 @@ _get_comp_words_by_ref () # Which word separators to exclude? exclude="${COMP_WORDBREAKS//[^=:]}" cword=$COMP_CWORD - if [ -z "$exclude" ]; then - words=("${COMP_WORDS[@]}") - else + if [ -n "$exclude" ]; then # List of word completion separators has shrunk; # re-assemble words to complete. for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do @@ -397,6 +395,8 @@ _get_comp_words_by_ref () cword=$j fi done + else + words=("${COMP_WORDS[@]}") fi cur=${words[cword]} From patchwork Tue Aug 30 09:31:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EDA6ECAAA1 for ; Tue, 30 Aug 2022 09:35:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231558AbiH3Jfq (ORCPT ); Tue, 30 Aug 2022 05:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbiH3Jen (ORCPT ); Tue, 30 Aug 2022 05:34:43 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB76CE42D8 for ; Tue, 30 Aug 2022 02:33:11 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-11f0fa892aeso7095327fac.7 for ; Tue, 30 Aug 2022 02:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=1RE2RSEEhghTXbkXOzED//6m4mPFHl54s/c/PBl1dFU=; b=QHLceer1LM20xD/Tj/MDUoKtfxRfprqS9XAwy5TzXdkproKmfSnK6t6NqRWnVWVi8i MaN9GWrESeFDDGRxXVXV9lmCvjPwjdgL9ECzETfm/vzdVLpmz0INVnRhY+3z64r/h8W7 V8d5mfKEKAIbNDqQa7E0vsGma4VH+avA0WHsRPyoR8Yf9RqPSRCYzdojBTxlwZtCfZYm EROmvdcZ4puh6UykGku5L7cLCzgqUZn9UzG8N95+sqz3/dBMvw2Rbw8ZwVgMQDPS7GG5 zcKFW7t4hzsuesJoWis9+h/FDq2Yo9ygpivTIo+P7NZcmM0shvseT4TEG95sxzQFhTJc BmPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=1RE2RSEEhghTXbkXOzED//6m4mPFHl54s/c/PBl1dFU=; b=1aIUMo/SFYbe5IDjLoY6OwVYkJ8uz94GyPjmHF8MrpzvWy3aQOxlF0xAGwSWzN4FEO OTjtythbLvaRZmTIUsnAoRIqh+Z6d2TIo8pvdBr3yEAZGoegCIFeZV8eIUyown3hSrl6 U50ybLx4LKCCdBDN0IBi0KwVH0Lja8qen3fUX6CUexh2ooSTMPrQmUM3f3DI/HtI6rvL h6pQG2pYRmlp4bBHhu7n7WBU+NE/e3DjXCRYqSgYEW0zAdc7Y/2TmkNp8ukR+cTf+uld sUBdROUCvCXhoJG5KMVO/ejzQZq7lt2JGZF+xmS8YIL2UYifNR4rM2+PcJLgOzWzMCj3 hLlg== X-Gm-Message-State: ACgBeo3bb4e5Sd6dcdDeAaUH5kMw3QZdUQyMSITNcEIK1z1DU/CUccBf FlzPXpYmTIT14NtISxvm9HHdkoUAi3Y= X-Google-Smtp-Source: AA6agR5dhMRPMgwwDZHe8G6FsCHsaREzXgV3dzIiPOQ2001YJDMxri2jjxWHV5Wrd6bFBD2wlCav6g== X-Received: by 2002:a05:6870:51ca:b0:11b:98fa:432b with SMTP id b10-20020a05687051ca00b0011b98fa432bmr9790535oaj.109.1661851984415; Tue, 30 Aug 2022 02:33:04 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id o32-20020a05687107a000b0011e37fb5493sm7583570oap.30.2022.08.30.02.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:33:03 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 49/51] completion: bash: rename _get_comp_words_by_ref() Date: Tue, 30 Aug 2022 04:31:36 -0500 Message-Id: <20220830093138.1581538-50-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's only used in one place, rename it, and use it even if bash-completion's more inefficient version of _get_comp_words_by_ref() is available. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 186 ++++++++++++------------- t/t9902-completion.sh | 2 +- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 395a356106..77a475e272 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -312,98 +312,6 @@ __git_dequote () done } -# The following function is based on code from: -# -# bash_completion - programmable completion functions for bash 3.2+ -# -# Copyright © 2006-2008, Ian Macdonald -# © 2009-2010, Bash Completion Maintainers -# -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -# The latest version of this software can be obtained here: -# -# http://bash-completion.alioth.debian.org/ -# -# RELEASE: 2.x - -# This function reorganizes the words on the command line to be processed by -# the rest of the script. -# -# This is roughly equivalent to going back in time and setting -# COMP_WORDBREAKS to exclude '=' and ':'. The intent is to -# make option types like --date= and : easy to -# recognize by treating each shell word as a single token. -# -# It is best not to set COMP_WORDBREAKS directly because the value is -# shared with other completion scripts. By the time the completion -# function gets called, COMP_WORDS has already been populated so local -# changes to COMP_WORDBREAKS have no effect. - -if ! type _get_comp_words_by_ref >/dev/null 2>&1; then -_get_comp_words_by_ref () -{ - local exclude i j first - - # Which word separators to exclude? - exclude="${COMP_WORDBREAKS//[^=:]}" - cword=$COMP_CWORD - if [ -n "$exclude" ]; then - # List of word completion separators has shrunk; - # re-assemble words to complete. - for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do - # Append each nonempty word consisting of just - # word separator characters to the current word. - first=t - while - [ $i -gt 0 ] && - [ -n "${COMP_WORDS[$i]}" ] && - # word consists of excluded word separators - [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] - do - # Attach to the previous token, - # unless the previous token is the command name. - if [ $j -ge 2 ] && [ -n "$first" ]; then - ((j--)) - fi - first= - words[$j]=${words[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword=$j - fi - if (($i < ${#COMP_WORDS[@]} - 1)); then - ((i++)) - else - # Done. - break 2 - fi - done - words[$j]=${words[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword=$j - fi - done - else - words=("${COMP_WORDS[@]}") - fi - - cur=${words[cword]} - prev=${words[cword-1]} -} -fi - # Clear the variables caching builtins' options when (re-)sourcing # the completion script. if [[ -n ${ZSH_VERSION-} ]]; then @@ -3477,10 +3385,102 @@ if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then return fi +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald +# © 2009-2010, Bash Completion Maintainers +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function reorganizes the words on the command line to be processed by +# the rest of the script. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude '=' and ':'. The intent is to +# make option types like --date= and : easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. + +if ! type __git_get_comp_words_by_ref >/dev/null 2>&1; then +__git_get_comp_words_by_ref () +{ + local exclude i j first + + # Which word separators to exclude? + exclude="${COMP_WORDBREAKS//[^=:]}" + cword=$COMP_CWORD + if [ -n "$exclude" ]; then + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words[$j]=${words[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + break 2 + fi + done + words[$j]=${words[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword=$j + fi + done + else + words=("${COMP_WORDS[@]}") + fi + + cur=${words[cword]} + prev=${words[cword-1]} +} +fi + __git_func_wrap () { local cur words cword prev __git_cmd_idx=0 - _get_comp_words_by_ref -n =: cur words cword prev + __git_get_comp_words_by_ref $1 } diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index fc09bafa07..fff8451716 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -38,7 +38,7 @@ GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase' # We don't need this function to actually join words or do anything special. # Also, it's cleaner to avoid touching bash's internal completion variables. # So let's override it with a minimal version for testing purposes. -_get_comp_words_by_ref () +__git_get_comp_words_by_ref () { cword=$_cword cur=${_words[cword]} From patchwork Tue Aug 30 09:31:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA40DECAAA1 for ; Tue, 30 Aug 2022 09:35:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbiH3Jft (ORCPT ); Tue, 30 Aug 2022 05:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231161AbiH3Jeo (ORCPT ); Tue, 30 Aug 2022 05:34:44 -0400 Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2FD0E2C47 for ; Tue, 30 Aug 2022 02:33:12 -0700 (PDT) Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-11f0fa892aeso7095436fac.7 for ; Tue, 30 Aug 2022 02:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=yQZUwlot2KcMcOVFaJfRif/9lhEQBesbqls2nqR2MjU=; b=OMJkUceWDPo+Pu0759moYZfhVyp2O07Sr59EUbW8Kcf44G6puh9snA+5j9nhLLOV67 jtvD4Ed6dGOVQZpFDdnactZSiVBadIPy2m3YjaUytjyPZpeisTbSZB8GJ0oqzI9YgMhs qmRv4kzi5+8TNjNJo2F6ExUp4AqBlOF3jSXGJ6SIsE+AudqcjI2mtnws+/ooAErkl0Xw xvdEsVZs/H+ihRL/kHxIZuRahtVvV0G891zmhGq1TpsHpONtppgHVTvn75vgHkycS/qU zDNYc2LDVWhojDB5KJ8xjQKRiuFZD8vCxIOF2yjgq/fTL6FxQID2nvvuSFeU42l2Qc+Y 6uGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=yQZUwlot2KcMcOVFaJfRif/9lhEQBesbqls2nqR2MjU=; b=ZECHqQ0gzCh07vJ9oxse+Y7x+h7Fa7K/jH/gkYAbJYcgkgH1CZadUCqCMf8YgkkvcF SfgelGrkLp7KcMaE1LIqrqWrnQGqeNhsurPhhObyblW903bmmce+o7MDZddQ6AArkkN5 deWM3zuebtIZ6rkbTM9Ya0EQwc4gzNxtYVGI7gXvjnylQWtSqhbXSHo2h7Vn1F5j4kUS zApyUh2NHWIFtFeFxQwFaMAT2GRa577sjyljifzIQxLYhTFHKDMPe87KLbaRMp1gkvmc lLrmJzDBaoDsHu6f8k6eKgsKpupBSmoKR2mrleAA6sVJk/b7RS+KrcG2KHs9Sup6t1KA 30UA== X-Gm-Message-State: ACgBeo0sEwYPACWmOtg6fH33xCF73cCt8XJDrU3kAiwV2T/FQB/K09qy 47CekPV48RLEhNKqfk2AiNJfe2lwXqs= X-Google-Smtp-Source: AA6agR5YlYHLMRl5/zbn2W6jih21GHLhLKnNrYTAo21HiBxzOG857iLSq1Zs2SWoylXTwj00jRbnRg== X-Received: by 2002:a05:6808:1487:b0:344:ad43:fe30 with SMTP id e7-20020a056808148700b00344ad43fe30mr9227859oiw.258.1661851985772; Tue, 30 Aug 2022 02:33:05 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id r18-20020a9d30d2000000b006370abdc976sm6982864otg.58.2022.08.30.02.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:33:05 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 50/51] zsh: remove version Date: Tue, 30 Aug 2022 04:31:37 -0500 Message-Id: <20220830093138.1581538-51-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Doesn't seem to be useful. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 7d34522621..31bf88c1c5 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -118,11 +118,6 @@ __gitcomp_file_direct () __gitcomp_file "$1" "" } -_git_zsh () -{ - __gitcomp "v1.1" -} - __git_complete_command () { emulate -L zsh From patchwork Tue Aug 30 09:31:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12959009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 766CCECAAD4 for ; Tue, 30 Aug 2022 09:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231789AbiH3Jfx (ORCPT ); Tue, 30 Aug 2022 05:35:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231905AbiH3JfF (ORCPT ); Tue, 30 Aug 2022 05:35:05 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69500E68D9 for ; Tue, 30 Aug 2022 02:33:13 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id 92-20020a9d0be5000000b0063946111607so7658442oth.10 for ; Tue, 30 Aug 2022 02:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=44HHDgpUjqwYn97esXWH6mQcjyhG45ZoEdWVWlQwTc0=; b=M/NApWUpEtt5BV7qobLEFJgcZ71PTP/n+8A+Pkcv6A1ivtz/AM1UfxMnUGfMScCoSx Uh2XuvXBxC2ZfKRKU5rI2XfT6mmYrYUkxd99sIAafI+MtmngBx8QpOKvECI8b3uZm+B4 lHL9vftCc0SWnirfg48mjAPSC2Kj3Fozz2Cxsss9IKdoUFE7DUG3eu9+aehXACPpT7bD BVNCfuL66C0mF8fChR56a4HBDuAdXklDg8yvHukJgj2jmUeXVB7kbpfBjloohPp7fUFq cUq7iG6xfo+yPPw87isRuG4AU8tbmiKSZnQ36CstYT184HeVFakDIS3fg9hIJQcPTGwX hd9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=44HHDgpUjqwYn97esXWH6mQcjyhG45ZoEdWVWlQwTc0=; b=DlWlJR0t6umG7e0zGzEUxq7CvNEJzwhg2jdJltIXpEsdEF80K9lC50XwXobcMk9LFT kLpJGHLyCSD352fOZJ5nr6eMOaiGzUDheyzb3NokwW/OvjHhUZUj/j8Wnbcw5Vh1I44k wVnVZJacu5WyYIcRp67ozv8ywiLZX9dpL5Y1Qer0pQIz5xBASBE6cTmY6rPV8LuP3phU HKsvz/nui9jMvA8IivzagIm4jLCmwjV6ohReMzc/yc5B/hqjkA9xzI7IniNNq5i9L15c llM8Z6Qvn6ZGPUuT3F3h9TK+svhwk1pBmtgxv1ecOQs4x8kquQ2w6MkweSuUJA8FwWri A9nw== X-Gm-Message-State: ACgBeo3W0dYooxMtrSwBH5LRql9vKVYKQiEjfC4Ke3DF3WCMHoIG+1pk 811q1GXMtBEcZfwLjQ3glu3QLF1jmvw= X-Google-Smtp-Source: AA6agR5pd9OVDULK9sbXFYZda0QDFlGeViUkjMSdNiOV4PyDvXyeaowckB01gjb7rcMGix8UAGIomA== X-Received: by 2002:a9d:66cf:0:b0:637:1d30:d72b with SMTP id t15-20020a9d66cf000000b006371d30d72bmr7919709otm.35.1661851987351; Tue, 30 Aug 2022 02:33:07 -0700 (PDT) Received: from localhost ([2806:2f0:4000:eec:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id g17-20020a544f91000000b0033a11fcb23bsm5981649oiy.27.2022.08.30.02.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 02:33:06 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: git-fc@googlegroups.com, Felipe Contreras Subject: [PATCH 51/51] completion: bash: trivial grammar fix Date: Tue, 30 Aug 2022 04:31:38 -0500 Message-Id: <20220830093138.1581538-52-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.2.351.g9bf691b78c.dirty In-Reply-To: <20220830093138.1581538-1-felipe.contreras@gmail.com> References: <20220830093138.1581538-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 77a475e272..dffb34266f 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3152,7 +3152,7 @@ _git_worktree () # Here we are not completing an --option, it's either the # path or a ref. case "$prev" in - -b|-B) # Complete refs for branch to be created/reseted. + -b|-B) # Complete refs for branch to be created/reset. __git_complete_refs ;; -*) # The previous word is an -o|--option without an