From patchwork Fri Jun 18 18:24:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB8E5C49361 for ; Fri, 18 Jun 2021 18:25:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 976F161205 for ; Fri, 18 Jun 2021 18:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235295AbhFRS1d (ORCPT ); Fri, 18 Jun 2021 14:27:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235291AbhFRS1d (ORCPT ); Fri, 18 Jun 2021 14:27:33 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F3ADC061574 for ; Fri, 18 Jun 2021 11:25:22 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 102-20020a9d0eef0000b02903fccc5b733fso10576106otj.4 for ; Fri, 18 Jun 2021 11:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LqhGhJ3dwbZy2ZYi1T3oIsD/xWQ5m9t5eU0uf2uOB4w=; b=l0YukYYT259odO+SSssczAEV2JJE14LgTd7J5aAjbKdMTUHjzNWQapN+UbFgYOxSbA vKEPYJyPrOK8nHvFtCRkIRTINsujKiWJBmpTuoykaEr0A75ms2Ix3BSpNOcYjGtfpsdu kgjD3X1ZmINCB/+r+IoXV5LYpXHG6JgsuNEC2RbNW2JjmVMxCL4eESidY2hvTaR5ggg9 0zsQBetzf8b6gkc+iILeXBtjCsH1mjzSVQR9E06UduzJ7CQuRHYWmoynl8nrBUrh/CTO WDbqa9b53XA6z6Tzn0Dvh78i0AnkhuMNY7L5Lq0DTIiQtmq+8I+RLZeK/u7+nPRkGAg1 DL0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LqhGhJ3dwbZy2ZYi1T3oIsD/xWQ5m9t5eU0uf2uOB4w=; b=gjCcNAl3PqVsazNTVZYw/LL8OU14QmX8i1DqOcfo1ZYnjwG1HUvJjMZRB3IYWG3GVJ dj1LYrERlp4zoQNNmKwa6aQM5L5gONXn0Rp3dm5qc4zlD2YXNvFAa5FGgmiqnJ+ZXKv/ HuzY70WMkGDzbm+Wh1A52/xocnKHnGbFLMGNExZKIg5w9F1NvWHYULO5x0Ma2oeiCaID DNtcXbgz3H74ZEdBDaPFysNZ2vkAbbhFg47cOXHp2qoe0wAIbbgxvq2qeqwVZuaSBxrf Mho7OphYd479QX5ZddfgblRiI/gkyxXwc0djio8qCOanChbTG/giLGrXUihAV3fU1g46 +BQw== X-Gm-Message-State: AOAM530m5RXKZlOZrQSSfew34bAI8P8CIIUaDslowRQn3LPIHFc8JP/7 tNGOPZtz9y40wFiyFv8aFt8lRHe2QLSgLw== X-Google-Smtp-Source: ABdhPJxEGWf1f4+OGed4tamGrrBdtunG60vc63LuVMMxBqZYL/cOLfi2kXphZrhWMD9wpq0vrREb6w== X-Received: by 2002:a9d:730a:: with SMTP id e10mr10471102otk.97.1624040721764; Fri, 18 Jun 2021 11:25:21 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id u17sm1072705otk.15.2021.06.18.11.25.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:21 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras , Harrison McCullough Subject: [PATCH v2 01/45] completion: fix __git_cmd_idx regression Date: Fri, 18 Jun 2021 13:24:34 -0500 Message-Id: <20210618182518.697912-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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. We need the function wrapper to define __git_cmd_idx. If the function wrapper defines __git_cmd_idx, then it's not necessary for __git_zsh_main to do so. Reported-by: Harrison McCullough Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 2 +- contrib/completion/git-completion.zsh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b50c5d0ea3..52a2d283cd 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3511,7 +3511,7 @@ fi __git_func_wrap () { - local cur words cword prev + local cur words cword prev __git_cmd_idx=1 _get_comp_words_by_ref -n =: cur words cword prev $1 } diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index cac6f61881..02ffeae768 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -251,7 +251,7 @@ __git_zsh_main () done ;; (arg) - local command="${words[1]}" __git_dir __git_cmd_idx=1 + local command="${words[1]}" __git_dir if (( $+opt_args[--bare] )); then __git_dir='.' @@ -271,7 +271,7 @@ __git_zsh_main () _git () { local _ret=1 - local cur cword prev + local cur cword prev __git_cmd_idx=1 cur=${words[CURRENT]} prev=${words[CURRENT-1]} From patchwork Fri Jun 18 18:24:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D196C48BE8 for ; Fri, 18 Jun 2021 18:25:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56243611CC for ; Fri, 18 Jun 2021 18:25:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235400AbhFRS1f (ORCPT ); Fri, 18 Jun 2021 14:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235291AbhFRS1e (ORCPT ); Fri, 18 Jun 2021 14:27:34 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40AD4C061574 for ; Fri, 18 Jun 2021 11:25:24 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id m137so11510280oig.6 for ; Fri, 18 Jun 2021 11:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NXvZEFQ5vNwDyNTJA7wlb/08fcKoPo2L8hb6fPqpoXI=; b=VwNRXYdA5w5d6llxN33CtzOBk7iqtyr+2tjNwLfRRUtIr//D0Kwq7Cei3PppdSI+cz ZT8zL8YH1phpB2uplZktGUMqccLmq481lJTKhegDGbVUcLfNbQ5doSaiidHX65sLeZA9 P9RcEpm8pVj25i1gJRSYHLfwHW0cfsQFr7Lk8zqQOaB0JF5sEb0XhLunj2NlZKyXFtjY Df4CwH2hgI3853/Zh6v8myfAtuEBzC1NrcQ65/ypSMDBFjae/gXvgGcFSpD/M+U8sSt5 6vxyC8toR58IwboyT6T0P1kEzKMZmrhS2R962YMVeLxyG2ykVPqCdwqJkRCD2WrmBPMv Ifnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NXvZEFQ5vNwDyNTJA7wlb/08fcKoPo2L8hb6fPqpoXI=; b=LQKzXVciVFBJY3qXUSfoR/mcuS5boOk+VTr2E0CMw+X6JnLpZDQLw7Y2U/npG+IeLZ lsPLz83eS01ikEuV6unMQNfdHWiY037H2pAu/BBLIQqAOnQ/wFLgvJAYo+JZSi7TJCb7 hCjIz9pmvlqOUKaBWxR79vYeUIRG9TkhD6tZOFv00cpXIjctWGE0LW1Z/0PxmR2cM2jT To7Zd41r7Sx0EMhZIYGhOm6yJqi3Luz/MwDLqjoMcQJQ5k3Fj2VknCHBwzkZBRjlsmEh GU0NurcNpov+ywQR6Xgp4O+Pg9X/vpA+/UU4oEc4Mlz15H6W1p0Y9lGR0miTZCFK7Eli CeCw== X-Gm-Message-State: AOAM530IhA8Ib9V/kTieTwgJO8gdSpj01CQ2DXWjdXt5INAGOvOGcCIl iWFnGKgmi9TBjNZR80jIFVERyGdvTJ0exQ== X-Google-Smtp-Source: ABdhPJyh1jSIagOgNFatlCxTCiB4b7avaDrelTymeSSyEnqRW7pPog9Bu4vRmeF4tfyd1RxJd+ye+Q== X-Received: by 2002:a05:6808:2091:: with SMTP id s17mr14655302oiw.168.1624040723443; Fri, 18 Jun 2021 11:25:23 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id r2sm2164135otd.54.2021.06.18.11.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:22 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 02/45] completion: bash: fix prefix detection in branch.* Date: Fri, 18 Jun 2021 13:24:35 -0500 Message-Id: <20210618182518.697912-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Otherwise we are completely ignoring the --cur argument. The issue can be tested with: git clone --config=branch. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 52a2d283cd..f8a751c4ec 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2649,8 +2649,8 @@ __git_complete_config_variable_name () return ;; branch.*) - local pfx="${cur%.*}." - cur_="${cur#*.}" + local pfx="${cur_%.*}." + cur_="${cur_#*.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx" return From patchwork Fri Jun 18 18:24:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB510C48BDF for ; Fri, 18 Jun 2021 18:25:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90A5D611AC for ; Fri, 18 Jun 2021 18:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235406AbhFRS1i (ORCPT ); Fri, 18 Jun 2021 14:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235404AbhFRS1g (ORCPT ); Fri, 18 Jun 2021 14:27:36 -0400 Received: from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78D10C06175F for ; Fri, 18 Jun 2021 11:25:26 -0700 (PDT) Received: by mail-oo1-xc2e.google.com with SMTP id z14-20020a4a984e0000b029024a8c622149so2666633ooi.10 for ; Fri, 18 Jun 2021 11:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H8ViT1a/zqKiojpB5G4WppcSJxV2adG0dDvrwDmAntU=; b=bW7NLZ+LhWX11jn2R/5P/qbT3Sl3W/ULodARSnSUPBhfIg3a3t1k0i1gGqRFIF9Ji/ Z4uRAqsO3Cob2Zp+pNHMd0yIWOF/owrzx0jkBGTQRT92NGkXc4YzUm8bI8uDRfKIS4YP ytXSWu0sAbnn+6H75nK8hGpiXAg549HTcuNcx0q0Q1/y3BHagsZMocW0AMmodjrP2OqP sWx07jjy8AVKkDaEniKdKPagJ5YezWBSVsGmSLTWwHANGW7N6B1Kzv7Uv+t2vs0bcmvn vlBIYwzIo/EOlDPPiMdIBiyDkgisVAcfqySMH3CzJ+ITx+ODoviCNtsMEbptaNbpapKf VSJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H8ViT1a/zqKiojpB5G4WppcSJxV2adG0dDvrwDmAntU=; b=oCqahf8FmK76SRooxvfODdO3OFUefOWEqofCB7lwd+g2i/JRzqqNx4aVLsW4Cw3xSW mV7BfBMjvgttd4G7ER0gHAIVZRrhCFFoOA3IgcED7Q4fiHjXX5ck0O27NiWBxCvfgH8C pb+tgyaN/v3X83+mHSf5DqxGdGHgJeAyiiaghbUlHHWVE9LDlwHw6Xm32INjBAD2P68d iczydegqDL2LJPC9ws83mYdd6CW4+pOoN2JBPs+5RhCSzqTrj3y7nivfLM3Vgw6cAzpr ZilHRrfra5tiRDZMcPtm9MrJMdlqSCjgcxE00oVnk/RGBGczYHYhmsGNwPkSbspOrPqB C54A== X-Gm-Message-State: AOAM5324iHhNOa6aClqzHVu/S02oW8UjXwZDLAooztZO/QzNASHLfPZP Y9sAbzrbhzoXXZ0cKQh9qQqMw5D5XRALug== X-Google-Smtp-Source: ABdhPJz2htUAGLCaV5L7kUPYyVDCTTCHrLNxOANff2NndEGxKCj1P2/Dnn7rErTFpPjBjvIxA7Tmvg== X-Received: by 2002:a4a:c190:: with SMTP id w16mr10166020oop.92.1624040725309; Fri, 18 Jun 2021 11:25:25 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id a74sm1936629oib.21.2021.06.18.11.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:24 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 03/45] completion: fix for suboptions with value Date: Fri, 18 Jun 2021 13:24:36 -0500 Message-Id: <20210618182518.697912-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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.bash | 2 +- contrib/completion/git-completion.zsh | 2 +- t/t9902-completion.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index f8a751c4ec..80b7c3eda8 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -356,7 +356,7 @@ __gitcomp () local cur_="${3-$cur}" case "$cur_" in - --*=) + *=) ;; --no-*) local c i=0 IFS=$' \t\n' diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 02ffeae768..4a4df3b37c 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -55,7 +55,7 @@ __gitcomp () local cur_="${3-$cur}" case "$cur_" in - --*=) + *=) ;; --no-*) local c IFS=$' \t\n' diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index cb057ef161..6b56e54fc3 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -540,6 +540,15 @@ test_expect_success '__gitcomp - expand/narrow all negative options' ' EOF ' +test_expect_success '__gitcomp - equal skip' ' + test_gitcomp "--option=" "--option=" <<-\EOF && + + EOF + test_gitcomp "option=" "option=" <<-\EOF + + EOF +' + test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' __gitcomp "$invalid_variable_name" ' @@ -2380,6 +2389,12 @@ test_expect_success 'git clone --config= - value' ' EOF ' +test_expect_success 'options with value' ' + test_completion "git merge -X diff-algorithm=" <<-\EOF + + EOF +' + test_expect_success 'sourcing the completion script clears cached commands' ' __git_compute_all_commands && verbose test -n "$__git_all_commands" && From patchwork Fri Jun 18 18:24:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5238C48BE8 for ; Fri, 18 Jun 2021 18:25:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85BD2611AC for ; Fri, 18 Jun 2021 18:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236291AbhFRS1o (ORCPT ); Fri, 18 Jun 2021 14:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235781AbhFRS1m (ORCPT ); Fri, 18 Jun 2021 14:27:42 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ACC8C061767 for ; Fri, 18 Jun 2021 11:25:27 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id s23so11483079oiw.9 for ; Fri, 18 Jun 2021 11:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rIj5VHjfncGl08rsJXzX8Ox1qBPz3MsC2VSU9ACiJTw=; b=q5G8UdJ6REIYf6G07CJjeKLJnFrxQLB4Cvr1jFiV7dZhDuEMrH+obkvyWXkocvy3E4 BgCQP9EPcQ/HBJ91V+j/ODUbauuvWMU89JfvT2Euvi8Bg4fUzYl2BnEDd5EKhPsffyr6 UrVLCKNMM5Qxmko2pNZj2LtJCHWnTc2ZCuTHSY5DtzESrSRxQBoahDjCjRDCqDSCE210 ZTtAt07vxSxs5+aKrJkF5lbU1sxzt5Y3HQztUtd04yS2vbchlvFZFLyp6051ZmjsDc/t MehYWFAiF52bsWSJ0lGd5PtI1H6CROiqzXpKzBWZo8jFFgV/SzZBwn9n9R2oxKpyOs3q Nymg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rIj5VHjfncGl08rsJXzX8Ox1qBPz3MsC2VSU9ACiJTw=; b=XIh0eoIKDm+hjEh4ocVZu/yqqGbELajNr1F0DnvpOsYdTBjF1g6ltCHWIfVSCAED5i 2gYkb7XwwThJqbuxHq4v+t01qZ9I916ymBSQihDIvy0zXZj498KvAIk90zrPo27CUviP 5XCi+CFbSZAfEjWfoQuxI5ILlMgSmViHq1J6bFxyg8ldqEZIc5ov6AfxaRrdgbuOcup9 fZVDu1dnvIf9yfolYFfqV5BUQDv0EOPTTc0EuZ0PcMf81jhANZhdrics5wvJQdERhgQd cAU1ATqMWMpnBRvAGuts9n1wIH7aeksyKq3Ltjod3Otw26oCCOLXAm4HgzgPdqVYE3/Z TttA== X-Gm-Message-State: AOAM531fJu/wtFldyjkMbL55cg/pRdXrKyguziOCKjOhWhovtN8z1iA0 bAWeL1YgPSRwJzchMMhCU6WuFGPpWyQzwQ== X-Google-Smtp-Source: ABdhPJx9me5cka0tEA9tNs2jnyzfboErGROdjSmmHTRiuaeX7dzYnIPOBr7zGQL1sRqm9CsxlvG1yQ== X-Received: by 2002:aca:4f52:: with SMTP id d79mr7932133oib.39.1624040726843; Fri, 18 Jun 2021 11:25:26 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id l24sm1910159oii.45.2021.06.18.11.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:26 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 04/45] completion: bash: fix for multiple dash commands Date: Fri, 18 Jun 2021 13:24:37 -0500 Message-Id: <20210618182518.697912-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Otherwise commands like 'for-each-ref' are not completed. 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 80b7c3eda8..279d2d8b1e 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -421,7 +421,7 @@ __gitcomp_builtin () local incl="${2-}" local excl="${3-}" - local var=__gitcomp_builtin_"${cmd/-/_}" + local var=__gitcomp_builtin_"${cmd//-/_}" local options eval "options=\${$var-}" From patchwork Fri Jun 18 18:24:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AB92C49361 for ; Fri, 18 Jun 2021 18:25:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A5A9611AC for ; Fri, 18 Jun 2021 18:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236294AbhFRS1o (ORCPT ); Fri, 18 Jun 2021 14:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236267AbhFRS1m (ORCPT ); Fri, 18 Jun 2021 14:27:42 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49E52C061768 for ; Fri, 18 Jun 2021 11:25:29 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id d19so11490687oic.7 for ; Fri, 18 Jun 2021 11:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PsbGwDkf3idFtPb96JeWlgNo04btzfemkzbKkJAjcoc=; b=r73eR/mZuijBKBk5InxGy/GowKHwZqVFFnSu9hAMC5L+6x7HZ8xdw9Kzp8GGj5qOU9 GDUGcq4DHvzghlVx8RuOZzrMzC6mj9RsIq3UTCd3xIS1V56YaYcBOa0ED60iaDWV27UF jtiELqAZf2MeOsCd9uyTypEi3BXi0OygZ5eoh7vr9La5dkvp2YvGtY80s85/Drv2I0xY 4SUogZQpPvZzHg7cW+2cT0DBJzDteWQbdt/rbj9CQ1pDiq5JIHp57Lvzv32Sz75a00P0 I3H+eG6THFX1Ni+vWR6EliCcaC/dY5GH3bQsK7KPC9YaXVKzLDis70myldD51Fg4MSnS V2gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PsbGwDkf3idFtPb96JeWlgNo04btzfemkzbKkJAjcoc=; b=Q1M158R3gHBhsAqZtJNCteevuCy5/h68BF8dNhz1lE5tUtHcp15XzFz/gEuyaieEtS 75m1XBDnuIYbfqgVtWf43swEaGqwUABq8f1ra3IkWXAjzsr9FbmEm4vYNUf6VmU6iFf9 7pA6Fw4UmcJypw+TrbtN6c2OKzaJOyhxAjLnDadREh8kX5fIoEn7tlte/w7jbkK+E2Wf htBEQo0hPSsnM4v8k0ufpeOUWgYa2o5knYuCo2lpXL+MxYcpZwJsok7Irr5ioQkNqNpQ peyO/bUGn0Eb2i0m1hReWg6R78kjiaG9Nfq7AMYtaDYnhiFNKEsaFScpjAZRKZzjXbzG UEug== X-Gm-Message-State: AOAM531qRZQuKVcqM6uNRgo4TRQbhQXTbzI6DN0EIZbC6WO1FVV1jJZz TMG85vT4OsV9H3KZI+gq66sxRucgiEznvw== X-Google-Smtp-Source: ABdhPJw0EIJIe5YV4msmKJj9UpYWHihqKNC4S7LnywE0cQeKKTgTHSgHF8OGby8kRQIPD/wsKYrPvg== X-Received: by 2002:aca:2804:: with SMTP id 4mr8035054oix.141.1624040728472; Fri, 18 Jun 2021 11:25:28 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id x29sm2104809ott.68.2021.06.18.11.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:28 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 05/45] completion: bash: add correct suffix in variables Date: Fri, 18 Jun 2021 13:24:38 -0500 Message-Id: <20210618182518.697912-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org __gitcomp automatically adds a suffix, but __gitcomp_nl and others don't, we need to specify a space by default. Can be tested with: git config branch.autoSetupMe This fix only works for versions of bash greater than 4.0, before that "local sfx" creates an empty string, therefore the unset expansion doesn't work. The same happens in zsh. Therefore we don't add the test for that for now. The correct fix for all shells requires semantic changes in __gitcomp, but that can be done later. 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 279d2d8b1e..943995689f 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2652,7 +2652,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_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }" return ;; guitool.*.*) @@ -2686,7 +2686,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.*.*) @@ -2702,7 +2702,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_append "pushDefault" "$pfx" "$cur_" "${sfx- }" return ;; url.*.*) From patchwork Fri Jun 18 18:24:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFCE0C48BDF for ; Fri, 18 Jun 2021 18:25:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EA1D611CC for ; Fri, 18 Jun 2021 18:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236297AbhFRS1r (ORCPT ); Fri, 18 Jun 2021 14:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236282AbhFRS1n (ORCPT ); Fri, 18 Jun 2021 14:27:43 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C83C061574 for ; Fri, 18 Jun 2021 11:25:32 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id w23-20020a9d5a970000b02903d0ef989477so10553941oth.9 for ; Fri, 18 Jun 2021 11:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+ZGt3UjCO90OHaCnDYTyjNMRhlOdjgO4FeS/J08wF5s=; b=QT/aE+2f65/WaJlyaWjkpj+yGWY5iI3TgGNUeuP+b47Yk9eahgFEk3x3E0KazEWY20 RHgxo2k2eW1/TCAFws/jfaYdZiCaWfK3mgsaoIICb2mQHZArvccFQs+prxRCYHHZ2dgR 4yUeOHkJe1S6LKUh6tftXvKlMY/o6K6ZSzMhvPoQgJZLKdIgXY29qFVz0BtXlo2sqEf/ cjSAZOIAY+m5GoCg9BEmYB1j2zpYmjbrlnIWFttW1oNB6Nap9P0oiWl+/o3NfICeimHk bEODkQPeZTJeSuGxW8PIUnbmd9hhmvC5/hUWspC2b+RBePoObphBSQ5dQNcbcsx/tr/Z MLpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+ZGt3UjCO90OHaCnDYTyjNMRhlOdjgO4FeS/J08wF5s=; b=B9FHD6a37IsxRw4FnUG2ZB3pvoeqeQPUCrRAqq5emotzFrjgVGF7sS0EF3S1/ZCNQE iGBJR9vXm5tAK07Fx4xvZKnh45Q7R5mNRfF26rxcEnIIRtACHaN9tXrYa6JsYjGGqhZl d5ECdfCgG6J3hI76kHp8bFXLQXpSvxAQF9LgBSVd2MBe7B4SPCdWQH+ypRZOk3Dga4VR 0oo/q8EWyjrC8DQ/HXcuJM5VRsiVfgd+fmkKlLEcwcBt/7bhpIPk65CqMZy5gzBLYJ66 2a1DR20ZhUzunRwELZk08F+7evZSLPBqt5rALQ+eXUI4X1vtwGb19bFpskip01x5s8Cj Czgw== X-Gm-Message-State: AOAM532+wShbjshS9p3RCvDLZ5NYScYmzlI2248ks91Ww/JhK/XScONZ xGBwYCDs3U9k1miMdbH+7TZN5gyClLzQbQ== X-Google-Smtp-Source: ABdhPJxvPqaAFJAy3NebDQpI2O7Y4qNRoHXUytl8An8j/o4MykgDiG5oZQipnmTYkEsPKzruMv7MTQ== X-Received: by 2002:a9d:5d11:: with SMTP id b17mr10777300oti.216.1624040731425; Fri, 18 Jun 2021 11:25:31 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id h193sm1953092oib.3.2021.06.18.11.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:31 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 06/45] completion: zsh: add higher-priority location Date: Fri, 18 Jun 2021 13:24:39 -0500 Message-Id: <20210618182518.697912-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 4a4df3b37c..da13c184d1 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 Fri Jun 18 18:24:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FDE0C49361 for ; Fri, 18 Jun 2021 18:25:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 062B5611AC for ; Fri, 18 Jun 2021 18:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236299AbhFRS1s (ORCPT ); Fri, 18 Jun 2021 14:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235781AbhFRS1o (ORCPT ); Fri, 18 Jun 2021 14:27:44 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 316B6C0617AD for ; Fri, 18 Jun 2021 11:25:34 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 102-20020a9d0eef0000b02903fccc5b733fso10576630otj.4 for ; Fri, 18 Jun 2021 11:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cUKZz0H1QBu/HTdhUngiScEYOBVU5tFVUWxaf7KEbOI=; b=eCyykaKyxMysS7m8g6TUkKfvChwX6MN2rTIDkWorx8UaE2CPEmU1KP6rUrMG9JnEkr j9HKO0iyufJTlDtJoD8f2gsCSH4x7UZfrbilf6HbRnWGT6npL7QUt8S6bPJflbtFUMYd xFiM5E6kug5NXeYRHTzQQCYH7fh2NyWQr7azqWepu4Ynvalw3Twcz+mmMuQn+6UKsEKb ktu3oEvh1OiY7k8+IrRz4E2TEIMCElQmIh7g6L11XYeuWRtxIeQiU0Dvz5vP9KhH+c6w SK5bINzIv/wt/vsU3D/H6ndOuLJi/vwwJIHvsbakIHZMaIRTF40i2NMC+k1iDPftvbmn 1A6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cUKZz0H1QBu/HTdhUngiScEYOBVU5tFVUWxaf7KEbOI=; b=n9whhy7JB3s0/DqHeQoeasOgqW+WOobV0aw97n/4GbYEsdkfUn9HEVSb5KlCrJEj9M Eyf/toPZ0q+q+2LmCyPU00xw77jJZz7eurXIZhs80cdGYf5LTtvliCastTBBTFFuQWhu EXmkIdkgUanFgQtszsZw8BoSRtJNsjhVER/Ddl9miT8xBSlWfmzpN/IGPo/RmMwfXjcu VgmRcPeTVvRypWv7oYrbcFR8TVF9xcTvIJWYQZjkBhLOwZfCPXJLFbKd6hDyGdjb0tFS Wmaq2Dk2yKOgvhTO6Eh1rhyeAvZCqgV4SAQt8B4PbwhtdHU9EzrommbfFBoNs2pBgZ0A Xiow== X-Gm-Message-State: AOAM530/75cHytgBN2ICc8TZ8Br5ZoY2DtVNn/o8n3lct46VzxDub+0H pWnJbVXlqz2gkd/AH7VkwoMxr6BOIGG9Iw== X-Google-Smtp-Source: ABdhPJwvt8yu0SsDQ/aVQzW1UdzgyS4XipmyDRWaQ15uIru4sq3KNaGr1yT7gCvXCEBhF/4OLDTjtw== X-Received: by 2002:a05:6830:1be6:: with SMTP id k6mr10551256otb.219.1624040733270; Fri, 18 Jun 2021 11:25:33 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id e19sm1952262oiw.24.2021.06.18.11.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:32 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 07/45] completion: zsh: trivial improvement Date: Fri, 18 Jun 2021 13:24:40 -0500 Message-Id: <20210618182518.697912-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 da13c184d1..9f0e03e86b 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 Fri Jun 18 18:24:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 850CEC48BDF for ; Fri, 18 Jun 2021 18:25:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6807D611AC for ; Fri, 18 Jun 2021 18:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236296AbhFRS1t (ORCPT ); Fri, 18 Jun 2021 14:27:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235404AbhFRS1q (ORCPT ); Fri, 18 Jun 2021 14:27:46 -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 B1B01C06175F for ; Fri, 18 Jun 2021 11:25:35 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id 5-20020a9d01050000b02903c700c45721so10582118otu.6 for ; Fri, 18 Jun 2021 11:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LRfU0FdazOvSRh5bUFkRqnoBSaUYu0K00H0qr8epigg=; b=qWvkCA+nHHRY5b0K/LzTRuYr04/7LJ8DYaw/TmeRqY1VUKT+NmIG0TOOMweEaIKv41 lVZDz6rq99yF18XmJhXrfRP7np6YXnv26uXyhivYqVpBgj7HTlfVEcw2WIiz5lkSWHHu lOaKeY1ilQ5tco0Wtr0SJKBupCunKI5so7hukePXjqNZtDh7cFtev9a0XAKACQSqGEkF f9RvP7fXAlJ8wmHiH/9xpZd32RmRaohaUzC1pVzRU85q5MIvbaXvdb4LgFKgwnBaRjOU c4km0k9svHo5vSNTbzKiYs6fiCRU0oMHvBIFylfI/RaQJTrAjZZd8eld8hJ5BfCKol55 MaJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LRfU0FdazOvSRh5bUFkRqnoBSaUYu0K00H0qr8epigg=; b=DVtLrfSw3lgrvUUHyouzwPlWP1S0DWrV48iJTZKLE59LVi15lAjDL3ijRIKkmO0Xst UbIb8+egyVjGTFdGwAGP2TPU3CuAluc7fw42L2krAOF8eNZ+HbU/hkJxgDh4bNUh7GUl Bfp0DUuZfEUXwUqjHkl7BaJaBtBf7jz9rGFbRSEYFREzCkOKryjjXTb7sGeDvzgDVlJG myITcpWkiOfof4Dz1faSZITfOdy13a12xw8JI01f46IA403yPF9iG9+B06nY/lyIPPHH quBmiqwMIVPyyitBvAZ2gfkOK50/m5wcl3V4YPt2ya3iDjcyaj8t3JmH+svVn2NRuuMa dZNA== X-Gm-Message-State: AOAM531Fb8SzFzWCFzzQj+vx7uS7EyaOHKfysio96Ga8O+9zAUaNnonf no2VH4b/+yrc3jsfRneidekeThbVDpMOmA== X-Google-Smtp-Source: ABdhPJyal4PrqPz3vcGARtJjou5CTBYsne6rwGsjSW9WrvYyeItLSvo23zqVfyPticoBDcZZWT0FUA== X-Received: by 2002:a9d:4b98:: with SMTP id k24mr10825014otf.359.1624040734929; Fri, 18 Jun 2021 11:25:34 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id u1sm1958187otg.17.2021.06.18.11.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:34 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 08/45] completion: bash: do not modify COMP_WORDBREAKS Date: Fri, 18 Jun 2021 13:24:41 -0500 Message-Id: <20210618182518.697912-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 943995689f..bede8a7e2a 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -54,11 +54,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 9f0e03e86b..5ddd2d6771 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 Fri Jun 18 18:24:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93BA8C48BE8 for ; Fri, 18 Jun 2021 18:25:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D318611ED for ; Fri, 18 Jun 2021 18:25:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236302AbhFRS1v (ORCPT ); Fri, 18 Jun 2021 14:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236287AbhFRS1s (ORCPT ); Fri, 18 Jun 2021 14:27:48 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB0E5C061574 for ; Fri, 18 Jun 2021 11:25:37 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id w23-20020a9d5a970000b02903d0ef989477so10554213oth.9 for ; Fri, 18 Jun 2021 11:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SKUdI/eXoS4KI0sXQ3uhGAKhlse6UmMtt7eTNP8YLRE=; b=nzNPLtMelNImxtFyM31EBJGx8xjaADwJEOfcfLOzAsiV2RjaxZHjWds6NZdIhSzi/R HFe5vM5CZe5U8unEgV3G8IDBaYDYbzrBuB+cQk24m7HGdHyN8oREF7Aj4tEBgxeBJhe6 c3ttDDRSbGaVBz3mN40zkU30akte6OHVFR61Ud4+2yjt42FGmI53fURqrAw/VPKmpRIw m+sytkydwo72fCBjQ+f4DYbCm7AxuDlBO95+rg+Lrkt00BjlBhO0TItA+5r1TeKc9e+i ApYtXvRJJvnXWEJ7sISAR7MTu5TZ/m+TuYAji1pZ/OVhy5mQWnbtyzDGubld7szLdp3I fxhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SKUdI/eXoS4KI0sXQ3uhGAKhlse6UmMtt7eTNP8YLRE=; b=X67pGcqIBMkACdqPf5qIQsjfFLxO/d3gzepjaO3OvkDhWu/k6xI2nfGHmmqdcbV6/x 8p8jNTOVoiBigSNJNMCBIOCDM0Ubd/79KmJkqZpn/XDMprzovuad80VTHeguuvrefRwq 73rIZ/6cyX5I1eC36mOv11eZJLGKM11afs1lDhGbZqCSXSkYfMOt9EDnbYvnMmblplUR hunNc3IA09Jwfd6pWy6aScr8/5aCZyKmKII/K2jZYvQBEqvvXuD3Ee8+YSp72d9VDlZo YdF6+YNn/V86RlzKRD/CZgiqdHD1sTqxEA/t4z7lcMZes8QVZOdtmMBn9ppBqUgEyRiR j9IQ== X-Gm-Message-State: AOAM532iVQlL0idTbyUJJ0dJqgClnrVa1xX1DjknUgeexfk+iEGwnuhc lKd6T9y0jbEQjIyZC6MWTnJtnhm75oe0pw== X-Google-Smtp-Source: ABdhPJwVTBlD4iijMt8gqZvzJb1JGDFy1ZV/IdC0mDiZgx7Wx/laKh+ziGXl6zUTWIxT6EfGxamK5Q== X-Received: by 2002:a05:6830:93:: with SMTP id a19mr10458662oto.17.1624040737005; Fri, 18 Jun 2021 11:25:37 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id p5sm1926529oip.35.2021.06.18.11.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:36 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 09/45] test: completion: fix currently typed words Date: Fri, 18 Jun 2021 13:24:42 -0500 Message-Id: <20210618182518.697912-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 change. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 6b56e54fc3..bffe1b0928 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -489,7 +489,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 @@ -497,7 +497,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 From patchwork Fri Jun 18 18:24:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A391FC48BDF for ; Fri, 18 Jun 2021 18:25:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BEE6611AC for ; Fri, 18 Jun 2021 18:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236298AbhFRS1y (ORCPT ); Fri, 18 Jun 2021 14:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235630AbhFRS1t (ORCPT ); Fri, 18 Jun 2021 14:27:49 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DE4BC0617A6 for ; Fri, 18 Jun 2021 11:25:39 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id o17-20020a9d76510000b02903eabfc221a9so10636968otl.0 for ; Fri, 18 Jun 2021 11:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0ggTZ1zBKFUmWxybCpPm5msiXL3W9D+UYilIBVeyoDQ=; b=GOySLJhGisa+WBFixNMgttyFKQmo31C7U+u7/9G8gvUZzSs0ADUduNqXzKMqK6OO/k odSD/yUxL8a/3pU7Xvkmd05Qaa3IEZwLKgrAlzNiN6qwvVI4lKZozhdF3KhEik9oqouB CuQmx8S4HpgLhRfHCgPBkfsx8k7japttxRJmjyJwJjCczkcZSMgI0EuY8SZpqVItgMJ/ V+ER8s6M7q6X4QdaUMXLsiR5K613citAusllKx/BWgLgio6qXavp1bCz4+8e+2N09850 z66T6Lmm0V/s28L5usllhTvb5ZjsqBantMzGIhdZA/EU4JTGZH5T7rxDAeLEXjCQkFx+ xztw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0ggTZ1zBKFUmWxybCpPm5msiXL3W9D+UYilIBVeyoDQ=; b=WEJ7JVlL+cvwAV9+6UgsrYc9BBCzT6RUYZE0NxGkmhGZKBYbOkfmlZF2OJSDUm9UKl 48gnH+r0Opixj7vuXnXtk7RhPU3AcKw17/OXwMylFHsbUjET8iSQunKc+r6d6xjqqGL2 A9JWy2bIQSv24Jla0rgHBis2twM3s3NppRlCUiS/smmeMjxJ3OM+jgCOJiniQyxyFVuI Zlio/NBxKFkCJ6Zcp1xTdug0Tm699agXC6dBTDZ3fR8CVaIjCtxagpYVYPzJmYvPq5ml 3ZlGu1J780m78yVxpvn6sxHCp5zFgQcmQ0H5VomVCk9p8oljrTCA6ME+gc5LeuNPPPS0 jXCQ== X-Gm-Message-State: AOAM531ZGcMe1d2Ykf01vGXEjSweFfi9n1bGeTKjkjef0sAKeu1GPTjw XsXanw/HTD6ePJy45m9JLG5Tf8CeI3pRpA== X-Google-Smtp-Source: ABdhPJwtEkepI0PU8DpL2Ho42cTS5Uq0tcgsgNaDgI+e/KVRlp24LOsJ9w0Omp4OllBWvhYapIEiRQ== X-Received: by 2002:a05:6830:1f51:: with SMTP id u17mr10598743oth.25.1624040738649; Fri, 18 Jun 2021 11:25:38 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id o6sm1180430ote.81.2021.06.18.11.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:38 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 10/45] test: completion: switch __gitcomp_nl prefix test Date: Fri, 18 Jun 2021 13:24:43 -0500 Message-Id: <20210618182518.697912-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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. No functional changes. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index bffe1b0928..d21dca4abd 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -568,9 +568,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 ' From patchwork Fri Jun 18 18:24:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64301C49361 for ; Fri, 18 Jun 2021 18:25:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4996B611ED for ; Fri, 18 Jun 2021 18:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236303AbhFRS1z (ORCPT ); Fri, 18 Jun 2021 14:27:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236304AbhFRS1w (ORCPT ); Fri, 18 Jun 2021 14:27:52 -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 3FD4EC06175F for ; Fri, 18 Jun 2021 11:25:41 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id v22-20020a0568301416b029044e2d8e855eso1374703otp.8 for ; Fri, 18 Jun 2021 11:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p02Z3d8avkruD7P/4TyjJlR1dmPLjE+yztJ/CH9AeWI=; b=B0NH4Vwi/JeoLqFLE0gqPTyO8LeujUezt0xmcOjlEIJrbljIdCi6K5BpXdkFXKbXfC DTtLfkxJbr2Avh1PgYwXBnG7axdzbwXa84BlkJVgJgN6B9VZa/vcMK+Dno/wFMUeBgQy uttMAEv4YODFiqIL3blDTQSEybbG5gvmHpxQoM3cN1D6JheYZ5Xfih/4S0glrUPRRlKs 6RgtelmXwtLb0t3xRVmGNA7r3st4WOaMuUmdJKtcz6vdWC7dF6wBhVEIvgvAq1hWh816 2/Vk7oNMA9ZhapjVH55JI6Yy1NXUAjBDeMYE6wMs8hRX2F4KL+5MSvsyQsVo6PfU5Nbt xd0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p02Z3d8avkruD7P/4TyjJlR1dmPLjE+yztJ/CH9AeWI=; b=q65BOtRcfWaU/cz3GmH25zeKOLk3wsZ9nyvRgs5BvCKJXbY0gBcyO3ivSp+FWx7zoU djlvQH3GU+u4JWvxWDY7ILQQiR9gc//eemOqep1ZJ7UK9q2Mq+VjJ3AI3x2Hnl+LNaF0 qrfbIs13UB2bD54ugpZzthycRTApMS91m83lbvi3sePbmlteeLHtoq52eFggCrAsYUgn DPuPtSutRVApFrQOrZqhpDCIhmyP7L0iil9C8SUINffNQLsrzMdaTe2kcKRo2BGQJYuV X87XqldiG76QPrh/w/cTHfXk/564oHHMtzVEG8YZOY0zj6l/oY1ZkpzIS5BxOGds/lAE EPJA== X-Gm-Message-State: AOAM5319gYQ6EGdVwDbVJ/MAJf9h3I3AbF2BRMmTdfoDwgTmh09cI0wT DPwL7VGBSjkpYRdBTCd/cnrcgFMqgD3S/A== X-Google-Smtp-Source: ABdhPJxXEdds2yoei4ugJOR/jCJV6ZL9dSB+HRpT2RTKD+LlEYA+2K+k0BDBxzPfFTTTV6zuyjk/uA== X-Received: by 2002:a9d:74c2:: with SMTP id a2mr10539966otl.324.1624040740423; Fri, 18 Jun 2021 11:25:40 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id v203sm1955550oib.37.2021.06.18.11.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:40 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 11/45] test: completion: add run_func() helper Date: Fri, 18 Jun 2021 13:24:44 -0500 Message-Id: <20210618182518.697912-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 d21dca4abd..bb3eebffb7 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -78,6 +78,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) @@ -455,8 +461,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 ' @@ -550,7 +555,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 @@ -589,7 +594,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' ' @@ -1090,8 +1095,7 @@ test_expect_success '__git_complete_refs - simple' ' EOF ( cur= && - __git_complete_refs && - print_comp + run_func __git_complete_refs ) && test_cmp expected out ' @@ -1103,8 +1107,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 ' @@ -1117,8 +1120,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 ' @@ -1136,8 +1138,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 ' @@ -1149,8 +1150,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 ' @@ -1162,8 +1162,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 ' @@ -1179,8 +1178,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 ' @@ -1193,8 +1191,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 ' @@ -1205,8 +1202,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 ' @@ -1219,8 +1215,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 ' @@ -1233,8 +1228,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 ' @@ -1247,8 +1241,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 ' @@ -1779,8 +1772,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 } @@ -2302,8 +2294,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 ' @@ -2316,8 +2307,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 Fri Jun 18 18:24:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12577C48BE8 for ; Fri, 18 Jun 2021 18:25:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDC68611CC for ; Fri, 18 Jun 2021 18:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236306AbhFRS1z (ORCPT ); Fri, 18 Jun 2021 14:27:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236282AbhFRS1x (ORCPT ); Fri, 18 Jun 2021 14:27:53 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E945C0617AE for ; Fri, 18 Jun 2021 11:25:43 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso10527754otl.13 for ; Fri, 18 Jun 2021 11:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VuLnN/lxBtwAh1MO6JMTqTWyXbeVKvt+EdEUlOD9RYY=; b=Qtc8oMAgPeqHcVxIICtA6bsA7hs0NNFrSeGSdndJ+6o90m8A3vJYMgQo6V9smcQal4 OeaOmBdYTchQjBUkjqtBHWYdr9GBF2ZLXb5dgOxdbqPsWGLAUIE61kHJvqYJHB3stvlc bKyPq4fCRvArCNVtvaPgZemH0nqVCU6/O8MaWshs03pxuwdqftg6N3G1Bzw1D8ToXPlQ B0clcA//Mmse0xExxnlz3bTVP9xhEzTmfTifXxIpmzr7uXiy+0wbobRyD5kxDdVzeMJb xkB0bNXKqW5yccNlq5vOff5vb7XxPHeNspCdPRYm4/WppQXIjDePoAJQsM6JyX+vufB0 865A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VuLnN/lxBtwAh1MO6JMTqTWyXbeVKvt+EdEUlOD9RYY=; b=rWWZyK3oEw6f+zVU1puYfZ321xZpRrMy4zLPqwjcbhhrdTSNN+0CF0EWgwzyxaRCBM 9ghWTrE9vqmHwPcC07azB1ozFx17cp9Z0ZIqAlyC442EwqKecIMhKZqeQIrJOp6e5+nS Ot262hx5GVC37E5cusx5+tq7BVKzwYslKEXBxWYCzBS+Tu3SwAgO3jEeKkc9QIhn8fPg TFD0qf6P9pZYiKOTPDnvvnRkq0KfAQRyM8edQ/G/uryQLiCsgvvCLcWvIL6ipodmIU+j jEODeDk0U86v5SBnD+uU/qaDBRPAzpwH/oqMUPmvLqwyXApE5d4CWRN0IumkP438dbrE j5LA== X-Gm-Message-State: AOAM533a66CEvPjijOks39UIxnNUfH9iBZl5JfTTpJnmPvxf7AKZlPLo dEeys4xvuaiYQXIipk4V3iKogjpLL3qwTQ== X-Google-Smtp-Source: ABdhPJxU/fz/E92cMfUtRjeZIuU35/LhUe9a63Hpp3qM8iNPxUSTn1FVXdbUdUKSDVUxCon+lcKV7A== X-Received: by 2002:a05:6830:1548:: with SMTP id l8mr9848134otp.95.1624040742420; Fri, 18 Jun 2021 11:25:42 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id m66sm1945943oia.28.2021.06.18.11.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:42 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 12/45] completion: bash: remove non-append functionality Date: Fri, 18 Jun 2021 13:24:45 -0500 Message-Id: <20210618182518.697912-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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. There should be 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 bede8a7e2a..8f72e0f66b 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -307,7 +307,7 @@ __gitcomp_direct () { local IFS=$'\n' - COMPREPLY=($1) + COMPREPLY+=($1) } # Similar to __gitcomp_direct, but appends to COMPREPLY instead. @@ -459,7 +459,6 @@ __gitcomp_nl_append () # appended. __gitcomp_nl () { - COMPREPLY=() __gitcomp_nl_append "$@" } From patchwork Fri Jun 18 18:24:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DE9FC48BDF for ; Fri, 18 Jun 2021 18:25:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33BDA611CC for ; Fri, 18 Jun 2021 18:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236315AbhFRS15 (ORCPT ); Fri, 18 Jun 2021 14:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236300AbhFRS14 (ORCPT ); Fri, 18 Jun 2021 14:27:56 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADDE2C061574 for ; Fri, 18 Jun 2021 11:25:45 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id o17-20020a9d76510000b02903eabfc221a9so10637284otl.0 for ; Fri, 18 Jun 2021 11:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+zL1t85DgllGMe13ZGN/bPVSfiUU2yAv1dpqoo3ssjk=; b=bQPsrdkhgP2sT5OTA8XIFXI2u3lMwTT4DifmBynStEikTto2ia63hQCNOM0/cs6zGd 8qzSYsV7JUr3rmitG6eX22/i1jvJRsrxmILF6F4ryV1La1Pdw3L2/4Ax4PbFU7Li0rMO NQYulJt0zkbVlsGqiSjIIEq3upEBK/865FDwI+2pa489wQqpioaKV7lL4vqsrH3ruhGU Rmy5jelYk1gSX/9KNSCSGxa1v6Y555eHWbsj7RQIvYpyyYicPoOBVbgoXpmqC28byudT LthzR5h1MdV0xA2/PYBVV7flnwDgchw4DmrDzfT41+wrAPX1MfUlrHQPHq4jVWKypddD jllA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+zL1t85DgllGMe13ZGN/bPVSfiUU2yAv1dpqoo3ssjk=; b=LqYLUxqzwGzal2ASt9paTWDLdMauWOX1qXEQZx+U9Jz9K57WeM0nZvyJpVTDA3ibWh rXIVepmbHHCvzLd3UWTUob5omT24k8UFcbcCzWC1eznttkQqee32sHd/2OumAn6CXesg x+JlkW1eLtTDI6c0BlHioZUeFC1dON8vNcmA+mb1LKFrypvTVSn1cwC0/AUPvUCdLwWk sFZASXcMBbjNrGZP7U4UC+ViyLcgn043A/1mqVaoCcTJKPCL3BBfCilJMabHIVbFLbpL Xzqp4k/cDaw0+4vApFk+PZWovry9tFvrYGSBUmPHpuuG/BEF+HKLMMqJE1cmS8NqBd3C mlhw== X-Gm-Message-State: AOAM531X0jZCyN63K2OVUHg98pSFoiNnTqHRuDvxA5VEOxBIin6kyQ55 UfOpIm139hBd5jc39JSc1gy3dEVdn9e6lQ== X-Google-Smtp-Source: ABdhPJxSFZSZioK6F9JQaS4EhRAanAz0PuqjTJlKUP0rgB8yH+UTPIPC5c7UTHGBPUUa514ggidwIA== X-Received: by 2002:a9d:62ce:: with SMTP id z14mr10855208otk.255.1624040744841; Fri, 18 Jun 2021 11:25:44 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id k7sm2020090otf.72.2021.06.18.11.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:44 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 13/45] completion: bash: get rid of _append() functions Date: Fri, 18 Jun 2021 13:24:46 -0500 Message-Id: <20210618182518.697912-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 8f72e0f66b..c3ea5261fb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -296,8 +296,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. @@ -310,19 +309,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[@]} @@ -440,16 +426,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). @@ -459,7 +437,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 @@ -846,7 +825,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 } @@ -2646,7 +2625,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.*.*) @@ -2696,7 +2675,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 5ddd2d6771..8cbf4f83f5 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 Fri Jun 18 18:24:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5185EC48BDF for ; Fri, 18 Jun 2021 18:25:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A82E611CC for ; Fri, 18 Jun 2021 18:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235091AbhFRS2D (ORCPT ); Fri, 18 Jun 2021 14:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236322AbhFRS2B (ORCPT ); Fri, 18 Jun 2021 14:28:01 -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 3DBB5C061574 for ; Fri, 18 Jun 2021 11:25:48 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id j11-20020a9d738b0000b02903ea3c02ded8so10577291otk.5 for ; Fri, 18 Jun 2021 11:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kdJ93B8GfAGhZuLUWGWa4Bvy7t6axrPT6YYr9b1BB6c=; b=Qye7Fx8Gv4l7vyP4cHjYK+AuaM3cXxj5O2dmefbBJc1SfsLdGMIboHaTWRRylO0m0l iSIQXCluUzo7g6mtKbJGNcg1pZoYLhAI3T1jNxpWlrhfNT4Ieta0Y8Ip7GodHoP1XwzT Eyj2OhgKoGKG7bUnTAciWyxZVdmaQSaiW4yGTvuxk1j3vdhIdf6R9mlO/a/I35faEcie OZwPgEmcDZ15UEE4DKyYz3ElTqAd/hMQVD930FZkEcz9UapKl9oJSZ+23tNSIskIUV3h StmZtbqXJXKN/u029c8tcuqiIYzbUCJp4wYPbQ2l+CKktOW80f/3R/eDGF0vgD9TvDTd JW+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kdJ93B8GfAGhZuLUWGWa4Bvy7t6axrPT6YYr9b1BB6c=; b=fAFwLhU+ltWeE5NYQ4+erojPFvEW9SqXWp44i4m2rqDwjV5CnFGAMc3hZwkWBuxhoa date41sjbfIhMNxUmmjecfDptW6xLl57dU4xyzaWpSqEkZLieGST1enfWVu5MPXWc8RO 9VPOuvhZw2TpENszXyOmnOsSXMDmWTi6MWzFNbv+J1wFOQrFXxEw2680nwa8zhEE6Ixb lXMw4O2y948zBkF4pQDkPTj/ar+KcvCVahuygKRx1c0GV+uqPRd1d0imWL50w2GqxHV8 4fcgoj9HPhpNYh3X05O7MjMohKzLtsg4r8sknXRXX2ME8tBNxqPRsrM8PuaB1XlafQu3 fYxg== X-Gm-Message-State: AOAM532umqte/A50tnLcaZJ+hNovhR9p1Nr5vh+bRZaJ4WLXI4p2oOlR 84+7SEBle7Dut+6ZpQfMOUzKxOqdwpxj6A== X-Google-Smtp-Source: ABdhPJwKp/AqdeG5orAZWHk48fPSqtAeooHRA94iFPPJrFqSRDFwYJLbw7FLvglKLoVHukhy32NHUw== X-Received: by 2002:a05:6830:161a:: with SMTP id g26mr10674497otr.62.1624040747388; Fri, 18 Jun 2021 11:25:47 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id 16sm2151937otm.57.2021.06.18.11.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 14/45] completion: bash: get rid of any non-append code Date: Fri, 18 Jun 2021 13:24:47 -0500 Message-Id: <20210618182518.697912-15-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 c3ea5261fb..366f255dfc 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -309,7 +309,7 @@ __gitcomp_direct () COMPREPLY+=($1) } -__gitcompappend () +__gitcompadd () { local x i=${#COMPREPLY[@]} for x in $1; do @@ -319,12 +319,6 @@ __gitcompappend () done } -__gitcompadd () -{ - COMPREPLY=() - __gitcompappend "$@" -} - # Generates completion reply, appending a space to possible completion words, # if necessary. # It accepts 1 to 4 arguments: @@ -438,7 +432,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 @@ -451,7 +445,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 Fri Jun 18 18:24:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95CB1C48BDF for ; Fri, 18 Jun 2021 18:25:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80744611AC for ; Fri, 18 Jun 2021 18:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236317AbhFRS2I (ORCPT ); Fri, 18 Jun 2021 14:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236319AbhFRS2E (ORCPT ); Fri, 18 Jun 2021 14:28:04 -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 BEB02C061574 for ; Fri, 18 Jun 2021 11:25:53 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso10528153otl.13 for ; Fri, 18 Jun 2021 11:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2JnvrF9wESkQ9rT6UToReU1QFMk6JyHzfs0dXq6cjZ8=; b=HX1g9JhBG21Pibt+QCTHrDqS5zDC4mNMCsPr3IJ6EB2CfRq1ljF+gj4jo67j+y4jWU +f/PZsh0qf5LwED+zUT8shIX9SdqSJw9HLaDoO0ZMhHg25zGR+edcnng6hhabPync4r9 lwJ4Q/F8xBTSS9MQ0bk9ssSaJG+A0XdTjeChjPw33AcoTqjbsj1d7rsrQ+You4LNzLkq O9mAJv1qvHjhJfR26vRXhSxrUqrvRlxuUa30qcco5Jeq0EW2GRhcWrtOb3ZwB+l8nsSV Wllea6ZYrJ/OZtqspCaSXjol/w8jDEJiy0tlQltfN/EzMmJxMTEOUWZJNFtKTGODK0iI c1TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2JnvrF9wESkQ9rT6UToReU1QFMk6JyHzfs0dXq6cjZ8=; b=Ay5ZI3eX3dYqH3XY9Rlj8aw1WcwCuq7GtHbfi5ADe8DN+FmupxbQIMj+DD5PLZDxfi 80KynY/1wQZ/mKM4VwXtoAhdV93QtSA9akMz9AbelZnraub1dCmIWeVAv//MP9dnxU7h np91yW0Q8jYjX9p2Bb/cmv2dyiqFnO+cjdwH4CBl0KCEgS3qpQ7cMn8ZQ1PuwdzEss8T JVrQV7Srhd0ft5q+7hXQN/oQP0N2uMlU0fK4sLN7ppCn+luNrETs4XWLhAKBwzMZlSym zXjiKPx+6RhMQMNIV5Ddp9JrpeylJUFJ3XoOtOjTsv3calr6F496TIDM8aye+y+VIGkn WoYw== X-Gm-Message-State: AOAM531Nml+4vvPmI8RljcL4yfxm71Rd4NGUU4j1/kc23O07bfs+eX3m FqSsDfYvAkaBBJKBXkJf24pM+SSQXQ8TyQ== X-Google-Smtp-Source: ABdhPJzZ4mHNGpbIqNW8/oa1aHasJ2/oF5BC2sl1aBSJbEJlYx0zlVCZPxEygoYxhQ1W+5kr1s+1xw== X-Received: by 2002:a9d:7414:: with SMTP id n20mr10601395otk.194.1624040752996; Fri, 18 Jun 2021 11:25:52 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id v1sm2228107ota.22.2021.06.18.11.25.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:52 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 15/45] completion: zsh: fix options with arguments Date: Fri, 18 Jun 2021 13:24:48 -0500 Message-Id: <20210618182518.697912-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 8cbf4f83f5..33bbf3d993 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 Fri Jun 18 18:24:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D64F8C49361 for ; Fri, 18 Jun 2021 18:26:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C32F7611AC for ; Fri, 18 Jun 2021 18:26:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236309AbhFRS2I (ORCPT ); Fri, 18 Jun 2021 14:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236320AbhFRS2F (ORCPT ); Fri, 18 Jun 2021 14:28:05 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 757A0C061760 for ; Fri, 18 Jun 2021 11:25:55 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id f3-20020a0568301c23b029044ce5da4794so3964636ote.11 for ; Fri, 18 Jun 2021 11:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BA+On2NfP5uKdi37PiVeRqvTi1iwdUaAFDENGVTDPgo=; b=jCU7j/Qj9Y4cGO1YEOgy6mVtmd79QAaZxuUJgmB8sHwWNXCTZS+IbR4tczRn71yNzh OZB7p3RwAdGYkOjM3wXKvIa1lfumC5272e2U7STBF7qJXjn/eWYdRL1DHWN0IOfLumPz 9RJgfjFCDEzkvERnK240fqw4gPjd0LK9RAaL+nYi8Xyin11ZHdt40HNPxsCe/R38ZzI1 5DeauBGZg31u6oa3CKEHVcM4/nPEn0Vm8fvfurhCP1WhzDbyAXut9b7lpxkYj0lmE+NR IBqBO+kq9utKg/fu9AgHZpZe+XXiL69hkVlVbaIDbTXoNgHM+2+GO9YSVgmeUNWut4Jb oyrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BA+On2NfP5uKdi37PiVeRqvTi1iwdUaAFDENGVTDPgo=; b=OvkOa2HzFRt5jyycbkrZWKpocuXV+5/1psyB2hJXirrXIXZ4qFyFwKTd7LCR/ghuoq u2wAskmUBOzZLcjQQcBOxDW8m4BUk1C8eMgqr4LjGmDaBWa1OvB9T47Joy2sbvKjTSsg 32uI+GwTr/3k8a8JSIaDmHIzooUMt/Ykrk/ngNNIUVQhcJE3WP61Gt8rlCgW2anmumb1 LyTVA3wLoDvWthSxAen4MyM3xJS193ozkMzQgrVMLDxUhGr7PoJGSG4SulxCm1kU4YLz felO96DTQS4cerQMoRX696gzkUR09sJKIGeAw1BpWmf76vJJv8e9y86H2tJvpJgPx353 oRjQ== X-Gm-Message-State: AOAM5321K8v9Mj9dvEwASbrqIYca+Z/LjHlBh/4zg0QOU6s9aWB2SA2t hBha2ssUnbyqW03V3BDt9IULufm1PGN1/A== X-Google-Smtp-Source: ABdhPJy478IpfX3dEsHMJLh3+XzjDc8Ag5RnJCz1nG0Z5sgQhdmsn3uFFJwOp2rtx3BoGk7KVWXM4A== X-Received: by 2002:a05:6830:1e95:: with SMTP id n21mr10742156otr.350.1624040754669; Fri, 18 Jun 2021 11:25:54 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id u10sm2280345otj.75.2021.06.18.11.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:54 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 16/45] completion: zsh: expand --git-dir file argument Date: Fri, 18 Jun 2021 13:24:49 -0500 Message-Id: <20210618182518.697912-17-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 33bbf3d993..9768f76af3 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 Fri Jun 18 18:24:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ECB2C48BE8 for ; Fri, 18 Jun 2021 18:26:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E0AF611AC for ; Fri, 18 Jun 2021 18:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236319AbhFRS2K (ORCPT ); Fri, 18 Jun 2021 14:28:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236322AbhFRS2H (ORCPT ); Fri, 18 Jun 2021 14:28:07 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF30C061767 for ; Fri, 18 Jun 2021 11:25:57 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id h9so11529910oih.4 for ; Fri, 18 Jun 2021 11:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jp7EkfeiOTWui82VagsHiOaToMZAPQZhYKxFbxXWEA4=; b=OrjFXdRxFGJtfYEqDZkOR+AiegWjZ3vRsMmZahhein4HS3kANrJt9UXQjrhVb/1omx 6oq1HEfcXq+lW2tQJPhpOqwWckb2sJc4J3zkFUcoQgsO3Tk1F4pq8GbW8PVg6ZJssfoo pt7HCo1a/vbVxDX4Y2Bv/4lOhOMKFbzfGR10NBkXdlErlSVhzO7kSiKGHdancfjV7aeW d1VNlvo5gposYTDR8WSXtnNIrNeOJdAl54YitzNunkpEu5rOFUoBux4A+U93AQgwZFSd Q/qkKFPe588vGqHjJ4UtNHEKHG5Bk2+hA83+GkrdFbQvv1cKvZ8eawLqB5GuHR51Opwl oJ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jp7EkfeiOTWui82VagsHiOaToMZAPQZhYKxFbxXWEA4=; b=AsiCZuvQmEwMDCbZyDwNmNqmhg6efaCCxIrQ8lKp88K3AKb+tbveFvx66L6lO+vvbV meym8BydmZXBB7mCH+vU9LZnmDv0RraZIqljte/qDXIM2jGIa+IcHQpeyB7unN6AeOec ZxStLHd+GyIOlRgYs6h3Jym8mjjL5rZzyaMex2KVJqpelwoIdSABaszoecVP5RitkNZn 7qwgDYFdwJpj9k41y1iJbxzAYS5we7snmEhKdLrbxYK/C93lrUtZbsSFPzMUmMQC93wK bfRyiTgvRQfbaxiatg2QjCtx/jn7q/RmITBu/b9s24C5ESQz2IMx+rECMAJuk+cAQOVk pI9A== X-Gm-Message-State: AOAM531jvjwRcrYaH6vy1wdbmdiDcEnq9mPe+kKpX99Q7OTj2DqABDIP IdOFH3o/RUdjtRgwy/qryGSpB55J647SzA== X-Google-Smtp-Source: ABdhPJwpn86lTit97iLoCr96qxK5fSs/1ap4jDOn8SF2wEeQicWD4+XJrNv4yY6BATcyXKvxOu5HtQ== X-Received: by 2002:aca:5dc6:: with SMTP id r189mr16004259oib.164.1624040756321; Fri, 18 Jun 2021 11:25:56 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id v10sm1901690ool.45.2021.06.18.11.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:55 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 17/45] completion: zsh: add support for general -C opts Date: Fri, 18 Jun 2021 13:24:50 -0500 Message-Id: <20210618182518.697912-18-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 9768f76af3..f60801741a 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[@]} ) From patchwork Fri Jun 18 18:24:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57BB4C48BDF for ; Fri, 18 Jun 2021 18:26:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 463D3611ED for ; Fri, 18 Jun 2021 18:26:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236324AbhFRS2L (ORCPT ); Fri, 18 Jun 2021 14:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236312AbhFRS2J (ORCPT ); Fri, 18 Jun 2021 14:28:09 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3FEAC0617A8 for ; Fri, 18 Jun 2021 11:25:58 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id u11so11511589oiv.1 for ; Fri, 18 Jun 2021 11:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SJcQ6gFN99CzFplbb3qLyaijbrXnk6PemYxzXnylJrs=; b=KCi3cK3phn+xgeFBJ7L313INyadS7R8v+7T75ZuS8ie/Yg92rXf+YWJsYeSM12R7ZF UVbk9GB+8IDbpFdmrgN+ZJ+CB1hqRvD5E8ktX+pVVDRti0X8JiSsoIy+ppKdEqyM+0zU U/7NuiXP48DUN9bSi/fntw9YLz2eOZZKn6X8yxqsT+RBhX/FDMNa74/MSvU8Fb8yHyE7 4OR/RqJBhAQlNCT69KhJqvahRMncGi/N8QxD2bP0npsmnU/QIumpyFctHD/mR+d/Oin4 F/J4pV7e3BtMog7KYghwCLJkTvMb8/otC32w+U8uiqE7yI0OHKdOGPX2+KEhTJQIz+Oj uakQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SJcQ6gFN99CzFplbb3qLyaijbrXnk6PemYxzXnylJrs=; b=HgpyaHxkK4DQXBuCOXCrfetu1DhOKH6kKjT+ITSQfkcFqAXERlrDheAZW5sQ6vMwlM sEvx+HzW5xSQ1ywZgOY53/kkTAQP9O5uXPvD8Vj3xOFh0sKboDIs/ELO0+aCR/3V4Zpv Ul4DOBgVpO6D4nPfYTmZYXzALG5GvoXmG2DXk6M+I9x6joqkxlTXYWJb1U1IXbCkuKFn jf9fxozmxrWxlNbX22PpVZRdUrVQSIyG5IlXbOXXnZ6dSXPAhic9Kb+PYnGelius9SFN GBdNVOBkt3WzIniGMh4yv1tOOu0EBYxNA3/H56+estb41y/OhF388vwlyPrUSAo95sdF 1jfA== X-Gm-Message-State: AOAM533RLciaTI45h98EuQdQEldbS6VO2rEtWWok1xjEs9xyDDiRJRbp oAT8EZpwW4fjr/N047ir8OprxRH2PzyhCw== X-Google-Smtp-Source: ABdhPJwz0UmVt2wmO40fP4F95CktZ+z9HQ1iVsxRjlZ+8Nj+ByOuD3MdJl+InZkZkVt8bhhzHpTyYw== X-Received: by 2002:aca:4d3:: with SMTP id 202mr8263179oie.9.1624040757911; Fri, 18 Jun 2021 11:25:57 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id u10sm2280369otj.75.2021.06.18.11.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:57 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 18/45] completion: zsh: fix for undefined completions Date: Fri, 18 Jun 2021 13:24:51 -0500 Message-Id: <20210618182518.697912-19-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index f60801741a..5cfbcfe7a2 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 From patchwork Fri Jun 18 18:24:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3DF9C48BE8 for ; Fri, 18 Jun 2021 18:26:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A952D611AC for ; Fri, 18 Jun 2021 18:26:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236327AbhFRS2O (ORCPT ); Fri, 18 Jun 2021 14:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236322AbhFRS2K (ORCPT ); Fri, 18 Jun 2021 14:28:10 -0400 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CF56C061574 for ; Fri, 18 Jun 2021 11:26:00 -0700 (PDT) Received: by mail-oo1-xc32.google.com with SMTP id b24-20020a4a34180000b029024b199e7d4dso2344763ooa.4 for ; Fri, 18 Jun 2021 11:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZvKHds7M4uEFzudoySAlpiECLLXAMj37W7YMAoHiq7E=; b=ZboUPXcG4ld9pvR8XFGjks4hmhQO7bqp2zT4qXSMICILPRU5GElyPkCQ0bF26seTy9 XH4uTt6WdCgsx5t/sqvWaPZLsqrHr1JnvOzyXDWMryKMYgLUoG3/QStjniD6IarPsDf9 tSRplR+jzcZMCXRLo5tpBYGjdoHxZIIDwLViT73JIR8XKg78258SSSA2nOOzoP9Bl+Ue dmbtK/Wl9JDD9+KBATB9gEzbauy4NYANR9EzzMdba6/Kub6NR02NOe/b4x0LIt3sfJdF TOU646i3kALE2vVjnc6fZa6eDoodyaw7U1b4/PJG9ckDDxu3YHPn6mKscMyUcMaTfRJj x5cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZvKHds7M4uEFzudoySAlpiECLLXAMj37W7YMAoHiq7E=; b=ohq9EgYAjhA7IVqIAb1C7w5snL93NtGeS7N0B5hfpwmLLgRVHXDQJt/GGXkQ0ykC1N /2BQ2I9oiEhqNpg/ue9KYrlD2TEkZUddx5Yv02QTVvv0XQkXu19xW+HmF3uMVQDGueJJ uB5HVxLKH/1XAR7Xk/mep3dDg22MdSDuLidqduX/uMU4YtPpbExH/+fI6D6O4ZoqqMvl u8wURPC+EbLNAumZR7tkwzkgdh/OU6V4ZJKFHxKtP0MG7hzmbi3OtddRhdR9susm0aw3 Bg5n8N1F8eC2gRlnjYsOAT/PBTrJOg76qcTYqfab7CyjPPCa63bll9mwTQAHaYRkWuV4 Jhww== X-Gm-Message-State: AOAM5327j6qpHb7ldo64z+gNmgsEDUzsBiR9Lhe3VY+xqqm7yHWmw1rm oQHC65skil3yKeA0VlsrWp4LAjRg2IB4Cw== X-Google-Smtp-Source: ABdhPJyAN41R62yFTmoeevPckgkHnHUyWoKqkbcHg2ZGsGkJkCK5fB3k78zn6EEVh5xHrw3d3a7QAg== X-Received: by 2002:a4a:e6c7:: with SMTP id v7mr10289567oot.86.1624040759605; Fri, 18 Jun 2021 11:25:59 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id x31sm2133911ota.24.2021.06.18.11.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:25:59 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 19/45] completion: zsh: add support for general -c opts Date: Fri, 18 Jun 2021 13:24:52 -0500 Message-Id: <20210618182518.697912-20-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 5cfbcfe7a2..f3e8cb7535 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 From patchwork Fri Jun 18 18:24:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7493C48BDF for ; Fri, 18 Jun 2021 18:26:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC7E4611AC for ; Fri, 18 Jun 2021 18:26:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236340AbhFRS2Q (ORCPT ); Fri, 18 Jun 2021 14:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236312AbhFRS2M (ORCPT ); Fri, 18 Jun 2021 14:28:12 -0400 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA11CC061767 for ; Fri, 18 Jun 2021 11:26:01 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id x22-20020a4a62160000b0290245cf6b7feeso2670032ooc.13 for ; Fri, 18 Jun 2021 11:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dXlYzPbBXdJzNOPEVUVvitzi1CW1bMP9B30F8iOMDHE=; b=vYBk3136IAgVedbCHZlIuQdowg59tKW1WnZoTMyswCF+5QfUyMvd6sCsj4lWBmm6A7 b2+CyRChGNJ2ZRcQC7xERy3vTts/CYZHXX0PY79jV+sPvwJGQd5w80hFACB75mtj3RwE rvAEPLOf1hwdnL9wHBXApqw7bYmb7UgShxMrysn+apsINavRjl1BGke9Zz2t7NBDPXP1 nxcXDdQ5KgeTG5uNb6uqqszg+rbqPaPEYWZxN+sLOMd15OorfyKkqGBpSo74JFneKeS8 JAqfCqVIUyApA8z1MG73FuVo/vJcRGG/e6uATiPUMhl7GABgQVCTz8CulTuoAOJVr3Er mswQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dXlYzPbBXdJzNOPEVUVvitzi1CW1bMP9B30F8iOMDHE=; b=tjXKIhJhUHayxgi13EmnQXlCWfoK3bo9BUpMm8MbHFmqo54aKyjZgwNZxepTdvj3XX g3JMSv9WjcJKAB1qibwbWw3cD38MK2sBv6xLsS+axgBJVmIochgseA5If8n399WXyHzC PRLiOnS+xBc2qylNzv++dj5MejuEpHt6A3aj0U7KCnpuGAt6NOoz9jdMz6Eq4Oj3hHyl MHm0L7G9v77KmVz+MdgzwE15uC1CecUmBPxdC0WsjOB8hKNxL/VzcyNwxnfXlP6sgyJb q1g0KtiBYqQuZq3tP/8gRMqLV4k6VrPjDym5AdnGjPyl0ALaLZkIrls8hQJk6bafglls LO0g== X-Gm-Message-State: AOAM530ktDyMhocy04iVAdxtGD32wA9Zr0pfIflKJxbRqO5u2b7kIvT9 tWaY/iM3k9f/J4H/4oILYTr+8ZFSKgU7Uw== X-Google-Smtp-Source: ABdhPJwrpWpVN7JkFAw2QYDjz1my5ZM0ntsqwX1gYTZP++kAubikex9mvjQSXhbDemDtDDzixisKFg== X-Received: by 2002:a4a:df11:: with SMTP id i17mr10007683oou.93.1624040761025; Fri, 18 Jun 2021 11:26:01 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id j7sm1951564oij.25.2021.06.18.11.26.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:00 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 20/45] completion: zsh: fix extra space on foo= Date: Fri, 18 Jun 2021 13:24:53 -0500 Message-Id: <20210618182518.697912-21-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index f3e8cb7535..56a1bb16b0 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") From patchwork Fri Jun 18 18:24:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 155BDC48BDF for ; Fri, 18 Jun 2021 18:26:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0015F611CC for ; Fri, 18 Jun 2021 18:26:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236338AbhFRS2V (ORCPT ); Fri, 18 Jun 2021 14:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236322AbhFRS2O (ORCPT ); Fri, 18 Jun 2021 14:28:14 -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 671EFC0617A8 for ; Fri, 18 Jun 2021 11:26:03 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 6-20020a9d07860000b02903e83bf8f8fcso10548128oto.12 for ; Fri, 18 Jun 2021 11:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+HcR7r7lNHBbisAGzlImzTt8aK9UKElQOVUuSbVYiXc=; b=CrQFJ9GEs2xeGXLIrNdD1K6nEMe/IY9Vmc+1CHvJ2i8TGX1aLQBICsdnOdoUT801mL WXpd44mmI15/b+xE5gh9YVhL7G4Tu8doTlsEMm0TvvwvVC9vvBdx2yW7caizB8Lppw72 2rPPwZtXItOCM4LRMFT8i+Vhlq5BjanJU5QSkbHHzUFrGwE0M/l6EQTEe1G//8AhcmNC YkcpwHpUbThIzLY13oYnudxaykdTNZYGLQig09+mTMoa1B4nIk0pFqriFp5BeV/KZV0f CONbdb+ALUIT+zkncp3wfT+mt6UoefwyO8TSWXjQkMm30CFu/0tVnFpoprG2+aChY87X oCvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+HcR7r7lNHBbisAGzlImzTt8aK9UKElQOVUuSbVYiXc=; b=jxFRHWGd+86FaieQpFQ8lJgvNdCzrSaPMcAwGRAk8ZHE5xWjIhZg03RvEJjf0TwTof 3SSXH3JR9OlBFA2fzmi2apedJ91Vq9XhrTDbuuKHYeVIg8sKrHO6aEMpxnzESnQnPZ/O C7LF7TZu5d7kCR5pteil4h/gChj9sb0JVNji+OL4elk28AjC3+up5JIatYfCkxXl2E5m 7LGS03AgYvG89o7LvfoXuGp5MF7tmmcFFPaURVTf/H15e4YKl5uwASFtjklxSBHUHMkl S5DxwTSgxcC8PWDPhFiPvb2LHIvRralnd9Fs2hrdgbafhOzBRDGOpRwXcFrNQ/FOog6n 9dPQ== X-Gm-Message-State: AOAM532ZO9qdQpr4F0V9z5WENWxisocJ955lg9OwIoIUgO8IEAwcjvZy xKlDGqJVROhE4U7LfhA1qrXFK8XLywJsAA== X-Google-Smtp-Source: ABdhPJxHRRNwuQ5mWxaHT05yTov0A2oLALotYwhgcbI1wa4gevdGfRlvddFf98E7+BEbFR+ksU+OSA== X-Received: by 2002:a05:6830:19fd:: with SMTP id t29mr10884568ott.296.1624040762572; Fri, 18 Jun 2021 11:26:02 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id x73sm1125543oix.1.2021.06.18.11.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:02 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 21/45] completion: zsh: add excluded options Date: Fri, 18 Jun 2021 13:24:54 -0500 Message-Id: <20210618182518.697912-22-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 56a1bb16b0..426eec10a2 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]' \ From patchwork Fri Jun 18 18:24:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4CE6C48BE8 for ; Fri, 18 Jun 2021 18:26:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFB18611AC for ; Fri, 18 Jun 2021 18:26:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236332AbhFRS2U (ORCPT ); Fri, 18 Jun 2021 14:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236337AbhFRS2P (ORCPT ); Fri, 18 Jun 2021 14:28:15 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F104AC0617AE for ; Fri, 18 Jun 2021 11:26:04 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id c13so11462925oib.13 for ; Fri, 18 Jun 2021 11:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2s21LxaNeZcA4LBi9OL+tF8uuoc0Xw8+P8No5sCsc9Y=; b=P7UbiaOVlg+jJKKKE+XvtLM8odSj6JaEajBoM1/Cxbs7vyWdgsEQfuISZkOZKqwbjC Wn9BW2Yxz87ABXFBYjipEPArImXATnEphOgbmOtOl70lyBcRw77FoU1e4gtDio5R48h0 xrLVy/kqPwKFsEjjXSGf8hq79/EBusl4pUUqkKTo3QLa70K0r91oXJJvePtD1QWQKEAj w78Y84QE+rzRd2KH66CH7ANNkdAzPIlZculLl6LUWCWM4t3il0CG7LfJw2j1MZisIyhi bEpYLkJiEmLmFTsbCbOnsghMhVuHd7e++boLwvA2sOaIl1ZXECZo50WM7s91vApltuL+ yAXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2s21LxaNeZcA4LBi9OL+tF8uuoc0Xw8+P8No5sCsc9Y=; b=XnatIFu2F44953bf5DJORMOPRnReNvtki++k+uiLoDx46Uesc7FD1sP8GI7AgkZ74Q 6cIldBqTeI9mf4Xw9kAxNvNN/c7TCWLfjUW3NtEPf2S6286UZogwn6Z/hbsJev6DCu74 6DRSkscsFmUTK5c7Y4SJCo6pKewuDwxfXnZW57vNdXDlwVUSEjM5MA0TK0fH3njfaIpN mII2ESR4f08JkUjDpY57pKyvysAucUhC1kQduS1DI0IFeD1bd93J0jHyBx2w/3E/umBm H2BQCo5qLAmr3lresTpUOFfafoI2/uWaJ0t9XWkSZbac+9V/TCbjQmY7WGzdCeOYqjlh 1ryA== X-Gm-Message-State: AOAM530hCl5H7V8VSreYTthZxL4Zl4GAwETi2ZSI5aEZ6lpAyTJ8f6DH wm3yfj8Kul8HuBPzq59mIubyovAzKWRI3w== X-Google-Smtp-Source: ABdhPJxJhPcxJqSoReJx4cwxmASjW9rU3qBoPDJb3z4G4gz53DliG+b9/ndlvqr34eAlDyhtzzqPHg== X-Received: by 2002:aca:5dc6:: with SMTP id r189mr16004622oib.164.1624040764150; Fri, 18 Jun 2021 11:26:04 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id l18sm2128007otr.50.2021.06.18.11.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:03 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 22/45] completion: zsh: always set compset Date: Fri, 18 Jun 2021 13:24:55 -0500 Message-Id: <20210618182518.697912-23-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 426eec10a2..b9c2c75c79 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 Fri Jun 18 18:24:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3A54C49361 for ; Fri, 18 Jun 2021 18:26:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC716611AC for ; Fri, 18 Jun 2021 18:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236348AbhFRS2W (ORCPT ); Fri, 18 Jun 2021 14:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236312AbhFRS2Q (ORCPT ); Fri, 18 Jun 2021 14:28:16 -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 7E75FC061767 for ; Fri, 18 Jun 2021 11:26:06 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 102-20020a9d0eef0000b02903fccc5b733fso10578204otj.4 for ; Fri, 18 Jun 2021 11:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F2gUZrJRZfmCPSCGiSJweliKvhao7YzSb8U9EkQCbCI=; b=c2/BM0w9zShHdSpXToD4mm7n0jYCcMKLU6spOlCsTYrZUYgQPCLMR/Fq1qdV+QxXZe Cv247I1C+TxEiwgkk4XVg0Z3ja3Gp31RnF7Slkmn6lgmB5kjNsLBJsSSAjk3evVeUW5W daUT5yLZC0Cl2YGqkc7OgNNn6vFlyo6kS7ojYrar1lgvrS+ZsY8kP/f3jBkPHBRJR56F yO3VS0hX/jtFTfeXvU1vrOWPk+RTJH0MX6OInBJP5rds5jNjVDw+TeE0uYD34zmFFbIL xRbeZ6BPnjUgMgsbo6Kha2/FcISbAXiJSit3pjO8fHqA5hPpqSh8tGTF9iouCPsUU7UN MkxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F2gUZrJRZfmCPSCGiSJweliKvhao7YzSb8U9EkQCbCI=; b=pqEZ5s+vsak9P+S2qx9loNCZppH8NqPC3czxnN0MeESZOwfMHiuXWVuq5u1ZRNEkOX 2EdIgz/3xpXPvn8Vd7ZBIdLsKfhXCBsyLb0welobtUmxqMTcANggPXT9puFkzReJlkMI 9GZLSW6h08mmw/UXIBSoaYtveN4Ky9ll1KHBkSg9Et1+h7A0OIF6oQoBX3CKWhAuVeQD X46kHb6lhJhqYbiXuY9BRhWW4kJsf6JgR7CfUPg2qizIc53ODZL7djbAIeNwA6Vpq7Cz QqdxO0lzaJSBuAQiS8uKAUajK52rZRFgRKObia+mZKpe+psmWbjgf3hTzGAGMaDD7DZb /cwg== X-Gm-Message-State: AOAM530+pSR5dGI51KXB3+gls2Zd9b+RO0GjWis4EbCPlwuSDndnxO60 djOKDpLJiOLynDzdmsyDkxjq2KI79siUtw== X-Google-Smtp-Source: ABdhPJyVeYL+c/Be3QdoOToJX5wML4OgHFyI3mdDBRzMvYOiHz7pbfxAxTqU0mhz1A3gkNC5ZNlHCQ== X-Received: by 2002:a9d:17c5:: with SMTP id j63mr10529539otj.369.1624040765708; Fri, 18 Jun 2021 11:26:05 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id e23sm2176393otk.67.2021.06.18.11.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:05 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 23/45] completion: factor out check in __gitcomp Date: Fri, 18 Jun 2021 13:24:56 -0500 Message-Id: <20210618182518.697912-24-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 366f255dfc..ad67abff36 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -330,9 +330,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 b9c2c75c79..4dd0a4d821 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 Fri Jun 18 18:24:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 988AEC48BDF for ; Fri, 18 Jun 2021 18:26:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8291A611CC for ; Fri, 18 Jun 2021 18:26:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236339AbhFRS2Y (ORCPT ); Fri, 18 Jun 2021 14:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236326AbhFRS2T (ORCPT ); Fri, 18 Jun 2021 14:28:19 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91450C0617A6 for ; Fri, 18 Jun 2021 11:26:08 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso10528727otl.13 for ; Fri, 18 Jun 2021 11:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uzdc/6+iV8+pAEkY4zTWjHEen/iX0RCSOtEZhcKa1Vs=; b=A8zJotCZPRdydXkR03ZPQwE891O65ngyXGY1BtZaTHsqOxuBfNlyUFELUWW2dPGJCv j70ok0AOSUedejq7jIufKLXSzYXEGSniOPj77RkxwpPFD1/EkReph5kkVzCvBKdn2uXI DIawFdGjxL5E6w6c0fwY/vloHI/BCWBuX84Ax6AmNRaOHlDfeWcZcaAKKcgPYjBL1LAl E7NFDzDRRFmhLa6FGaLrp6IQagdJ9bBBwag0DveTZI9H524eDM325mM9mbK7Yb5QSXor f2iQNHVFekHvPsrGMOf/fcwhtS/wyXW2YX46cyHgfbwlizT192TiQJhRVZ7u9++28o8a 74Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uzdc/6+iV8+pAEkY4zTWjHEen/iX0RCSOtEZhcKa1Vs=; b=NkmmspAv3/DU0LyRBLT4UwsWwMHxxmbgWUFjnXZPljW5AF355PqWmVd7DMGkIyUXLq 9CLjb0DgLDuHfXm16JdqSo3UuEosZ1sHCzKAFNv9U/pEGqJtcYeuqHDLwyH+LvIW40KC xYu0uNMqCl6oF656tnPUYQW8JO7J+79y/RrA+Xim/4JsNZgfUkADwJUWxbD2MUcxOwSI iqwc5XMe87U+1r95rW3mMlIhX4fY98BejKTl7KZDmRF0Sojun/7TfVHg2hCpzjs4llSH dqLHCmeGyAKOqiPdssewUxHLD1Rw/nUSaKKsIqJfbo7KyoWbXCF2e1T9Y02SDF/fR+Lc 2MSw== X-Gm-Message-State: AOAM532ys44o3u3MowZiLY9KwyBQSPVNiwi912v3I6IMYHVUfmkrg3wT 8gw6ZDUbzDn4KwPEDNjlHPR52JfGQkYZAw== X-Google-Smtp-Source: ABdhPJzJGXPS4NAbFtMBTxHaVYgQVC4A2MW+9PKnH6OxKVqbGLDNHm7dr/rC9gsQRtmDClnLyS32/A== X-Received: by 2002:a05:6830:90c:: with SMTP id v12mr10135155ott.7.1624040767558; Fri, 18 Jun 2021 11:26:07 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id w12sm1598719oor.35.2021.06.18.11.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:07 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 24/45] completion: simplify equal suffix check Date: Fri, 18 Jun 2021 13:24:57 -0500 Message-Id: <20210618182518.697912-25-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 ad67abff36..d0df695b52 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -344,7 +344,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 4dd0a4d821..1fff8437d5 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 Fri Jun 18 18:24:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64F29C48BE8 for ; Fri, 18 Jun 2021 18:26:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F6AD613D1 for ; Fri, 18 Jun 2021 18:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236341AbhFRS20 (ORCPT ); Fri, 18 Jun 2021 14:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236325AbhFRS2U (ORCPT ); Fri, 18 Jun 2021 14:28:20 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5ADAC061767 for ; Fri, 18 Jun 2021 11:26:09 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id 102-20020a9d0eef0000b02903fccc5b733fso10578346otj.4 for ; Fri, 18 Jun 2021 11:26:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zg2t0XPVdQ3UugjMMaP236645ooApa0EF7cqzJTIyCw=; b=jLOkafwQ/MP6TAC8YQ92cUEHMqUgnACRmhW2xQy4kPt3+hSxPsND2AjTDxTZVdqGDU bM8V95ep/vNR3CnKReje7tkMiRLpTfOfkeKMTf97wbUfETSYJLWPQ6tZzZsfzgJKJ4au HKFU6liuF35AsuBHBkIfZ9hW1jf5UoYqYSENl5mo4TytV8owivrxM6hsmKcwXlUm0d/2 cHPvi0NuYMXXYdWsrkVMUrVSTMONR5PWtj5r2d6UEmqWDtqJ6lxQ4p5pBR9KrfhBj+0G eQk3q/Whx8iTFSKOlUc3167wVRxD8kSfN7Ti0Z9bfF1mQXXruh/m29gaaRCXYp1bKJxu S0jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zg2t0XPVdQ3UugjMMaP236645ooApa0EF7cqzJTIyCw=; b=Xu2F3LxjZY7VLysamhw4WB3Oy+5JstJYdkw35OVelKu/HPsLpWekkObjRP7VgXS8Pu nfMHrX3EdI3kZM3o1fmV5d0pVtws+SlceETaAcVh/JCieSXnnMMg9WrAy4hguqrtUHnA 8jAP1NNOxG49hKOEw7jRANEAMQUVFpVRBdhmOaccmXl+FqZJA14zpstGFcBuaPq8tr+R PxZLGGhPJR4BT0WQKBjBrSXI4emAC1uVacgeto1uDAp5yExufcNF/vxeV9NyOR/5BBU7 DHMeXU40EgvIpkR0cRHsx6+2rl27AUwzHDDK6I9ax2TaQKEZWSDUy4q5o3cfvBTB8C+5 G/kw== X-Gm-Message-State: AOAM533PXpBo9auIxgfACIEETY4Ek+aEQ/BQrcdkG2udmbz/ZoxWV2L+ shVr7IUS7mIfqhy5UAOJUumi8fu8l4U33Q== X-Google-Smtp-Source: ABdhPJxTNZC+Y4hnEDjRg7Zr3goZkEsUm7b4RjYdcgk5a0/qzWWjG1oX7ej8LMqVmxJiJp0XQpZkxQ== X-Received: by 2002:a9d:6f93:: with SMTP id h19mr10315217otq.100.1624040768943; Fri, 18 Jun 2021 11:26:08 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id v42sm2126382ott.70.2021.06.18.11.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:08 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 25/45] completion: refactor __gitcomp Date: Fri, 18 Jun 2021 13:24:58 -0500 Message-Id: <20210618182518.697912-26-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We have to 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 d0df695b52..b4b778da0b 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -334,44 +334,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 1fff8437d5..c7e4de15c6 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 Fri Jun 18 18:24:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6524C49361 for ; Fri, 18 Jun 2021 18:26:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1737611AC for ; Fri, 18 Jun 2021 18:26:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236368AbhFRS23 (ORCPT ); Fri, 18 Jun 2021 14:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236342AbhFRS2V (ORCPT ); Fri, 18 Jun 2021 14:28:21 -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 6C77DC061760 for ; Fri, 18 Jun 2021 11:26:11 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id 5-20020a9d01050000b02903c700c45721so10583854otu.6 for ; Fri, 18 Jun 2021 11:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q/OXb2rTEpjHV5GGoPu9u3B8HTDEI05r3wIZLjVDxQg=; b=sXeP6S7T8PjLSoECvDXlmh5rK9ilKSu8PPDNec+snxlJLFB01k8rgdp+pu1+UV6tDQ uxlPhiDDqVu9qNFUdfLRKkLgO50wC0Yi+BfOWlk6fznj9+0ot4sbNltgD0HYDtI9+uSn m25l9hfOu8Abc7o62q4lL62HbLnAnqU7eTUQwhcAPWnq1vy9RpvOsYBf4cSCgtg+ILaS WqE+lFmX88hLgdYaQ2j14Zck50MdshvRoyutRTMCyDGrvsdSqHqH6jBwyCEYIx0iMN19 FjEJUnhSq/nXiq88irVrszdN/JLa/PEyH4ROzdjhS9p/HOIm53UU090Z28o1j7s+RZqE 2A+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q/OXb2rTEpjHV5GGoPu9u3B8HTDEI05r3wIZLjVDxQg=; b=DGrDV5pNsTx3/bPMF4proinsVF/GTSMJororY++V+18T9JI1WigINLzgwC/wancAoy XqMnK0YexyO8K0+vpqJouJmiv8OCpdpVQDwx23qH8Z/jgAMlCxUy+gxYnGLAc4Aa2PDS Fso2Qo+ovzKLkKMA0U3vLBWhjzi8Gn/b3zZiAcY9jrzRBxVrmRbuKvDili9X1bIlkdtT UfZtGyhPc6F+WSPeBPRkAkyiIgK/flw2ZdS5soXPyAsihgF2PPZe8kDEJdiniFnCGrtF 1TAmhqXYl3tU/+38+hdYnJKVO6QyHH7wM3I+0mRB0Zkf5dqMrQdME5Mg16AWcpoaN/40 8D0w== X-Gm-Message-State: AOAM533orJ3sVhBwknWhGJB5ctDFdXJ6hwrA9QcgfGrpHs8bNWEWQQLz X8ouDTjSZwuyBN66ZYvRkgZoqFcMQos3uA== X-Google-Smtp-Source: ABdhPJzhXAt+2bnTcyP6C2K39IaB5z8rfXooilUQdriKXtM/myOcxDznidN9mQ8PcKQhnRVUVJ3lCQ== X-Received: by 2002:a05:6830:402d:: with SMTP id i13mr10292867ots.46.1624040770624; Fri, 18 Jun 2021 11:26:10 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id w20sm2183799otl.51.2021.06.18.11.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:10 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 26/45] completion: simplify __gitcomp Date: Fri, 18 Jun 2021 13:24:59 -0500 Message-Id: <20210618182518.697912-27-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 b4b778da0b..ebf8df94e8 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -341,9 +341,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 c7e4de15c6..6008a73816 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 Fri Jun 18 18:25:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A93E5C48BDF for ; Fri, 18 Jun 2021 18:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E493613E2 for ; Fri, 18 Jun 2021 18:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236382AbhFRS2d (ORCPT ); Fri, 18 Jun 2021 14:28:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236331AbhFRS2X (ORCPT ); Fri, 18 Jun 2021 14:28:23 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5C1FC06175F for ; Fri, 18 Jun 2021 11:26:12 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 102-20020a9d0eef0000b02903fccc5b733fso10578464otj.4 for ; Fri, 18 Jun 2021 11:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bbD5pl2lVnLaK08ia/VKbSbygyDTXnLrFUifoXgtAks=; b=c0A/f5bz0ZQLpv0xTP6V0b0BG/KjABvVI4QHbu5q6L0wyMTwTNkVpCrnAlK6j3dxU8 kGLdBlaD6baJwgguEUgmra2ewncKU/VXK/g2mYQxaA1z0HHtrFsQHqC3IqgphsvaQiiC hY8mdAyfnYRcFexnQXKhHB4gQdgwOK8/1PAwrhQTxUPz4PJQVtJNnGVXZIRqxXtVOTeM l+IZ7zkGWMlXbEzv5rPaHArxHvPygSkEG7fyg/wPa+VMnmJPBFSRxV/GTMB0uageRObT Y4lHPf+xKn8H4Y/JpgP9dGJ05XpjItx+2r804YGJ4ow3asQmBvheLrtBV6aiZef4ff+z 1wZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bbD5pl2lVnLaK08ia/VKbSbygyDTXnLrFUifoXgtAks=; b=BhC8ScSFyObzOWGit0EFp1mEDFUyQpH8fIDEDrB9SkgGKAGUJshDbv8zoYUDDgBWyC uHwJt2h43ubiwmIfoUUr5pYndSP+ZsemHOHrxt5AmDnrziFmktISmUipzOQmXXEELmsG IHH5Cj1RJBQl7QsroIxFHHFcapfzDYywVihS2uCLzxZwvqgY3ClIWOLYSychNQBN8aer S+qL61/yC2TiWdxM6ogBWyih6cgdyDFYoci9nOA2QD6s52AVdatmLRrUVqamnsivV2UX RIX6W80J/RUHD30hJmeF3QwKrVbjEZ+eJ3rHWxjQ+q088sngQfrJt5MMC+oNKDHz02Uh zJ9A== X-Gm-Message-State: AOAM533KTjp0IshcME6yrsxlWehPHvEG6wiOK//AF+83h8/eFe8Af6nA I/A0ArmXyPW+AFUlp8m1v7m8E4CiUEeKWA== X-Google-Smtp-Source: ABdhPJyigkfIYIZ22R8UZsWvtAQDyNvE+vN9DPGskah8CeoKRutRG/07byjxxIv3RATalkbJltNDDw== X-Received: by 2002:a9d:1726:: with SMTP id i38mr10027538ota.51.1624040772159; Fri, 18 Jun 2021 11:26:12 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id n7sm1901842oom.37.2021.06.18.11.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:11 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 27/45] completion: bash: change suffix check in __gitcomp Date: Fri, 18 Jun 2021 13:25:00 -0500 Message-Id: <20210618182518.697912-28-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 ebf8df94e8..e7308b212f 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -346,8 +346,8 @@ __gitcomp () fi break fi - c="$c${4-}" if [[ $c == "$cur_"* ]]; then + c="$c${4-}" case $c in *=|*.) ;; *) c="$c " ;; From patchwork Fri Jun 18 18:25:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ADA1C48BE8 for ; Fri, 18 Jun 2021 18:26:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 610A8613ED for ; Fri, 18 Jun 2021 18:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236312AbhFRS2e (ORCPT ); Fri, 18 Jun 2021 14:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236326AbhFRS2Z (ORCPT ); Fri, 18 Jun 2021 14:28:25 -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 DBBDFC0617A6 for ; Fri, 18 Jun 2021 11:26:14 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id q5-20020a9d4b050000b029044ecc922d44so328188otf.7 for ; Fri, 18 Jun 2021 11:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h4KCGaVavbYXhHWlt2+XttNVGAlx0V3Dfsx+2+lv5Z0=; b=C2fbKUrlADZovlHgMNgrGKooonjhpX8eMM+nqP+cXX8kH7JiO/Twj/auRbgPCb436C MuzZh58mHvoENVxVhaZL4puw/kJaXCdC/w+6tf5GoKxSOMIuKdho2P24hrxSJNvbUtWy qvHjqTe+2fY24viPydijDN1um5dRyDfcx6pAdDvM3a04vLOI2D7ZYsyJmm2gK8Ff/fZ3 Hd4dfrMKfK7GTKBpPfdP3NIgraR3hUnMYHi4JLgCCB5oIDjoUNLrkBv4ECratkaemziR aSb9qRpRt43QnkkZkKnzL3awEcWdtYSjqjv9vP/vM8K+xcwEHvTyilNzK/c3vLTfb1jB q2Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h4KCGaVavbYXhHWlt2+XttNVGAlx0V3Dfsx+2+lv5Z0=; b=aIWfnB2gBTEypGCfG/rCY+vizlYURfJKluS/ZXTpeUfj2AaJp5AQvnjEn7P5YIQQVr jFbQAFwHeMXh30IdTxi9GloM+DOVx9kIb0zVEkFs8solSnt37xfIT9ZRPFTFRrAaHlEy 6EtzekiCaylBMZ3DiYgnEWTXxQzhlkdZ8xq9I1pXkweYVt621RXIEbrlpGEq+VLHv2un Z/aCFVsEhKoDCYkDdf8axeD/V3JO6rBGLeqyO9HoYjExaWurD5kVdjegKCHUHCMgjorE AtcNeKNVaYVxCPLORzOr7iMFBfqBkK6nuUbJsgkvfZ0xCUt6A7ZNkNT46Jy1OrzDdURB W9PQ== X-Gm-Message-State: AOAM531uGXxsYAa0jBprAin7E7GFO6Pl3POrcsLoiAJijfCPhiLw2h/d myfjTZ68u1AeT1AV0pb8bGRp9oRq4KsVHw== X-Google-Smtp-Source: ABdhPJygiX8zLw/ctwl1o7OdWLULpi6f0HeHWTXlN5Demx8GvYwwKqQknWgV1Ncad68lLCt2dLbceg== X-Received: by 2002:a9d:e8f:: with SMTP id 15mr10349542otj.334.1624040774056; Fri, 18 Jun 2021 11:26:14 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id q1sm1909155oos.32.2021.06.18.11.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:13 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 28/45] completion: improve __gitcomp suffix code Date: Fri, 18 Jun 2021 13:25:01 -0500 Message-Id: <20210618182518.697912-29-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 17 ++++++++++------- contrib/completion/git-completion.zsh | 18 +++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index e7308b212f..c246d664c3 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -334,7 +334,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 @@ -347,12 +347,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 } diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 6008a73816..b81479c814 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 Fri Jun 18 18:25:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FA9DC49361 for ; Fri, 18 Jun 2021 18:26:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07FCE613ED for ; Fri, 18 Jun 2021 18:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236346AbhFRS2g (ORCPT ); Fri, 18 Jun 2021 14:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236360AbhFRS20 (ORCPT ); Fri, 18 Jun 2021 14:28:26 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E01C0617AF for ; Fri, 18 Jun 2021 11:26:16 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso10529107otl.13 for ; Fri, 18 Jun 2021 11:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ySJSiNT4qBvSxuWCbFPtxFVboJ8GrxxtyeLQECaRETI=; b=eb0YDZzPg352r3tJNuGRNcVpBU35ZTvPQXCVwcOUOFdgjRgvv45F0UXRskn7Oi0E2b QVWaj9QBohXAHPg7rUoX1ExDgw2hf66XiZmrvpPXske5lE+TVLsKlwM5QOCAB1AFxIRm jNB9HHnlYb3pU9lB7L1yYk22nGNgBfNzBX57idcPq7LnbWbKZ9bs/yzkIC+6TfGF9cZu 9QcpFW8+TktZkGdLeGqbV2tTuXz7PgZPurfY8A0ZREuYAPzWbpVM2Mz9lpHx3yCmuLcV YyvUAn8g4cZOK/uSNrbVug5dTXn+pHHk4d7uHsPQX2evUZNrY/FWWudgSS2B5PLuSD03 oPMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ySJSiNT4qBvSxuWCbFPtxFVboJ8GrxxtyeLQECaRETI=; b=rh04umIIM6SqhXm5a35GpEa+iukFNKS28X5VNFHajOhZOOYrXjNrqBcAGF/wabXfEt DGxfFUemZOEzTLD47pl/GbWEj4tpXZ1T3g/yitV4xpca3YyN8R6yDnY2gAHXVuMWuqsT vjmKMV0Y5AGvtlFQ4EwHRmgD7g6Gz7MG/411oVL2JMzL8EccKppD0uFvi2AJ5FKqXgAx e9iZI6sHbCIxMFpvAb5Gn606AQ3MShTUUE/PLjrYT+4tt5LF//Btanc1YxrAPCmOHaT1 x+ALi8Qvk4Zm51d7y+RMRCglPRh9829u7bV/Tq+PAiHfyTmm9lBqDv5IQECWy/ORyRxU JXVg== X-Gm-Message-State: AOAM533KlxhhqT+faDZiB35pc9J55Pb/essaEPnEHqg76GBytiVy/mWB MxnVzhk8txjxaQWzA8PqdrsPCKV4i9ZFRQ== X-Google-Smtp-Source: ABdhPJxUiKDSu+JbwNG6TwkTbt8Av7V2b4l4WSEJ0B1UbOT1ETv19v5xJvtsCqVLfA55+tkFvuPe3w== X-Received: by 2002:a9d:589:: with SMTP id 9mr10615008otd.65.1624040775883; Fri, 18 Jun 2021 11:26:15 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id 16sm2152185otm.57.2021.06.18.11.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:15 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 29/45] completion: bash: simplify config_variable_name Date: Fri, 18 Jun 2021 13:25:02 -0500 Message-Id: <20210618182518.697912-30-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that we can actually pass a suffix to __gitcomp function, and it does the right thing, all the functions can receive the same suffix. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index c246d664c3..cb25916f65 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2585,7 +2585,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 @@ -2607,7 +2607,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.*.*) @@ -2641,7 +2641,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.*.*) @@ -2657,7 +2657,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 Fri Jun 18 18:25:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE1CEC48BE8 for ; Fri, 18 Jun 2021 18:26:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 951A3613C2 for ; Fri, 18 Jun 2021 18:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236362AbhFRS2i (ORCPT ); Fri, 18 Jun 2021 14:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236367AbhFRS22 (ORCPT ); Fri, 18 Jun 2021 14:28:28 -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 43004C0613A3 for ; Fri, 18 Jun 2021 11:26:18 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso10529179otl.13 for ; Fri, 18 Jun 2021 11:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KcuRercXshr8fVDxo4roWVb7XS+XuYh41b1LArPaIh4=; b=lbOTHTIS2gLdmjKpH8UMOZvFlnsc4p8zpCv2XGHZOdPfRiEorwBcbWhZxSy2iPr2R3 W3THOiomV/TwNvdq3etpRTfezvSATOTpuAl+grmdacnx1ixYypdsiQu8yCDQ+WscX2oO vfueTbCIiZRVvjKO26JSu6M+bUjNogYmfbOe0s2W14195K/yycqRYb64bgAUq/XHpWji 71vzuF888sl19aOnDt8ucWv5sGown2zxXEGxJYSde/iFJJQ59VkoJv7kCIB22M7kEZow SxNIsRwQEmfO5Bvijx63thjryR55N5zc3acSHhtMNjvfeRapD3vTph80ms6YNJEpBbiv Z3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KcuRercXshr8fVDxo4roWVb7XS+XuYh41b1LArPaIh4=; b=NBPZ4PnKFS3Aizh7dBwrxQ6mpyuLuR/pCTcE8RrKO+WIQSFZ/3K6URjgd+gKURAn2H WyVLAwGXEFpWK8IvYuFh+N+Qsmu1gUZfyBGdbL71maSfefHcHqrLJDkvTBaYH2VOS0jX Skq/Hg/NzqvI2uPvvllp6FU9KLcmXNcTEPw8XtkFhSPE+iJXQqF/jSTiygCSohvKiXVh kvMQaave0uEjWVGAEMkoSAl4by7+InaC0BAP+agfVJG0LW4Ck89VtXZVxLTIUwR+yx6c U/ZbQh9I7y2M1Zp9tb5PnL1CB0MmZM8z1bBX0oJjn/fOHInNrKnQe1XK9bS4R1d5+AJ1 sb+g== X-Gm-Message-State: AOAM532W22C4GNT9UNcgYbUWZoMolbyCqujAZ8IM3Y0ldngi0/4kgDKa QTrKF9N+mdK83zm6rBEd6UIrBlUiDmVyxA== X-Google-Smtp-Source: ABdhPJyaPjCMy3zlEUC9+4t7j3jtfnmft+ySOgvebh+sc+Ff2RL7KSvg2EdMUsTdBrP7erbtFkHwcg== X-Received: by 2002:a05:6830:1387:: with SMTP id d7mr11077975otq.61.1624040777458; Fri, 18 Jun 2021 11:26:17 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id q1sm1909183oos.32.2021.06.18.11.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:17 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 30/45] test: completion: add missing test Date: Fri, 18 Jun 2021 13:25:03 -0500 Message-Id: <20210618182518.697912-31-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index bb3eebffb7..9803878480 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2335,6 +2335,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 Fri Jun 18 18:25:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 059B5C48BDF for ; Fri, 18 Jun 2021 18:26:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D60FB613C2 for ; Fri, 18 Jun 2021 18:26:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236390AbhFRS2r (ORCPT ); Fri, 18 Jun 2021 14:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236345AbhFRS2d (ORCPT ); Fri, 18 Jun 2021 14:28:33 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D92B7C06124A for ; Fri, 18 Jun 2021 11:26:19 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id l12so11486065oig.2 for ; Fri, 18 Jun 2021 11:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nODSHHAKBDo2grTSrVsZagzbFmQoCQJ/QtqVcd0Obsc=; b=huvIN6qZWXtxZOQnkBZaeCYgivnYOLHrfQ+OLhnkAZb3BYh1yV7IkQ/EZfqHd8fBdN z+9r3mUgUK1RwDJZKTVvvU6wClLSlRl8uuCRjSCuxfQyVf/CA/kQBRjxrN1FC+LUH8l1 oSSxWbWLocCwxNuKbB9iBgXMhji30fHWGCGZv0JtKMO9vzra6nM639rlrO/xmKihoCFg kYLR+7XUXbRLqBuo2555EOizHNpECWwq+Yy5Ka1wYZAdGka4vz3BgbgGo5Z+jvlhOgXq pqP0CWoSLq98+cwKEMlGmlyGA0FF7IytTeiUafCkshxYmrPjAh1LvcOD22phfpxrf7fp c41w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nODSHHAKBDo2grTSrVsZagzbFmQoCQJ/QtqVcd0Obsc=; b=KiXmoJHkwR5sA45Uhen5mwcCFOnaiQj/1gIr4HxjapvSBDbmhN4BmIb+Occ2PcExBE Nwa54C8ve7dcPDYweCBZS3TgQ8G9YecWskMJB84Co5RC30iFXp5YMppm7qgvh+vAICb4 YRhQqIE8egZHbcIDdi1Ju/IAQ+eRiZD8cwvC+SjOjh+x9zsFJLLK6PjNvpFp86tTG5SV yESYRXQSaSuxWPqphuyBAYednfFmsb3YH7t/63gGznV5Tk6E6APPj0RhmQUBJromZYqe kPvLEds3FUfSWiEebACbds7JHaO+GZf7uVAF+qhcplmpEKhRGby5cYjeGHOk7ZaXp9fx TdqQ== X-Gm-Message-State: AOAM531bdtWPFxGAsqnpl/uu/QsbL9AzghXuJGhigCglJVl+JHT6JzWc GWhpIX6XZZabr1MJH0wkeDjGk44FWGDqEQ== X-Google-Smtp-Source: ABdhPJwpaE2KF8PkE0XKvANt5jAZHci99quP3PENmNQdN8py9OknA1vvmDiUknFulGvYNtQS/ZlRIw== X-Received: by 2002:aca:2804:: with SMTP id 4mr8037392oix.141.1624040779115; Fri, 18 Jun 2021 11:26:19 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id q26sm1999885ood.7.2021.06.18.11.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:18 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 31/45] completion: bash: improve __gitcomp description Date: Fri, 18 Jun 2021 13:25:04 -0500 Message-Id: <20210618182518.697912-32-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 cb25916f65..0218ae7eb6 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -319,8 +319,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 Fri Jun 18 18:25:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 457C4C48BDF for ; Fri, 18 Jun 2021 18:26:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21F5F613E2 for ; Fri, 18 Jun 2021 18:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236342AbhFRS2t (ORCPT ); Fri, 18 Jun 2021 14:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236358AbhFRS2d (ORCPT ); Fri, 18 Jun 2021 14:28:33 -0400 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9386FC061224 for ; Fri, 18 Jun 2021 11:26:21 -0700 (PDT) Received: by mail-oo1-xc29.google.com with SMTP id b24-20020a4a34180000b029024b199e7d4dso2345027ooa.4 for ; Fri, 18 Jun 2021 11:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t5fMuLSySkB2Tfqy24UjCGYy2iCrTsJPheQtcjVpzbU=; b=LF0t5PFe+2Desf2CsFYFXTSy3mPvE51pky3mRWH9j83OkjGWvh0FhlGCXYp6qa0DVG HwGHL5fkG+SJJ2HzY3A+JJbfRTK1YMwXL040QC0v1+8bUhRv/yFZ7juv3yIq/pSF2to8 4B4CgPWI1qf/Wb+xJYwGizikBPi0Y3p6HQWcvFvXoRpBS+nEn75hRaapjozJ24HuwVjo s9RCzxx6wsDQcOb9dfzfXKDQTLwce6/ctDBtDJ8y2JTo9B5E1W2Ea9b7ZN4FrwjI9LFB mkJ5aaUrfELjNslQ5Pz/sytYX5+CC/J/wbUOICFg80ZxPscXviECZNPuyHfbpcQiP5et FMjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t5fMuLSySkB2Tfqy24UjCGYy2iCrTsJPheQtcjVpzbU=; b=aA4QcKgExAyWOgCOC8zyEaQdD+p7Nt8kbSkJyJZ1PcVatAJFIJl/7C3X2aAAn1N5HC 0RVmAmos9R/h1StNfy3LDMGi+uA91vOPSF/HsOtmvJwBiePwCaHVeKEAiZmE8tPJUsm0 dPpg2kX/6bdm4Zvo1gz8mgJVXBPewJfKNTIGpSQp/hVCafRcQ7plDxtd7QnCXVQOE2z9 7oZ1AClEAOuYKYKWIfltwbH1ddCIx+Kz7C6RtCfvZTtI/sNOUhx10clZUOMPpeG4d4rm QGRG2kLNTc7NItJsP0O1C0vxupo0UXKdL3CXENGLcHkh/5Tz3k+dHYzpHlY7Jph1qY2u SLtA== X-Gm-Message-State: AOAM530VilTfcP45RWrE4I8PGyDBb2Anf2u4K825YUx5eH7L2AuwS+8E +IXvrEGN3Ree8HjF5eMS+M2bJvMob9irog== X-Google-Smtp-Source: ABdhPJzIhyOVJ39qemz8wRPyS5Q9EIfHh0DFNirm2k8VmsFvc1HzOUcEbipxYvZNjsfVwfFSod6Hww== X-Received: by 2002:a4a:315a:: with SMTP id v26mr10077841oog.75.1624040780637; Fri, 18 Jun 2021 11:26:20 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id p9sm2105653otl.64.2021.06.18.11.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:20 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 32/45] completion: add __gitcomp_opts Date: Fri, 18 Jun 2021 13:25:05 -0500 Message-Id: <20210618182518.697912-33-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 | 100 ++++++++++++++----------- contrib/completion/git-completion.zsh | 8 ++ t/t9902-completion.sh | 58 +++++++------- 3 files changed, 93 insertions(+), 73 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 0218ae7eb6..8836eab884 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -319,13 +319,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}" @@ -369,7 +381,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 @@ -404,7 +416,7 @@ __gitcomp_builtin () eval "$var=\"$options\"" fi - __gitcomp "$options" + __gitcomp_opts "$options" } # Generates completion reply from newline-separated possible completion words @@ -1041,7 +1053,7 @@ __git_complete_strategy () return 0 ;; -X) - __gitcomp "$__git_merge_strategy_options" + __gitcomp_opts "$__git_merge_strategy_options" return 0 ;; esac @@ -1051,7 +1063,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 @@ -1293,7 +1305,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 @@ -1553,7 +1565,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 @@ -1711,7 +1723,7 @@ _git_diff () return ;; --*) - __gitcomp "$__git_diff_difftool_options" + __gitcomp_opts "$__git_diff_difftool_options" return ;; esac @@ -2005,7 +2017,7 @@ _git_log () return ;; --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options @@ -2068,7 +2080,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" + __gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui" return ;; esac @@ -2216,7 +2228,7 @@ _git_range_diff () { case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --creation-factor= --no-dual-color $__git_diff_common_options " @@ -2233,11 +2245,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 @@ -2679,7 +2691,7 @@ __git_complete_config_variable_name () for (s in sections) print s "." } - ')" "" "$cur_" + ')" "" "$cur_" "" ;; esac } @@ -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 @@ -2960,10 +2972,10 @@ _git_sparse_checkout () case "$subcommand,$cur" in init,--*) - __gitcomp "--cone" + __gitcomp_opts "--cone" ;; set,--*) - __gitcomp "--stdin" + __gitcomp_opts "--stdin" ;; *) ;; @@ -3025,7 +3037,7 @@ _git_submodule () if [ -z "$subcommand" ]; then case "$cur" in --*) - __gitcomp "--quiet" + __gitcomp_opts "--quiet" ;; *) __gitcomp "$subcommands" @@ -3036,29 +3048,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" ;; *) ;; @@ -3099,64 +3111,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" ;; *) ;; @@ -3396,7 +3408,7 @@ __git_main () esac case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --paginate --no-pager --git-dir= @@ -3447,7 +3459,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 b81479c814..e515f464ab 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 9803878480..3dbb5eb121 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -101,17 +101,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 } @@ -466,8 +466,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 @@ -475,8 +475,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 @@ -485,32 +485,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 @@ -518,44 +518,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 From patchwork Fri Jun 18 18:25:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CB2FC49EA2 for ; Fri, 18 Jun 2021 18:26:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87318613F2 for ; Fri, 18 Jun 2021 18:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236364AbhFRS2v (ORCPT ); Fri, 18 Jun 2021 14:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236381AbhFRS2d (ORCPT ); Fri, 18 Jun 2021 14:28:33 -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 167ECC0611C3 for ; Fri, 18 Jun 2021 11:26:23 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id w22-20020a0568304116b02904060c6415c7so10613340ott.1 for ; Fri, 18 Jun 2021 11:26:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=74wmMndoRRJg3xMKh4g50ca2DD/m8DEKi9iYUiJ0NE0=; b=np9klRzoEUz5ZlZhdtIFiPhms1/V5tMYTOXV2hJVy2yKjM0cplyzTYNwZujw+LLqQb Ds6m3vjv7++/OZslTi1JlNlDnTA7N2pMyS+qoJFv16Ni1M86XCLVznvyeLTDurYE/SKX hxIfkFNXHd0LdWzX+zHrPFZQj6nWnA7ZEdWSBUP9h/mFP8zSeqXZEkj4rCxadFNN5V6o 8GxGgeshT57uT8c52nIjKwELq4HIzENyOsKCunEegbTi1SMx7wS5Nu2OUHhJVtbvfxFS Sa/vKStAwIgYJj8dIRb5FkTRJG0JGTRe2+66WqeKdGQrxbHeXxP5anBkfIJ+BfHIeA8p GE8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=74wmMndoRRJg3xMKh4g50ca2DD/m8DEKi9iYUiJ0NE0=; b=SB/jt52iiK6UE35lFCx8TJP7bMIj6NKqfSS/u4avoD6knmSJLpwmx6Gzjmuz+19Rx1 lmOuafqIJqdnbA+Od15yHEHrh902cDQhcB9KHkw6oTLKMQfdBccIfWn/Big0qB3rRFiP 4PumtfEjMrfyaqRNu3Amu0PVhB3C4X8fn5+pe9Q5aftDHOmt1oL0FAAVgaVHX8bduRSR X5o8PvcP6c3ynIZZtA4f/IR0HOgartjKgJVSG1QLwLiz1RxCW5rH0QbKk415OpTpR3CG JG1pQo1fuz6wSGBJVLlI4klSz+OgPvu+/2aeSvuvbmOiyUTUO02Qo1J2HP5f8Ffq1HG2 mmDQ== X-Gm-Message-State: AOAM530dAOO1OefJDG37dBg0DNgyg5Y6aAcs/bKRgw07HraDDdN5leNr QO6MtnCkuwiM99KIVcW8uet7C6o3bhSmrQ== X-Google-Smtp-Source: ABdhPJwIiTRVr84JrBYVdMNn4VijA/ziN9L4IOfJloPZvFwNPf1gTCFEcHuh3QgtPtyBUSqQfZczeQ== X-Received: by 2002:a05:6830:20cf:: with SMTP id z15mr5552707otq.221.1624040782266; Fri, 18 Jun 2021 11:26:22 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id y9sm350104oos.14.2021.06.18.11.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:21 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 33/45] completion: bash: cleanup __gitcomp* invocations Date: Fri, 18 Jun 2021 13:25:06 -0500 Message-Id: <20210618182518.697912-34-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 8836eab884..7a27347d56 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1369,7 +1369,7 @@ _git_archive () { case "$cur" in --format=*) - __gitcomp "$(git archive --list)" "" "${cur##--format=}" + __gitcomp_nl "$(git archive --list)" "" "${cur##--format=}" return ;; --remote=*) @@ -1782,9 +1782,7 @@ _git_format_patch () { case "$cur" in --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --base=*|--interdiff=*|--range-diff=*) @@ -2290,7 +2288,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 @@ -2314,9 +2312,7 @@ _git_send_email () return ;; --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --to=*|--cc=*|--bcc=*|--from=*) @@ -2618,7 +2614,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.*.*) @@ -2668,7 +2664,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.*.*) @@ -2683,7 +2679,7 @@ __git_complete_config_variable_name () ;; *) __git_compute_config_vars - __gitcomp "$(echo "$__git_config_vars" | + __gitcomp_nl "$(echo "$__git_config_vars" | awk -F . '{ sections[$1] = 1 } @@ -2785,7 +2781,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 @@ -3430,7 +3426,7 @@ __git_main () then __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST" else - __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)" + __gitcomp_nl "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)" fi ;; esac From patchwork Fri Jun 18 18:25:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3857BC48BE8 for ; Fri, 18 Jun 2021 18:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20ACD613ED for ; Fri, 18 Jun 2021 18:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236401AbhFRS2x (ORCPT ); Fri, 18 Jun 2021 14:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236352AbhFRS2f (ORCPT ); Fri, 18 Jun 2021 14:28:35 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD0C9C061574 for ; Fri, 18 Jun 2021 11:26:24 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id t140so11557874oih.0 for ; Fri, 18 Jun 2021 11:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2nwWWpUfzs4RJxtlSlPNsY9lrFEAT33e5VGjeoX9IBw=; b=pk/2oCgek+HRtFPkViPNZxbW4ta9C3sN9UqOqY0T4ZFFbdFel+sOe2blS4IfelVW47 0ICToTIPdkieUersXQDojIgXUTU+fKDkwaT35YIFZzK35xoOgDJ90y3UqrGqqo6QwXaE BhWoIMpR+rBOYCYZii5ZdLk1eJegZWcJmf3mMrC1Kw7ON25EqTJLcNxT8TCR4TH5g3k+ 25AeAcDc/tJAMYQc1zqzcvORwmMKeR9fEkbESfMqzcvW8bzXhjs3GG44LvtiiocT3hMd qEG0qdXFI77NzhZ5/LXfl6JMbvAObZGpr9SiqcsWZF4R6rOBRJ5wvRcwKR6IBdpo4brg ks9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2nwWWpUfzs4RJxtlSlPNsY9lrFEAT33e5VGjeoX9IBw=; b=Ygu/2mtYBhIgnFWlAzxEBENPijQKpc97wKLi4/boHxilfzOBob63khHzwCwfQz4JPe 9vQRwN82NkgmlwLPdPQ7hbteAysn8DdGGhqbScE5ZuS8nVMG33hfErDmNd/rQn28f9Lb BFd/paLJSaifF39nyMdZquYDd5E6RIoMPNlLDx610vIGYxek/T5mtcEAvZ57b9vE4ICZ Obdg5EtcT3Yj8Rw6kmxptHdcIURVC7EQZwEwWrdcC5cFTu1Tke/4srADAjAekPj7hLdk j/xhiszvCbW/lcUCjJjBxBo7Fh+rqtFmUal2ojr7/qYUgfCmnrG46a6oPB5sK6C48BYH WAZQ== X-Gm-Message-State: AOAM532cVjd/ZgMyf+rKUnMr4IYhPKNI7CResWKeybhDCQKVVjnqD9/g NkKb3TivYB5JPeWm0sDTaIVo+88KONs0Ng== X-Google-Smtp-Source: ABdhPJy6xmuMvr03Yl02p3tmfIerbxyXMDqD4yNfE5p9Rd43h7TBUOqTyVXIPQdksPrBksr32zlrDg== X-Received: by 2002:aca:3986:: with SMTP id g128mr8257189oia.159.1624040783878; Fri, 18 Jun 2021 11:26:23 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id f63sm2192645otb.36.2021.06.18.11.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:23 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 34/45] completion: bash: shuffle __gitcomp functions Date: Fri, 18 Jun 2021 13:25:07 -0500 Message-Id: <20210618182518.697912-35-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 7a27347d56..47c96b918e 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -54,6 +54,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. @@ -296,81 +435,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 @@ -419,62 +483,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 Fri Jun 18 18:25:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6170BC49361 for ; Fri, 18 Jun 2021 18:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C47B613F2 for ; Fri, 18 Jun 2021 18:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236402AbhFRS2z (ORCPT ); Fri, 18 Jun 2021 14:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236361AbhFRS2h (ORCPT ); Fri, 18 Jun 2021 14:28:37 -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 5CFDDC06175F for ; Fri, 18 Jun 2021 11:26:27 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id 5-20020a9d01050000b02903c700c45721so10584641otu.6 for ; Fri, 18 Jun 2021 11:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hMQbZWO74UAehI1PYSRscHwSL7VdobUcxTzqxMSnjYE=; b=XIh0LFCxXekEncmNLvOeTHDqODZDlU7KO0xMOo29/xVuCh4f62/AIboLXD3nIXx+AH YeMddwZIANpF309mI9srSMT/iUYhtXscd25fv8SsOXIVRcdV8uRvtVqfuH3oXHaWQsH8 OUF1f8MZpLX8ftT/lhleRPlN+pSGXKjT5hBz/3u16riy2ieyfjz/s3c57sLAD65NEmtC 6mMHI3ubJVaIfH3gvLOiH4JxDUq8lib0ZznDTyVcPmukifNKFH8ol+Np/zf9y2jEpuH8 BjGLvhqwoyK79RJXeuF0hG4AL8Hij9IQrnqoklxTkqp3FOGrlJvTItWlkbQZzKB5rzrr /yaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hMQbZWO74UAehI1PYSRscHwSL7VdobUcxTzqxMSnjYE=; b=ghe0QXjZo+IV7fesYM2bG23tpXlnFoVM3dBrtFvncetqQu5R1pClaja3/5JZ+gdBi8 vOjgpLHuRDp3JXJaVWkxlmcY1K7ke3rjag47zqWncjfbD9kPjpXIZ8c138ikGe/pku7e 8YybQRhs5hMcoCrzh4ozOE177p8IZVsyOOoHbZPrF1eRl9iF90LQMAOp8RsfKJrAbBut 3DRm0s5MaFdfJ9MTF7pu6FPf7D3HF2gY8DWvZqJh8OQFBe2WypdvAzSaTbJ1W4NQuRSW 5MSjPw2wi/hKiDgPIytyhjmkY1m4U1Sz29vcF+UObt5LCCN1PNqQFKhr81Xf2y6hulLK 2yZw== X-Gm-Message-State: AOAM532dW59vG+JMPj4DIziSovv0skQW81+lJ2NONoqklL0H6nQ3YfyG /cLO6e8EHG+v21hpVgu874MEw+pgiIasSg== X-Google-Smtp-Source: ABdhPJw7XFiwOdhU/92RxJug9G9M6pEnhlnzS7kIVtyE9ynZ5O4NwDAes8y/7O3BEvx/WojjluRmyQ== X-Received: by 2002:a05:6830:181:: with SMTP id q1mr10708032ota.360.1624040786588; Fri, 18 Jun 2021 11:26:26 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id e29sm1982127oiy.53.2021.06.18.11.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:26 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 35/45] completion: zsh: simplify __gitcomp_direct Date: Fri, 18 Jun 2021 13:25:08 -0500 Message-Id: <20210618182518.697912-36-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 e515f464ab..bfb5c38a3c 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 Fri Jun 18 18:25:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E2C4C48BE8 for ; Fri, 18 Jun 2021 18:26:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59001613C2 for ; Fri, 18 Jun 2021 18:26:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236374AbhFRS25 (ORCPT ); Fri, 18 Jun 2021 14:28:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236369AbhFRS2n (ORCPT ); Fri, 18 Jun 2021 14:28:43 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37D73C061768 for ; Fri, 18 Jun 2021 11:26:29 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id t40so11499953oiw.8 for ; Fri, 18 Jun 2021 11:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l4OUJ0MFZciuomuXAL2m2mr7Epmp/zVr+QKarkFWi1Y=; b=aM8pAsaUYkOH5uEgzWW/GYLW2jJZ7z9iRwSe48tb6xxuaTUmR6iM+u8596L9TD9+xM 5rEqaDNhdyLNMhP7SCUsAk5aQ3e4/a37Vmd/flUxZaDBWoDhq8+HQd8gHnyBrDgN8SGD yeh2U+wfxcY5OJH5te04ZQS8zRPyTUIrGyE4IzvdvJnVQMX+GITt/Jn6JuF/8bqc/1CP Ed0Tk6TKhrCXbjKXRwW3I+NyhZ4IlUQiFfZtz1nNmdTUKVsXReNCzcnAR5PuBiVSY2YE Z8i8nlnPVaEPCg+XH7Raud8CkdOmKnZcPbQSitpY05i3dVYYzOKtXf6SHa7TcMTt4guh OnNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l4OUJ0MFZciuomuXAL2m2mr7Epmp/zVr+QKarkFWi1Y=; b=iSsR/wy98n6Y6t3AE7IjMhDzl+YJsHrwcuxcGmTeafjABKxt5b3QLSj+6B3jPEYty3 QaBOQaqyYzO7n6nMyMSb4rxDqeJuEKTU4QNsizMWB2I7lW9A3KrvWo6/HSjh1iCr0Xy7 rgv0awkBcLsObMRzOux9q7JGZy1f/wXcaJLXsOKU74WbsnN1+AKsxa5V4MS+1lBopTSw xiLm4AAkiouWWK/8MNwAe399m7kGjK16hA+RqAIgbZbIs6u2y8WZJ45mU0Etg0Ha01K5 hGcjy5Fowu9+zz5lP++RE4nEFolMIRCoISPHbC0tt7RFrTorc0D0xGXi0/h7tpb769l1 2p+g== X-Gm-Message-State: AOAM531XOTqsHrSdYzvT8TcDmsMxpItIFYUidpEp02BrxIgN0ptduUil VkwSV10wIFrGfEXv000LRtSa8R4gllPoUg== X-Google-Smtp-Source: ABdhPJzoygKVPYW1ktq3XCmL9tFp2NKHnKpXXq6bk/5ZR835iYI6mPeRe7/g4O07qU4eBXGuR5GBqg== X-Received: by 2002:a05:6808:200d:: with SMTP id q13mr8459310oiw.24.1624040788465; Fri, 18 Jun 2021 11:26:28 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id d10sm1541207oop.3.2021.06.18.11.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:28 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 36/45] completion: zsh: shuffle __gitcomp* functions Date: Fri, 18 Jun 2021 13:25:09 -0500 Message-Id: <20210618182518.697912-37-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 bfb5c38a3c..c4510a3180 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 Fri Jun 18 18:25:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 107CFC49361 for ; Fri, 18 Jun 2021 18:26:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF84C613E2 for ; Fri, 18 Jun 2021 18:26:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236384AbhFRS3E (ORCPT ); Fri, 18 Jun 2021 14:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236383AbhFRS2p (ORCPT ); Fri, 18 Jun 2021 14:28:45 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C03DDC0613A2 for ; Fri, 18 Jun 2021 11:26:30 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id c13so11464188oib.13 for ; Fri, 18 Jun 2021 11:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RtBFRg4YIY0Ft23J52Bewvp56U72amuajVH1wIdgxT8=; b=cYrTGf5+KbK1JWI/CPSDp9aBhkKLAtgSrttZaHCMMtmZab2Krbl+lexxh0iJ8K/ovS jNCEwKOEvTp+njkz9hGxAYq6rNdmU65pjCXAFnzsmWxtkiflcmsfKCLylrqLQC/V4R+n s1CJ42cEkPwF7wn3zeM1o7SZAb20BcVPNP4XAO3XerzYxNydfBvuD/0ui/eDGKOJ637X xVBpH105P9W9mjYoT7udbN0pKgKeZWjnInyn7fDj1mCai5PVWHp2Uz0T6/m4knWLcT4u qgCj0b1aq1mGAuvNi2tXR2MCe1SuwhAyMlv0Prew8eTawKjXDOuvnJSDfQTgfqgA6cTQ AszQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RtBFRg4YIY0Ft23J52Bewvp56U72amuajVH1wIdgxT8=; b=EErh6/0p+4jnho2qGx5+O2a4o83ZFiBrvgula6n1IEkn5ZA9t+8hWFJBv7bhux5oKU JFxslJv8DAdpUlxGj2CXcSIC599ih6sV102+HFQ4uYTw1zVvKPrS2t0FjIwPnWCr2dHi JDa1bUcP3VSyIJY49OXNQLxmtKnhe1004kuC0wtZO/8t3t+2czC02u3+5jHmI31Ul4UW QVi8tci0jB9TmwIFVY4mKmDkFtA2nZ18jWjPu0W54K/r9+ukIUJA+IGHGMfTdZZNL3J7 L3T6PkixM5VaiWIoCfI1+gNKNsg9ci3IT48rAmFgRCtgZVJG3seIapMCuzmR3IDiHvJW pV0Q== X-Gm-Message-State: AOAM530/hTwOfDNX/fBR/dLIamPU23OZTcod99GxFb2X0m/HjqkaRBbH LFWQjvBe2BmMANtFakvvOeeQr9Che1zlRQ== X-Google-Smtp-Source: ABdhPJyMAwl1Sog8SL83MtAox6c00vqnnXdRh4xI8kvg2ebL0BGRD66i+r27eeop279wUkWDFdYy1w== X-Received: by 2002:a05:6808:484:: with SMTP id z4mr8171447oid.89.1624040790187; Fri, 18 Jun 2021 11:26:30 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id l8sm1952202ooo.13.2021.06.18.11.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:29 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 37/45] completion: zsh: fix direct quoting Date: Fri, 18 Jun 2021 13:25:10 -0500 Message-Id: <20210618182518.697912-38-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 c4510a3180..3818291950 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 Fri Jun 18 18:25:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1457DC48BE8 for ; Fri, 18 Jun 2021 18:26:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3831613C2 for ; Fri, 18 Jun 2021 18:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236411AbhFRS3F (ORCPT ); Fri, 18 Jun 2021 14:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236387AbhFRS2p (ORCPT ); Fri, 18 Jun 2021 14:28:45 -0400 Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0831C061280 for ; Fri, 18 Jun 2021 11:26:32 -0700 (PDT) Received: by mail-oo1-xc30.google.com with SMTP id x22-20020a4a62160000b0290245cf6b7feeso2670354ooc.13 for ; Fri, 18 Jun 2021 11:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dYRYdsZ2hbeblvImBFJ8F8DCsk7IRZLMqL7lag1gqps=; b=dUtxw1LKPkhlD/tT0gGW08QN/too2PtgVp6LoxYH/4jkG52woVG+RcbBxKvDGAeb2f pa7cA49ThFtIVhr2Ns92Srfhwa/R2NASx7PKdjSnP9jMjITJs8AxIG9Rk0RkC4zWXIU/ xmIVuimfdyeqDjW/wuASVGTdR2wyATAZlaSHjkbzjsaJ7VQLyIw6Je6G2t0+WfPoYFWb gH/wXcR341wD7wUNiLavpSUDDzemutKTO1f1kH7/gKKmfzC2u2t1fAj6/Pe/jwmSjzwp S9NF4/lEC6m6/GYOvdmR6fYLXL1No28IdAvm8xnM32UnSnu8WSUQLxk9ZNZfGuC9xSAr ylnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dYRYdsZ2hbeblvImBFJ8F8DCsk7IRZLMqL7lag1gqps=; b=ZS1XydZRowR6cPTN7EDF5372lCeJUP+DCDcOG/P7IvnsrRHng47+vzn1Qo6vAvxOlh 9BCQXgo+VeKLfGZ0OcQ+Xbog52BC9XC41JdyYnsK/qGSzMYkcJ/+xADiAy7qAi0yYvv2 MIsSVT2wha8xyOWT1tpTXeluXmq6PEiOGeDHAQz+E6m+1pJWWCydGhwti/YMfqSwvB3s BRxZ1OKgsVfR0PwgLfFhfWJ2ShGGhH+3DrbdvHJ/U3EzEY2SozV2w145YxIm2szePG1m HYKIFiPy10yHyWeg9yQ8T0fcuk8/3WIsQp0E9QwHHMYHnjtNU1wWNI+3qvoEzVGRkvjJ 4RLA== X-Gm-Message-State: AOAM531N/f4N6wqSobhliLvUTJfwzjvzbgfcic0acWtpLcTw0zFmzVAx sCEjSt+SXn6HFopyEPJU1sqTNpZDHvXaQw== X-Google-Smtp-Source: ABdhPJzeOWhm376iJfu08xXUOvS5L91rf4+/u/f3MVex5h5trFBSaCXcY3P8tdVqc+hQpL8NEPzd6g== X-Received: by 2002:a4a:3904:: with SMTP id m4mr10282623ooa.61.1624040791870; Fri, 18 Jun 2021 11:26:31 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id q9sm1862414ots.1.2021.06.18.11.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:31 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 38/45] completion: zsh: add elements individually in __gitcomp_opts Date: Fri, 18 Jun 2021 13:25:11 -0500 Message-Id: <20210618182518.697912-39-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 3818291950..a4b5e7dcc4 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 () From patchwork Fri Jun 18 18:25:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C763DC49EA2 for ; Fri, 18 Jun 2021 18:26:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA12C613E2 for ; Fri, 18 Jun 2021 18:26:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236415AbhFRS3G (ORCPT ); Fri, 18 Jun 2021 14:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236388AbhFRS2q (ORCPT ); Fri, 18 Jun 2021 14:28:46 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60714C061224 for ; Fri, 18 Jun 2021 11:26:34 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id r16so11525958oiw.3 for ; Fri, 18 Jun 2021 11:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IugA4e8sia2SfBnU7y99hb07IL8ySGm4SOBc0tdzo00=; b=Xqh5Th9nx20I+OkaJzDtPuRb8+ITHO29iVv62l/rYfQOLLpeKd15eqU8vo5BXJKAmK z9Yq56r1W1Zzphmzqk+FLy0iFEQFNf+T587T1stlJFPrFjUlT8RS0TCPs2/6g52u6mcE sI/LfXGH6+lSFoltULurwmZWjxZKw15yUDKN4+K9ZBMXemrY/8DeqDGUpJxv5kH24U+g Kp991iwpbXVmsI7ykPvRWQ5ZJg5NA+KYSBp42/YephVS+hKFHD2+WEND0Z/3Gux2TiZs LE6YBN52oKeD3GoyBxuCpoy2Ba+0wvbzMZJgk1vd8UafwJ2aGJeOlOTVI8+VTMxYDzPH OgwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IugA4e8sia2SfBnU7y99hb07IL8ySGm4SOBc0tdzo00=; b=hVEzHG+EZR6qaSwDCVlwDaMwkihFdY3XAvi/G0T0/1cQEjmphrAIsLyykLN0KLwOGd lBTRxTUmMsGozn/zpQ2yon+TUVEpSgx4Vru0sHssnAM1F18vA6AwoHlhEBC0oZVztr63 SQia8EUC5ExhWnb9FyxP14Ye3DW7xm5dF78wFc2L8c2BNVRIb9sHjVae9Fc9Qu5oX6k4 K1CNMrUsbk3L4QOXzIMRd+Zl/9iwlAdrOeiK0bZ1UbWEO2pxFxY3d0MxR3Avd5QStJsr mlSiiGOt301tZNmUX71FafyKv/WRdA96HF3sIcp85armlIjQPhfPwjlG+7MEDSfWyWkF U4RQ== X-Gm-Message-State: AOAM533XR47zqBRqWrHGPDpYxYLpUJ79RJmGCsHy3qX2boY5hKfX7W1q LfPhezpe7p20TGbRk3itZtUjBMoIhNY48Q== X-Google-Smtp-Source: ABdhPJyJ41avEFK3nD37wh9BO9dwmlJWWrrgSoQCS7F+j0rE2s84pKkxIeRsDJfvF3OnNc4H42rkeA== X-Received: by 2002:aca:c456:: with SMTP id u83mr8350981oif.86.1624040793506; Fri, 18 Jun 2021 11:26:33 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id f12sm2155735otc.79.2021.06.18.11.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:33 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 39/45] completion: zsh: add __gitcompadd helper Date: Fri, 18 Jun 2021 13:25:12 -0500 Message-Id: <20210618182518.697912-40-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 a4b5e7dcc4..0f2f0e5eb0 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 Fri Jun 18 18:25:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F8BAC48BDF for ; Fri, 18 Jun 2021 18:27:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38D2D613E2 for ; Fri, 18 Jun 2021 18:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236388AbhFRS3J (ORCPT ); Fri, 18 Jun 2021 14:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236391AbhFRS2r (ORCPT ); Fri, 18 Jun 2021 14:28:47 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33EE6C061226 for ; Fri, 18 Jun 2021 11:26:36 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id h9so11531861oih.4 for ; Fri, 18 Jun 2021 11:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k2PFJRuW8/CqHVD8/EdwwhC7Pvllu/Ues+vPXQxZub4=; b=Lpc6j4gufa3jWQesLXDZqYgJamOZOPFyCmgRZ6REWcYmsz6T36oU2qaHYcFWzeTY2Z //X+KopiSuMgB9WN5gpkywDVATMU761FQa8UESjUkUou3Jm+U8k1BQeT0DRVsk7qAdzC nljUAXsY3VB54j1HIU8S3cjwgrx0rIA5aOz/uGIhNM0L7kXZ5e/CnnGfci7qmHFXesev mfsQEsWNos39D9vENLpbsgbZq9oWH9t7sTEyxUkWVTm4wliO2y3ofZ+7i+FQENM0mucs giVnrET+0VQC98+tSxaAXDTnydrF/mkTFyK1FPR36GI7wEItpZWoxF5yEFmSu++o+FfW 25xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k2PFJRuW8/CqHVD8/EdwwhC7Pvllu/Ues+vPXQxZub4=; b=jQAv9jXc4wFIOQSVypwM7Fbz4Fkx2GOksIegpbrZMGhd/CPXctY/dN5qhzzTZGF7RA M+9LEyOUVKia2m7Pmd5NRhSl2Oi5OJkBhyUfsyTLD3og/ctN4S2Jl81KNIleL3bgDBYI w2JtSEmogib/nTfodLl9GR1Mf+Dc1HZMQSEwoKYxer/Fvqn1WDCjLuUjuyTg2g2rJw/+ Z9Oz9heyHPLhrAOZJMyr7peWTdUvIj90AOPkUVKXrinKjYIBAHGdGhH1XLgB3/4Gs3zi aY5jzvpTHQZtFPhntkPEQcERq3zB4CiGu22BbKq1Cei12zkFbbmkWDd2muhi6ZyeAB2n 5GoA== X-Gm-Message-State: AOAM533dGHHptyFc6GaCrCunQIoETKfi97p8WCSzD157+P+4i7HT2PuQ uLWlQW3yMKiwVeYXUGzkQyrhjpU2sUe8iA== X-Google-Smtp-Source: ABdhPJz+XfGY7Db+lyJCwYobhtuYLhqEWVefvm88nEnP4zC+kji8JcNd2vQ7nHQwAnehl9GpaK2n4A== X-Received: by 2002:aca:2102:: with SMTP id 2mr5030994oiz.122.1624040795404; Fri, 18 Jun 2021 11:26:35 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id w8sm2147241otk.16.2021.06.18.11.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:34 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 40/45] completion: zsh: add correct removable suffix Date: Fri, 18 Jun 2021 13:25:13 -0500 Message-Id: <20210618182518.697912-41-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 0f2f0e5eb0..d425ff1d81 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 Fri Jun 18 18:25:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F9FCC49361 for ; Fri, 18 Jun 2021 18:27:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D397613ED for ; Fri, 18 Jun 2021 18:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236355AbhFRS3X (ORCPT ); Fri, 18 Jun 2021 14:29:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236353AbhFRS2t (ORCPT ); Fri, 18 Jun 2021 14:28:49 -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 DBB00C0611C2 for ; Fri, 18 Jun 2021 11:26:37 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id h24-20020a9d64180000b029036edcf8f9a6so10601131otl.3 for ; Fri, 18 Jun 2021 11:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WK5DcBRoX39UMfCB5g6tpkfosOcIkrgJzYkuTqSHiHE=; b=D+zi0Gpuni5ycRbTUFCjlWzLRp6JYtSEytENcS4PgjG/CQcdmY3SQ+GWsAyF7wOrer nF489S6bPZXBoc4O4SaJuHUN4v8hf7I1PzoRAFCCKZ/z8aE2kOAZK/SYddQxthVsLfv5 TxMwBLEFaafO/+JKMwN/LFFLrmfXOevnk3Y+DRKpb5exh0uh56dlrybzGeGJLUCp+J9t i3k60QSQSRiQRTbUBE3h1+Au+lXSrwT6vqFpypN7dXh7Lcq3eulSrP+XS7Il1GwiR1Rd 1Eu7ngsSITpEU/IRBeS+aFGwsHt7OjuJd5VmtTG47Q7VFiGmzvFrQ+i7RzmCXFYqsvdo /usA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WK5DcBRoX39UMfCB5g6tpkfosOcIkrgJzYkuTqSHiHE=; b=tdflJDcb0CN16LN/gUL8P4ZAmVP/HKBLx7tJgldFWFHUG3R3y5j5s0ymOWSuh3NZ7n HBQPv3/YeC9Z3WxIGTpg8NfjqC+NNvKDzqERa0/ZCogZWsyIgt+12WHOtJtf5cHeRy3t c6Lm4JEslfC1SpTgYqEu/n+InxE0WJSEzSOv8rmwbAXQZA6bwjO1fLAcGxTR1gk4vpFj Un5ArLiUxkdW6r1uug7RnjdKIvuBlanmhh2J4/Z6vQQ5/rSIasDia7IWm5L0Mk21Fqyz Tmi2MyTSWlYpgtRSSB1Z1lLriiQwvANK7i/C3h/J9rvE++vrXnUtIC57/al+yYRhNz5d g6Pw== X-Gm-Message-State: AOAM531YzJ26g1CNsHuFYyPuYzs11CG9h+mCV7mio2ZcN5TAOs/C7jnK 49PCuAa9AqXP6ncMM9E4D2yXe/PGDVXJIQ== X-Google-Smtp-Source: ABdhPJzQsrr42r5856RX2OebfHgMBoTj1JxUkw5EO4uiCUHHk7XLBz2JhwpebyV44I4GSDEEEBaMCw== X-Received: by 2002:a9d:2222:: with SMTP id o31mr10566098ota.75.1624040797083; Fri, 18 Jun 2021 11:26:37 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id x31sm2134261ota.24.2021.06.18.11.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:36 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 41/45] completion: bash: simplify _get_comp_words_by_ref() Date: Fri, 18 Jun 2021 13:25:14 -0500 Message-Id: <20210618182518.697912-42-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 47c96b918e..2c0b869aba 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -408,30 +408,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 3dbb5eb121..8745f6afe9 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -43,23 +43,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 Fri Jun 18 18:25:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CE23C48BE8 for ; Fri, 18 Jun 2021 18:27:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76ED7613E2 for ; Fri, 18 Jun 2021 18:27:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235403AbhFRS3X (ORCPT ); Fri, 18 Jun 2021 14:29:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235096AbhFRS2t (ORCPT ); Fri, 18 Jun 2021 14:28:49 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D163C061574 for ; Fri, 18 Jun 2021 11:26:39 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id v22-20020a0568301416b029044e2d8e855eso1377457otp.8 for ; Fri, 18 Jun 2021 11:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UKz0w+fDZwtHdACEV3EyfOdt/qztcW5K7S4pEcj+Fgg=; b=e4C6NjY7RkuT20IWPlk4X5SRoz2NR2q0V1k8u1iMhxIvakD6ri3AXerOk5cHfO0yA0 /JMbGRPaO0/MWMsIORUnJXPegMrxg7jmuKO3Kl3kI+nm2upgqHqBecUYtDWYjZo+05ic Qq5DoiHZoCZMvohGGhxREtvav5ckWQd6LE0tPLnvcoA3Z/ojfwUiSFSKVqHaIN26cOdF /2R66c/pdBgQcpjjesvQAB+x+lzTPL28Qr7P0SIxYSpCKbpnn3R1rG8vqRAdbaGnIGKC pnQvWnRV0aJKo0zvOFGjiqUnxlPT4ec5f54g47G16pfeqjLvaNTVh0uoWCK93esxxk94 6Rlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UKz0w+fDZwtHdACEV3EyfOdt/qztcW5K7S4pEcj+Fgg=; b=TbSBQ782ZGrqI2N3fRRERrWjBH7EpRdwpix7gH1qN07KhL1AcITtRlf3IpqoqmACaK fvjn5x82EwpdH8b/i/XNdVqTjbG1RdnIMM9MZquxOSLhwLoViyKYkulaqVyj1eCp/q0n 5+kKa42ZfiNrWBOYGoxqNGMC3FcAC7bul2myZ6kVzp3ZlpXr/FjYKsUMd/T3Mc3PhWF5 j1UD5fCSXJwGOLRpzekYHapkgLDDRxfyDOA0xqsUyJKDcUQBqkp61bKhroSOYxISfhtR gWZhgLhSCb7NZNA6G2nvCFmKaR627CVSHuacm/2SlkcDkQJg6C4uPQ0+78SLX645Z3ti dNxg== X-Gm-Message-State: AOAM533uTVCzxfMcmB00XixuV94vbQvT8fT4VLOoSGB8sSwQpMFpEssN kPwxs34y9broi0fgpN5bABk0+fvrls68Mw== X-Google-Smtp-Source: ABdhPJwjO0gAWn7SZET+rL2XucbkApa5XVSPp5ODs4s5nZwkIalP9z0DNyLGfoEELGFejeoWLXx98A== X-Received: by 2002:a9d:554a:: with SMTP id h10mr10886891oti.177.1624040798566; Fri, 18 Jun 2021 11:26:38 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id t15sm1930822oie.14.2021.06.18.11.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:38 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 42/45] completion: bash: refactor _get_comp_words_by_ref() Date: Fri, 18 Jun 2021 13:25:15 -0500 Message-Id: <20210618182518.697912-43-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 2c0b869aba..9976009951 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -334,21 +334,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. # @@ -356,60 +346,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 Fri Jun 18 18:25:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3133DC48BDF for ; Fri, 18 Jun 2021 18:27:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17A74613F0 for ; Fri, 18 Jun 2021 18:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236352AbhFRS3Y (ORCPT ); Fri, 18 Jun 2021 14:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235359AbhFRS2y (ORCPT ); Fri, 18 Jun 2021 14:28:54 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18973C061760 for ; Fri, 18 Jun 2021 11:26:41 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso10530113otl.13 for ; Fri, 18 Jun 2021 11:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4rgajWZl0DFSpJct7I4QXRMbu1+TGuK6SYgJ5hyjBlw=; b=h3t9vixaxsnP+82pGW65Jm4VhSpcUMyQ/1Xx+1VaYlWJPGNARVMBK8SCr2aU2Uqtk4 kPYtjpHzXjlACc6b9rLsfmOcWPpbsJaZlEpeqjR1vTZnym5poLxw81B/dQ+3K14MmrRL nhDsqu2av4wU9bCkDFW1ny3vPolvKf0Z7WIk5A/QRos7/HAgmNu+1ISVhSPDvpjHWZbq J98XGBab0NUu7X5hgBrNkYPEZ8mpTnI62XrUsFcXfsuZam67vHci4lkuO9PoEisuo6f1 7pNeHnnj2LrKaATMKVHlNfgf94OOVq+0YqxVip/2z3KePlF94aEnqACyeLXv8BEXfKYN fUlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4rgajWZl0DFSpJct7I4QXRMbu1+TGuK6SYgJ5hyjBlw=; b=EtjZKgOkoWeidWeyEI1TwFgJHbIq8mRKTEFFbdoCneK8/LvljrbiKmcQ+GWHor1rBS XPakZl2i9zUiCKtc3rkQarU3HnO+ezDJgy8RBxey0T6U0tba/nrTB0rLL7g0f/G4w2Pr TwMX03CDaLI9jyI1ZmM9B1hoTlIn9zHvSYEV/AapSCRMIV45Pe9N9AgVhaWBIu8G7dmJ gqzKUlC2mYq6xhKNm3Z+Vt15vzh/z300IgNnbZM9QQHR/QCReJQzrWwx8gcqlwgHQJLD LS7TrLFeCWjoS0LXbJbUa+QTcauiFAKGVXe03A4lt0g4PMG3zCCh+5lEqt/oFVWcSJnJ j8rA== X-Gm-Message-State: AOAM530/82nrZ+oaeiGbsdR2BLfq+Zb00TANQqfuXBNuOnlmNCn+uYiE UhwnWzkd0xBIhzVO/qFyjx5FYaFi/4tj9A== X-Google-Smtp-Source: ABdhPJxsZH+m8P0Tvp4/tn/SLnxlf3lN+BUlTLN4hTWtUuAzfjRU9z+czsZvm5dSPHpj9Ek0mH3MuA== X-Received: by 2002:a9d:20a2:: with SMTP id x31mr9928330ota.263.1624040800265; Fri, 18 Jun 2021 11:26:40 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id u14sm991304oie.0.2021.06.18.11.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:39 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 43/45] completion: bash: cleanup _get_comp_words_by_ref() Date: Fri, 18 Jun 2021 13:25:16 -0500 Message-Id: <20210618182518.697912-44-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 9976009951..0433713242 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -350,14 +350,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. @@ -377,9 +376,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++)) @@ -388,17 +387,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 Fri Jun 18 18:25:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0FDAC49EA2 for ; Fri, 18 Jun 2021 18:27:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84DB3613ED for ; Fri, 18 Jun 2021 18:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234989AbhFRS3Z (ORCPT ); Fri, 18 Jun 2021 14:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236369AbhFRS26 (ORCPT ); Fri, 18 Jun 2021 14:28:58 -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 B421DC0611DD for ; Fri, 18 Jun 2021 11:26:42 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id q5-20020a9d4b050000b029044ecc922d44so329564otf.7 for ; Fri, 18 Jun 2021 11:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4rI21jrYd8T4dE8uKXchfmq24yIG4nfo4f1kTWqBYGI=; b=mGG4+Bul/rnMTqSC4mwB4V0vhKKqmKA9nCRLw4S6+jvy0ticN+nd5rvVLJ3PaFuHFY qB7MiVDUAreRvEU48W/5YnfTUW/ibZadp1/U+Y0FMJsCUckYv+fCOoHnLQJQt1OeR2AB GUNqRzZItPCIj19qgo1sACM5AQWmY7TvYvmoPQVQeKP8YiVDFYJjDBVJws2HZIVBG6mg Uq3mIPc+IkIBPxKDN3cpfU3JHaYmqq13uIOOYVzFo60VDrAD2NdAWjFu/odaDD0Ijz/O Kc+O9KJdvdnRw8cpMrWaOg/cPss7rtSh7t5SNMpSWsaqeid06tpSjsM72YZcJmFXqkqc tChg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4rI21jrYd8T4dE8uKXchfmq24yIG4nfo4f1kTWqBYGI=; b=HjlJpBkADok31g+CxNk0USslDC6Y/3Q5G/y+ok+94G90cqkaBJEaar3qJGuY2noYDX xjjQidTX0dKD+B20bhOjWSJVtCOSNrqXH/pMMmVu4jhQuredCeRsU7cS7NI1n6cNYYbz aYyxTY7k2IhAW+/foQ1NJ5WjE+mET1QMJ1UUPF+mHWulzG5MhBRqx/TwHbWCyEPFPJgC GbGGuGV5RxGYKLKZ1Nz42PCy5piJVq2FP1Rbx1dgsW9CH4/BhCeWjJ0Jz96fK7DSawJd /I10u/us+BSFXbYaYxRLrE5Fx/Me1BhOOSb9hBmRJtm0fvFjvoMOwVJYODUhyjEL4WIT /jiA== X-Gm-Message-State: AOAM53249gzapgCbZzp10Vn2i7bBDPqG0HfP775fL6lHZhqg1TJSg/C5 WKt55jp8p77Fl20IEZQaipO3M7/x9V/XAw== X-Google-Smtp-Source: ABdhPJw6cTckRoNI3Ccs/yDHqNu5N2MAJH5F2rgTZykmKkB2GlO+wghOFYxtaW2FP0J7JO794HtQfQ== X-Received: by 2002:a9d:7f91:: with SMTP id t17mr6497589otp.22.1624040801943; Fri, 18 Jun 2021 11:26:41 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id a6sm1966473oon.20.2021.06.18.11.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:41 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 44/45] completion: bash: trivial cleanup Date: Fri, 18 Jun 2021 13:25:17 -0500 Message-Id: <20210618182518.697912-45-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 0433713242..cef064795d 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -355,9 +355,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 @@ -392,6 +390,8 @@ _get_comp_words_by_ref () cword=$j fi done + else + words=("${COMP_WORDS[@]}") fi cur=${words[cword]} From patchwork Fri Jun 18 18:25:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12331991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2280DC48BDF for ; Fri, 18 Jun 2021 18:27:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FD0E613E2 for ; Fri, 18 Jun 2021 18:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236369AbhFRS30 (ORCPT ); Fri, 18 Jun 2021 14:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236409AbhFRS27 (ORCPT ); Fri, 18 Jun 2021 14:28:59 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B916C0611F8 for ; Fri, 18 Jun 2021 11:26:44 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id j11-20020a9d738b0000b02903ea3c02ded8so10579873otk.5 for ; Fri, 18 Jun 2021 11:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=czk0sgs9qxDUwTzSjF2lnBq+6oQwn66Jw3awbko+uQw=; b=ZUwCoB2Ftg0k/IMUy2QanW1amEZLSTTUGz210o8PnrIVh1J8603sqMOTAJ9RVSzgme 4eVkTKcn6nRWM4I332zLW+3OjslRRTq3uuhQ4bzVR1WxUvRH66GHqb49v7t+oSvcIP3s 8cF8Dx8bgsWxQkKqLlHeT7iyZAFuK68KopK0GHH6RsWBjzD8/NSRB+YgN8O6mRwcLTXt loNl0tHpTJHeghr73ADZEWvWlFmBpfXc4rsoY7N/EomrIRY5/qqfaOySAzSHXzIWFdt2 I0xModf32YrNtMNMEIsfjcK0xbR4mJ6bufk3LpiVy8PGVmawAFA55+FfJLEIOfiWLuTD S2nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=czk0sgs9qxDUwTzSjF2lnBq+6oQwn66Jw3awbko+uQw=; b=kQjU9StODJbQFf73X0JsOlm7Z8sjlDim+Lxv0umZPm/hynP5Fw9EulaDvBWwTO4jB7 o7gmzroI4f9AvAHfKTNnEgjo/fhJCX2y+E0wJwnFpe8xLlb2N7Zk50XmXJirswbCzv3X qovgf0eFNZGK7Xyiy5RA9kguBrYFIcs4f8ExQqsRzIJnuTJMzFprHF7bIP1A5o+qqz49 EQBQdQ4jiIECb/dqcVfHmtWh4sRsr+agy/nwHfboPnvgtYljZiNM1LvftXHv+/20TIwt spemDHHFZYuxwKgLnwQXJ+9nRE/L59lorBXVsRYo+EbBWOU17tTpBMvBHXg7poTXxyD5 u1BQ== X-Gm-Message-State: AOAM530XtiKDOIhoz0dTOv2MXE/VImILpCOWEWxGepbOXhmdzG0inxQY ahDAJNLSQJDnQRerBtLz3j+KETu6T2bJgg== X-Google-Smtp-Source: ABdhPJwgsZQ+6CdDWNpULeRiNn9MgIEi9jO7U9JEGODi6lFXffJyKCufUooCsQzMSqYpS2VftXY8dQ== X-Received: by 2002:a9d:6219:: with SMTP id g25mr10338277otj.262.1624040803549; Fri, 18 Jun 2021 11:26:43 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id o20sm2111247otl.2.2021.06.18.11.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:26:43 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v2 45/45] completion: bash: rename _get_comp_words_by_ref() Date: Fri, 18 Jun 2021 13:25:18 -0500 Message-Id: <20210618182518.697912-46-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618182518.697912-1-felipe.contreras@gmail.com> References: <20210618182518.697912-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 | 184 ++++++++++++------------- t/t9902-completion.sh | 2 +- 2 files changed, 92 insertions(+), 94 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index cef064795d..aaff13dbb1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -307,98 +307,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 @@ -3443,10 +3351,100 @@ 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. + +__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]} +} + __git_func_wrap () { local cur words cword prev __git_cmd_idx=1 - _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 8745f6afe9..90f1236a00 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -41,7 +41,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]}