From patchwork Mon Apr 26 16:14: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: 12224483 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 3E653C433B4 for ; Mon, 26 Apr 2021 16:15:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F373B61158 for ; Mon, 26 Apr 2021 16:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234219AbhDZQPw (ORCPT ); Mon, 26 Apr 2021 12:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233736AbhDZQPv (ORCPT ); Mon, 26 Apr 2021 12:15:51 -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 A1B75C061574 for ; Mon, 26 Apr 2021 09:15:08 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id x54-20020a05683040b6b02902a527443e2fso1504416ott.1 for ; Mon, 26 Apr 2021 09:15: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=gB7XKDX+4BdwbEDALUu1tA4TooNcKHP+uZUeZ6j7NK0=; b=VKjpcuehEuANsehdriwdndRB9T/Y4gAqbyO4YOIv+Pi3aEvBK6CJJ7puugK9UKweZ0 yO771rR8V4ekJ27ILU4PS9OPYqx4eBOyVPzr7mCA3CukTRtM97RJ/wBZyo9XJ6/qXt5y /CrqCAA55A6+OlY8muZyGplGPAxmCW/6uanoVikD61nCHTSt9V48Wqnugmp/ArRezdp+ XF2lYGZB6vr+EUeP6yVVIBNyEHv2hCm+r18glZ78u1EqQ5VkhepwphMTEY6UjwI3H6oa CygykXJZZREZds1uycJ+DGMc74A0mYVaejPuOwDZPKYizxXChI6VvDp1ZPIiRGbfW91h TVZA== 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=gB7XKDX+4BdwbEDALUu1tA4TooNcKHP+uZUeZ6j7NK0=; b=J/Oo/Mz6oV+FHqEZQg9kuv6gN1jbdHfURroPd+PqUDErGrnn3ywTB2qC8oP/l26V2S GJ0X7AfCJBicfYARZS1L2v5mIHPkCssF8xEEa/K06wJQq0VSTWEv3aY74zNF59HE3c7p v225nzeTeA8g1kmgt7l+DgEgz3P+zzcPZzHRom6tl+efk3WrWt8H2EOg/iLY9HHlKqoX eGgNs35so+TsyaIdGFcBWK0oxwVvj/wHdQCt0ftfncpmZ3KdVT5kFLWuE4IRIyCA0sV4 iafaQyTikwPzIvvAf/nKEm5FubrLPmCsUKuAbZMRco1UfMVRWzNlWq3yHym5JyEGYUcL zjGQ== X-Gm-Message-State: AOAM530xN+i7fh2deVssdFTqc1iFLU2jyoFNy5Y34EGoeE3fP1H4B0/i L6YoTlt1caXbTbQK8VvsAWH7J4PJcfEBYA== X-Google-Smtp-Source: ABdhPJwjwkSvzKZ4k/WuUf6NP3cEiHiOAhLPXLyYi9bcIbH2mH1wUfY5whgZiqZcVKv+nJH8c3EsiQ== X-Received: by 2002:a05:6830:16c8:: with SMTP id l8mr15358976otr.56.1619453707906; Mon, 26 Apr 2021 09:15:07 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id q189sm3061648oih.25.2021.04.26.09.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:07 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 01/43] completion: bash: fix prefix detection in branch.* Date: Mon, 26 Apr 2021 11:14:16 -0500 Message-Id: <20210426161458.49860-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 7dc6cd8eb8..3323b770e1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2644,8 +2644,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 Mon Apr 26 16:14: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: 12224485 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 EBC3CC433ED for ; Mon, 26 Apr 2021 16:15:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4D7061159 for ; Mon, 26 Apr 2021 16:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234225AbhDZQP6 (ORCPT ); Mon, 26 Apr 2021 12:15:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234221AbhDZQP4 (ORCPT ); Mon, 26 Apr 2021 12:15:56 -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 703A3C061574 for ; Mon, 26 Apr 2021 09:15:14 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id i16-20020a9d68d00000b0290286edfdfe9eso41974328oto.3 for ; Mon, 26 Apr 2021 09:15: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=XdpVZbBb51lRACz6fnNhegxLQsigIZLmLPFefdHcqBc=; b=DXa/Gdjhs7WurM1CevMQJ3kcKjCvDQudfZfnqfC/vEkQd3QbXC7HstQDTX/CmpPeGY BqaRpmZKE16cWXFgCrbt517R5TnrJWMiu5AIVBczZlfzhnZmQ1SlStIrtM2XO6XbS3eY Snc46uiRz4XqXSEQO1j16NV5HD/LQALdKKV87YG3h5GsgZwMlI7Bjf5J0tNBDWAzv+jV rTVPSZva/M/PFzx7LU/jCC8AA0K8U7+vyNpBP9eBKOm6alxrmbN3oFAyZT7+z/OBttIz eCt9rpsvGk8P+YkJPrNBSSq2L7wnp11u2oy1XcibESU4RVlbkdow3d4RAX58H7avxsXy dQwg== 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=XdpVZbBb51lRACz6fnNhegxLQsigIZLmLPFefdHcqBc=; b=pUw5YQyCVstgG6xvalTb9pSh6uZIM+Q91axMYmItrauHGaNpRj7xwRoYsdjW4RAleJ 2jGI435L/BfGlGU672mU45JnJqCLmUNTKMnp7H4XAsn5MCGBAARNrKUkrs4SD3e7L60o iYlBKg33fazjhomV78fBX+evBm8sIQBV+9RjqX9FUl9xQP/w6bHB3NSptGLOtvPJEfw1 AqigRBOBFms+ZNYHbvd8sKhJQDSusSuzEcVWaAzu0SUB9bF/y7LZosiIaUbrocXGBxbO lbFIXVIHqQ/X6G+fp6ZKzxxFTH2/IheJrnWpYxZzdR0Fo4PMeN+McPdrZpva24r8LP2S lX2w== X-Gm-Message-State: AOAM530eozA5GOq4rDbAsLQ5UjNin9WY0fJJsYgRL90R3mnY1VMwfpOH VAZcu3oydC79aWp0q/AHOn4nLXyM4+ar2g== X-Google-Smtp-Source: ABdhPJwSWtpo+IMW9NWe3x4pQn6ICCyost350EUtmnEvkzdyAK3Dg+HiN4BnVqdYL+4uST3Brwx1gQ== X-Received: by 2002:a9d:449:: with SMTP id 67mr15017534otc.333.1619453712780; Mon, 26 Apr 2021 09:15:12 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id f9sm62530oou.48.2021.04.26.09.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:12 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 02/43] completion: fix for suboptions with value Date: Mon, 26 Apr 2021 11:14:17 -0500 Message-Id: <20210426161458.49860-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 3323b770e1..e7173cfcdc 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 6c56296997..69f90913db 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 04ce884ef5..7fc8eed375 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" ' @@ -2358,6 +2367,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 Mon Apr 26 16:14:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224487 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 8E2E0C43460 for ; Mon, 26 Apr 2021 16:15:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 682FC61158 for ; Mon, 26 Apr 2021 16:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234282AbhDZQQB (ORCPT ); Mon, 26 Apr 2021 12:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234231AbhDZQQA (ORCPT ); Mon, 26 Apr 2021 12:16:00 -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 55641C061574 for ; Mon, 26 Apr 2021 09:15:18 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id c8-20020a9d78480000b0290289e9d1b7bcso38527174otm.4 for ; Mon, 26 Apr 2021 09:15: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=EXhQVrixx2+pq4Ekm+UdPUFL4GkJdNABGJxxo6XQMbQ=; b=U6RhpmaDmbcnN409DWcjMsvNkJpy7t68nzQkhbMmC+slWaR2sI1r1WvwsJVoopT2O4 t+XpV63oYTCQuqWrThBXcqELu1h14PTo5iJ69uWnaKaTzyjlwMV1sS8UiaY8F4r8z3QG 3a9WQESjEh7GfmWlJ7DV/16jrvKj898ryQPIglPDKDH3j0TEQzOeUUJGmzliHDg2pE4o QYuxHGQhRGo0pEFfa3YW9irzuokhmFW5NPFYMF/87HADEENJS0BkjyJ9QKtfQuBP/lWx 9pandYpEoX6JmnFhp3SIzDz1NyoDNLo1OODWu8Wv9PsRJmcMGR4eLYx07H3vjD8Hto4d Nruw== 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=EXhQVrixx2+pq4Ekm+UdPUFL4GkJdNABGJxxo6XQMbQ=; b=i0kJ7MG/XLG11cXR0v6w/5K6kf+k2Ip/FbHcQ5XdrVtdf4pctCnOVzERKCbWsZ5ThV c2ag3gumrJtXe6it2XpAEOHt3PjHs9fCoNfga3emd2CIn9jw4YbSLaYwpiJD+H4FzaHL Ytw1KB/j+pR0xLMtTUTTUJ/Tu3KQ7PGlQ63XQsA8O/y6+qV7UpNvgtUOHqOLeZfYs6Cm kr4/nJQffAKo4AsTzuwxoQ+BaNLuAmPee0qZgjJYHwxYxlDcXF2NIRjtAngLc8wu9EWg lGnxjKNzJ4lml2YKt4nWqW/LAN6+bgG3/dq4nibWQY3FEbX7al2o4d4J4ahCWuYQvYaK vMOw== X-Gm-Message-State: AOAM532WFlx4SyYaVHR+Y4N4GTr7RXcm77VRhe8mbHy4mHxxT/0DS0gM VquijOgi4/xbIA+roILXW391ZrHF8ayYpg== X-Google-Smtp-Source: ABdhPJzcKPOFL4OeKTWX9FN6sv6XCUyQcMp3S14yMVbqUet9yFL61E1eQ2915XBHzTYn9yeCLaJgXQ== X-Received: by 2002:a9d:5c87:: with SMTP id a7mr15595876oti.292.1619453717519; Mon, 26 Apr 2021 09:15:17 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id j125sm3115328oih.10.2021.04.26.09.15.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:17 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 03/43] completion: bash: fix for multiple dash commands Date: Mon, 26 Apr 2021 11:14:18 -0500 Message-Id: <20210426161458.49860-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 e7173cfcdc..bc19792a51 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 Mon Apr 26 16:14:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224489 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 A7A4AC433B4 for ; Mon, 26 Apr 2021 16:15:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B8F361164 for ; Mon, 26 Apr 2021 16:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234298AbhDZQQF (ORCPT ); Mon, 26 Apr 2021 12:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233934AbhDZQQE (ORCPT ); Mon, 26 Apr 2021 12:16:04 -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 CE8A4C061756 for ; Mon, 26 Apr 2021 09:15:22 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id u21-20020a0568301195b02902a2119f7613so5690212otq.10 for ; Mon, 26 Apr 2021 09:15: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=JAVw9eVU+ydJZBoZop+F0mxI4d9bqq+1T45uqXAJK+Y=; b=CdTM/9/iBDwwFbLIZfQKT3EvInRCsGB8g1/DMuCSPdmxy7nGxbq3lsQWP7e9bObRJy AJ+oudrsRqYkPhqolxUOpum4DEA1IvFRiNcHxE8wal/aKalumDxs7L1W4BYMIGb7W+CO B/qYTzOtnlqd+EprT8NYXkKUQFk6QFP3NdNI9S7z5ykZiaLOzXZXdJ9TeByXq40upEEd LWGwRbnO8dHOenXKGCn7cUw3wd7+r3JjnzvRb2MFRexLdRpa20PP6U+8kBQsSZkELBgX 5Vjk2KNfwyW6/Xu5fCfh8ofeeZKPOt9YrcAc4q7Uz26p8iTOwEEoXT9oxugzBzfst96f Ysrg== 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=JAVw9eVU+ydJZBoZop+F0mxI4d9bqq+1T45uqXAJK+Y=; b=DDwFkAZepN5BXce5DaEFBctOgmf/ITbowUT4sK3n3D1yleOUX7JK8gfGefQqHuISBp of1D0VPM2Ls9BqkYKFV9oqrhUL19PQ7YF8CG+qgqjHj9Y3XEqWlPzHtdC6PGN+4oOLkT kc+nY8TPbuq29t5CVMa9Si8YR0KiIaayMmU/Mr1+4OrDSlzh24WQ34OAsELjKYkBBYhx U2gVID0UlFKQmUTP8nEXCxaKXA4n9xCqOuvvjtZ38w+JxiFFspVSUSV35GZcjotJUxbF mFodVQLNzfprFIbESzZ6iuesY9vlHFAOozfz/DEyBbnaZx8Gof+38ixy/TXfjjy5jGa/ iTUQ== X-Gm-Message-State: AOAM531Pk9gUV6ZEz/9A2fpV2r+jQvikDqSNYS9dgPXi0TgJU+FZNlaJ BR7583mLiSN7wxmK/ihqqTks/zc2AzrDOg== X-Google-Smtp-Source: ABdhPJzYoFFKGoyuV0+VQLnOY/Ie8zUr1jjuHurVb7p4uFFV0rYDP5Gh2R1sUAqvIq3ayDIMNiMDbw== X-Received: by 2002:a9d:5c87:: with SMTP id a7mr15596151oti.292.1619453722055; Mon, 26 Apr 2021 09:15:22 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id v128sm222236oia.44.2021.04.26.09.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:21 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 04/43] completion: bash: add correct suffix in variables Date: Mon, 26 Apr 2021 11:14:19 -0500 Message-Id: <20210426161458.49860-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 bc19792a51..0706f1e304 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2647,7 +2647,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.*.*) @@ -2681,7 +2681,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.*.*) @@ -2697,7 +2697,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 Mon Apr 26 16:14:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224491 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 1C69BC433B4 for ; Mon, 26 Apr 2021 16:15:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E002661158 for ; Mon, 26 Apr 2021 16:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234302AbhDZQQJ (ORCPT ); Mon, 26 Apr 2021 12:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234299AbhDZQQJ (ORCPT ); Mon, 26 Apr 2021 12:16:09 -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 78C5BC061574 for ; Mon, 26 Apr 2021 09:15:27 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id s1-20020a4ac1010000b02901cfd9170ce2so12396546oop.12 for ; Mon, 26 Apr 2021 09:15: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=MMfOt+yTya2AASklWFX88cYlPjvsn+c/5pVwz4tdjDU=; b=hh9t6ZS1ZuZU1Th0cxpZHXDcl3l3nCf9kvMoK7t+U95gAjjVB87GjfD5GdXZ55HkXf +bCQwedP5GRDyaFc2wkJbVefLWeUlwv6LXcKQx8zD8nvgnNzbMsZI9Hv110JjFEeIorn KDLXOP+k6+cHdnrbUshmQaPuolvEeMWSvYObL7MYdPsn/Ze1uLFMB5jBUckghWAeGvqo tsH246I0BXaUgBXo32P/GY7ksy0RZ+4M7UyVgfK0JTyeMlZA8vighOs2qTwN1Bfx+1b+ NaDaDtF+n4iV75Yx5nkqV93IibofNeeMJBXd7FYgG/AXbYJ+Lv/JVMpZZ6/xvCJbtuQ5 HS5g== 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=MMfOt+yTya2AASklWFX88cYlPjvsn+c/5pVwz4tdjDU=; b=JRi0FgapKnaSoWy8hV0/QTzoe6o9QZYFRW7zFA+Np/+DVlqBRV1picNe14myw0mhF0 AsHNidkF/T+2WE4hIlmkVe3sZRnt5BEO+5D7f3PvO3eJc9v3sC3yamp+frBO/MDaMYid 3aZmdvIhIndxWzhUqIiyKAljZglCY6ILqMT0Ib+jrFrE/n3PiW0xv1rnt0Jd6DCz3QlH 9Nim5xC1iR4AHYCFKLM3nQRTv1U8h4Hfj1WfyuiwLgO8EYLB8y7tzLIZtkyfbrsYIUmk uaueS5Pi2657FuR4RfCZ9KhDUK7PNVTNRZ55UUO8g1NC4dWofIb49SiR8Iyw5adcZ5qr 4qug== X-Gm-Message-State: AOAM530BvCoshWXnF2plgr1zqzzqo8IbxuupdI5M2MYoQqibkKxD3PmY NW3+FR8nVX/1N7Ft7bRmddZqZiaPrSmePw== X-Google-Smtp-Source: ABdhPJzb4a60Jbr6+ai+qDVeYqX87g8cwLEfI585p9kWFHhPiZ7pkHLRVJSFM62cLRpDTy8A1UDf5A== X-Received: by 2002:a4a:e873:: with SMTP id m19mr14192224oom.85.1619453726656; Mon, 26 Apr 2021 09:15:26 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id u4sm65868ool.25.2021.04.26.09.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:26 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 05/43] completion: bash: do not modify COMP_WORDBREAKS Date: Mon, 26 Apr 2021 11:14:20 -0500 Message-Id: <20210426161458.49860-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 0706f1e304..cbb2730bf9 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 69f90913db..e2ea14fb33 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -45,6 +45,7 @@ fi local old_complete="$functions[complete]" functions[complete]=: +COMP_WORDBREAKS=':' GIT_SOURCING_ZSH_COMPLETION=y . "$script" functions[complete]="$old_complete" From patchwork Mon Apr 26 16:14:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224493 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 92AE5C433ED for ; Mon, 26 Apr 2021 16:15:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AD3461164 for ; Mon, 26 Apr 2021 16:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234243AbhDZQQP (ORCPT ); Mon, 26 Apr 2021 12:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234299AbhDZQQN (ORCPT ); Mon, 26 Apr 2021 12:16:13 -0400 Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED21AC061574 for ; Mon, 26 Apr 2021 09:15:31 -0700 (PDT) Received: by mail-oo1-xc2b.google.com with SMTP id c12-20020a4ae24c0000b02901bad05f40e4so12398908oot.4 for ; Mon, 26 Apr 2021 09:15:31 -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=8q/9izTH3+b5FZjKSC9PHnw70ZDe7b7IJKIurTswaLU=; b=FAyJoDA91/xPH9dFj9TWfIfl1tUqlzbYVin6+yV9n29LZCSVxPK0AIev5f9U0TfTIE Doon/PVj6ZNarIxIqklSLBAyeSEiRpOKFDJ4jg3SmP7t5SwRXPWp2iHLXkBJFOkSZt8i +jzaqV6LdyTOT/5VjQxNhr/QteZ1+jXN8QCfL6G+YyVSkbOoYcbftc528ySeBg5j3gRS YrTCTZ9kzTZc3cXbGaSPF/7Ctk60K2fe8lX/tEzS3g7ri2I+KLHvWNU0iDCBjznA4wXV 9fXf0Mopm7Y1VMeETkxqzHZmmfJC1EVuBJCHtGyeZHm9zHrscEFRrZ8xfOJALSWDRuvo eHEw== 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=8q/9izTH3+b5FZjKSC9PHnw70ZDe7b7IJKIurTswaLU=; b=DiUyTf4mcRX++jXKYFKfNcr5GQclQizbLbpWuE8RjYV2gjdogjV0c+rVNS8lnxwfOg iWVLQdePSBmHqlp35wM8bK8bmawrvN3DecEybSzD+92k8Nap7YI06c7QkDW4QmyEd8qc CmtZTsIgvnh/XrAhkGa48964ZtrnDTSusnWknd2Qol5DwtbvIRXPEbVwhjkKvdU5emyd kEK6fNcDtbbV3F2b4YQuNJdiaorOZjWwuN3J4IAxkf8Ja6BhuASbWSfGMH1KQBkA4FaX Y62L1HrOFmz4ND0HVBqzAx4vsdS9euXuY/8Wa7fIYZr6/YdDDteGWq2uAoznY0L5Szer FkIw== X-Gm-Message-State: AOAM532sm56iIGZdHIWZS/j86r80I+ojk10WapNcSSIrBfmgU6uu/Qy/ zBamsP7hmWRS7lamd7aq2RxIkofF8qzPgA== X-Google-Smtp-Source: ABdhPJwNbzY2lCPJ/3uBvOUihRnDtfgD3g3xrW+nfmkCi2aTBzG3XAS3dl6xAA/dJWWzRPA23nE6JA== X-Received: by 2002:a4a:3142:: with SMTP id v2mr13950400oog.9.1619453731142; Mon, 26 Apr 2021 09:15:31 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id j11sm63525ooo.45.2021.04.26.09.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:30 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 06/43] test: completion: fix currently typed words Date: Mon, 26 Apr 2021 11:14:21 -0500 Message-Id: <20210426161458.49860-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 7fc8eed375..4d4bee20b4 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 Mon Apr 26 16:14:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224495 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 5AB18C43460 for ; Mon, 26 Apr 2021 16:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39E996105A for ; Mon, 26 Apr 2021 16:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234326AbhDZQQW (ORCPT ); Mon, 26 Apr 2021 12:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234316AbhDZQQV (ORCPT ); Mon, 26 Apr 2021 12:16:21 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6281C061756 for ; Mon, 26 Apr 2021 09:15:36 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id z20-20020a0568301294b02902a52ecbaf18so239248otp.8 for ; Mon, 26 Apr 2021 09:15: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=Gjc2iTirAk06PW4Equ5G1GqwAUmddUKPB7Ru4CksQQg=; b=vYuWBQRO1bBvq1F+YRPrCf4X/chMAeqOjuN08RXWWzdJtUfFta+N//9kqWCf55ZTB/ n8vfxbbwzHlg58CLFkzq2547FY0rar8MxiirjcuYAbkMdyEzS7yByQIUdfvUGvLSmEte Ljg40t8fXV77V/W3MYkpPxQ01mSHV7gUk6JhHVZTUX5uO/44xmQnHUOtUTULywLxxcDg +wyQelOfl64Y/F1SuLdX96DakIjp6onlXGd8ow6XZNBny8PmIIyk+F+Xcx0rvpIPLg4m hSseQgCaniVI6IgX6GIea44Rsm/lVr0DoIhp5ozhoY+R3NRDtehNHAamHDz8dPOZZusd NlWw== 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=Gjc2iTirAk06PW4Equ5G1GqwAUmddUKPB7Ru4CksQQg=; b=RARrWEY9CHUvT6TLwVNqF3PJqmcGIavPNv7WCYcntby/1iA66xTp2hf6ufv3V1QfdO jgYv8Vzl5z5znfXt6nbB1XSvK1cMisTWKbftuJktyydvdh4z1xAsobzoBRkTmF5s8EEZ KGDJ67vRR0CGUX0NJu0jxzBb/1GsLnwnfrVPKERGTvL16Ytpiq7QysT3uVK2p1kaDMLD /to1EaeoFsPxqVb8AE4QM2wwpjP4t5iml9pqhr2Y/6IucVKxntkz/jSjR6c3mEUaPFSR hlIVeKBvwzBoBWz1mk06ZKu7sWFWq4v/gd3kATVo+nP+JRzkeDeicSe/3CMGe+gQlh3A iLfw== X-Gm-Message-State: AOAM530tf7Du12rzTP+ljBKqQZWZjrHdPIopFfgsT/Bg1XdI0EJuNyMq 8thIY66EuwF5O9hVkJ5/7yZWNtYmgt3OLw== X-Google-Smtp-Source: ABdhPJzrWn4zufsyiwETuT2l9G+rVQX59bUJJwgtbTBp1aBSu1nRILNK1PhWbSyQuhf68ctcG+3rUA== X-Received: by 2002:a9d:7453:: with SMTP id p19mr15200228otk.271.1619453735914; Mon, 26 Apr 2021 09:15:35 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id r19sm3097968oie.58.2021.04.26.09.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:35 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 07/43] test: completion: switch __gitcomp_nl prefix test Date: Mon, 26 Apr 2021 11:14:22 -0500 Message-Id: <20210426161458.49860-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 4d4bee20b4..13bdf634a6 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 Mon Apr 26 16:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224497 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 4FBF6C433ED for ; Mon, 26 Apr 2021 16:15:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A6E96115C for ; Mon, 26 Apr 2021 16:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234338AbhDZQQY (ORCPT ); Mon, 26 Apr 2021 12:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234328AbhDZQQX (ORCPT ); Mon, 26 Apr 2021 12:16:23 -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 495E8C061574 for ; Mon, 26 Apr 2021 09:15:41 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 65-20020a9d03470000b02902808b4aec6dso47826299otv.6 for ; Mon, 26 Apr 2021 09:15: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=uE+ln/DWyAKHmlptpr6V9OW1SY6SWtAUNqAMRFnMuDY=; b=GXCcaKPDuvTlORWA5fCUTDtwqF/lrpD1E5Bpxj0ieM5qjM1lDJnwkRmx1WA3VsbNXR pTbSWKeQNhEMs9j6bK7BTFJe4emRGPxN3l1oaorz997nzAk7PweeSvjor6jqrQFIYbOP pOChlv4A2tfRnzcFHtEGk3HHq4toD1+5kLJUG/AqDvjHYrZp1MVHGKGf0HQP+nsxxI8v i/IKq9jv5CD6H0J3xtXwi92bpASqtmT38YIERTxDAFL1KbjXDI7rzFWBqnbqb9fx632N MXPfG7/hJ/G4r28AtxG7uSgS/n9Apst0r2RZ1YUNfFsBOwUmFlDoXCqhTwMxT1WBttQa zbcg== 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=uE+ln/DWyAKHmlptpr6V9OW1SY6SWtAUNqAMRFnMuDY=; b=Prjb/VH+sNKP8prbtSHErl0zOK3VYq456hin7A/TMVE15rtv2ed0hSqAYgeiPTLOrj fLqu0EYShCEOXcsgJfELqenwGXgr/rWFFkD9/Nfn1YBup5Tk8uSxZlIotqDy0nKdDgio VSf4Zd2TQhRcGLIzrih5/igXoi93zKh/XMlAbPsNmSB+Cq1bRahj2+ivPXQZDCPzbi83 tEG86p0AqxyRtrbQYa8AA3ITrkWCWdJMKZEeEcxFeZwMHXmab/2pJAxptQZ/bUnn0m4b q5UQpuwthGCueHpK35Uk1SYozI7WcL1hBQK/KxZ5Oenl3AmSPttDp57gAv3N/+ZkgGV7 mAKA== X-Gm-Message-State: AOAM532u9whXlslMTYJ0vaduNaZoxySkdhVfooDMFqXnkX897oNwg+qQ pEZD5JouYVIO5RyLBx2K28TbZ1gV4u6L6w== X-Google-Smtp-Source: ABdhPJxGnHe4lJhc/ilxBHbWXSIZSpzjAgQGtsA5J/Y5Q8Ttr3p9wHoFRIuIuJeAvOXEp7293fabNg== X-Received: by 2002:a9d:6b0e:: with SMTP id g14mr15273404otp.214.1619453740478; Mon, 26 Apr 2021 09:15:40 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id b22sm3603330ots.59.2021.04.26.09.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:40 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 08/43] test: completion: add run_func() helper Date: Mon, 26 Apr 2021 11:14:23 -0500 Message-Id: <20210426161458.49860-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 13bdf634a6..3528463047 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 } @@ -2284,8 +2276,7 @@ do ( words=(git push '$flag' other ma) && cword=${#words[@]} cur=${words[cword-1]} && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' @@ -2297,8 +2288,7 @@ do ( words=(git push other '$flag' ma) && cword=${#words[@]} cur=${words[cword-1]} && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' From patchwork Mon Apr 26 16:14:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224499 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 1ACF8C433ED for ; Mon, 26 Apr 2021 16:15:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D614361159 for ; Mon, 26 Apr 2021 16:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234344AbhDZQQb (ORCPT ); Mon, 26 Apr 2021 12:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234346AbhDZQQ1 (ORCPT ); Mon, 26 Apr 2021 12:16:27 -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 B2150C061574 for ; Mon, 26 Apr 2021 09:15:45 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id e89-20020a9d01e20000b0290294134181aeso26800766ote.5 for ; Mon, 26 Apr 2021 09:15: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=TN5fyIbQXpcWr6TA0JuNUKoUtDPdeg1HgvROSqtCZbk=; b=Y5hg19Y2y4MgC+HNeoprWjGz96y3PDSpBoED0frEZxML5pBojJPI+5BiLVbTqTyXJ7 1mo+wqUOYY4t4p36TIhjjkoXZxnN0TNxukyEIRfZWwt8wOyc1N3kWnh5lteq8B56PasI kexGmkNUAuUTwJe7xm7xzrjWfpABS+Fu3j9O3bBQTv/cZMZdR9VA+l/6OP5rKshnw0re 7fkj3Zw2EtmmDjjZwlLumZfIOcb/8TpXyeUAYowz6rzo1l2susRgXRgyZFFbR8mCqSFE LpF3bZuttN58IoiNvFyn2gILkiGV+VH2XM85cH9zBv/j6d4gknFJnAyT1n5AkrbDAH+m NenQ== 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=TN5fyIbQXpcWr6TA0JuNUKoUtDPdeg1HgvROSqtCZbk=; b=Bnv9kxCjv4eouiS4vjlg2mSvGO6z/SDoNtU10sg6x8UyRnu5fKMsdSZ9W+lWJXBA/p yi/DwX+whoNOa6sCCeLWcGH1+9bOe7LnW+9VQfEOPAOykrhfeostWfCptk0BJOXH70j5 VALXuYILlQ+i7FQovxCfEwLZrM8pBzPEQG5zU/VOpsf58mK7nTWMfCivi39jEQBi/32u 0jqmReyB9InsOrZQxeC76Kkwtp+CoQ2IG/wuKvwbqjgTp93fqFpiFVZlF4+J2dAz7IAL yz8YleDCGti4jpFV0JK0G5saM3ZbP06aQmKds+Tf2YrgEssYk/HEZ08fkwsEGVQyObUv juZQ== X-Gm-Message-State: AOAM533cghCehnxiZAAoflCI4X3I1ZeVxTcPci+4SmS/fUtUoVFvUMrn v3YZ+heR9kp2oSVFgREcOlGd3U/gTqjt4Q== X-Google-Smtp-Source: ABdhPJxlObGINHE/f+qiyH1IvJ8kYrj91rXIjuLjbKnthRjv6gca+QsTcINbxrvpq2A+Cy4cah8lyQ== X-Received: by 2002:a05:6830:1386:: with SMTP id d6mr15445729otq.150.1619453744945; Mon, 26 Apr 2021 09:15:44 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id f20sm73019oov.21.2021.04.26.09.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:44 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 09/43] completion: bash: remove non-append functionality Date: Mon, 26 Apr 2021 11:14:24 -0500 Message-Id: <20210426161458.49860-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 cbb2730bf9..162c8a89a2 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 Mon Apr 26 16:14:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224501 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 CC843C433B4 for ; Mon, 26 Apr 2021 16:15:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A356F6115C for ; Mon, 26 Apr 2021 16:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234347AbhDZQQd (ORCPT ); Mon, 26 Apr 2021 12:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234310AbhDZQQd (ORCPT ); Mon, 26 Apr 2021 12:16:33 -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 4E0B1C061756 for ; Mon, 26 Apr 2021 09:15:50 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id x20so23196875oix.10 for ; Mon, 26 Apr 2021 09:15:50 -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=kEtt5x6Ev7zM72wyLZFvyyz7aXR6Q8l3yiChgxYkvTM=; b=BSxZuNGajIH2Zj8LcMMz4GDbqbDtjjCSueDjF1JrhUdV1dhcKp5MHnRoBTLgQ0861M gNEU55cOqJOOzT5Ibr8wbyqitEzgiUa7DXOzsPdTEh6i4RG85nG7jp4l31ZYcqqUd8Ob Cp7FQA5kmjXtpm51xkghWon1bkXCumxCGiKhok1+/NG3M5YhbWl9EwoMZHg+W5fdA5y7 XJpGJUb6jjyd1xg2H3DvVifwIfnI/tPnOVjq3Pw7Dbn25dMW8Dc2iAjcr4K7heF2ij5m Tmh83o20P02s8JPTlButuw4iNy+SKL0RekKDI2dJauh7t4gLvxgc1HTqkkW76CKHhbYD bolQ== 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=kEtt5x6Ev7zM72wyLZFvyyz7aXR6Q8l3yiChgxYkvTM=; b=sKV1LaoC/F8DuYlnsJPCqnsA10Uj+NEb/n7fsGuyAGCEBmsTgdimMgtvCAcOdXK4VJ i/wqudGCFRlqUp9CaX9op2MSEFWwvQROJDN9viA31jhqvbPLuZMYuc5C8pg8kAb0Wivr YqGhHJN/VuezSVcpupssu7fkvYWUP66aQVR2lsF32KrAGdfOfG81+nq98/5P9rIhaf1K BIFuUy2JXYG44282HW9gAbgtiF4V0Psz9qV4mQYG6NQDaN000t1U96brhmutLBuopRnp y3YKaHDA762ndZ2V2DSeLWbicY7W3WSMvxW09pNDsPQPYOlB+qqqc/ONFO4my3X+pOoY f0gw== X-Gm-Message-State: AOAM531aCbCJbl9l++f0YFsAlZII7YLIVaX9ohfnkilRPTgnl+sF2vXQ kHB9ovE3Xn+binboge6mumr0C3vq3ldhVg== X-Google-Smtp-Source: ABdhPJylx5h46uJstRZnrldeXe4rVu5mS+7Xe71ACYMRYUBETHAcfwUr59rck6uObCU+Lh2/50t0Uw== X-Received: by 2002:a05:6808:b10:: with SMTP id s16mr12916920oij.4.1619453749487; Mon, 26 Apr 2021 09:15:49 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id l17sm595391oig.20.2021.04.26.09.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:49 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 10/43] completion: bash: get rid of _append() functions Date: Mon, 26 Apr 2021 11:14:25 -0500 Message-Id: <20210426161458.49860-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 162c8a89a2..d87d1ad12a 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 } @@ -2641,7 +2620,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.*.*) @@ -2691,7 +2670,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 e2ea14fb33..97d2bcadd6 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -121,16 +121,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 Mon Apr 26 16:14:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224503 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 DF8DEC433ED for ; Mon, 26 Apr 2021 16:15:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8E3461139 for ; Mon, 26 Apr 2021 16:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234349AbhDZQQi (ORCPT ); Mon, 26 Apr 2021 12:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234257AbhDZQQh (ORCPT ); Mon, 26 Apr 2021 12:16:37 -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 BAACBC061756 for ; Mon, 26 Apr 2021 09:15:54 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id d3-20020a9d29030000b029027e8019067fso50706281otb.13 for ; Mon, 26 Apr 2021 09:15:54 -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=d3ll2VtSLN3A8nhX9iE55BTSNDeOOmX0g404u4X3k4E=; b=Q2UT81bBiixWBpGjP8qKTMyQMLeTP8SUP9afhyn5wm479Qy7W6RJldn7t0Ot//VFh6 8C/iIGuqQ4LsucQYbje4kCjMPvuGWYD+wlT21SBSihogDdXqwcG31TPCVNmX9a6HwfXE NNac+lBmwXgF0SpLtNHgIorUErrXee2faH6X8PubP4RYfwf3GdacoINTR5zOzP7kwGhj NC0A7HQXaBK5hNhgaJU0CuFkWxXop818hNgadd+npZS+Z566ZjTb/J8oKEICgSwU5U5S F4yi5/qTdsnf/X4bbsfoLtbj5qEFuOnKFD0ubNHqEZdQm2lB31xfTu1yFB4UkYH8lYAi kSsg== 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=d3ll2VtSLN3A8nhX9iE55BTSNDeOOmX0g404u4X3k4E=; b=Mlf74jSvp863qMSn5t8fPedCnQDm9a90qazlOQLyEtiwnpCV46XqK0iGbmSK2YSd4a YjFWcRV3kMmAyO3PnT076pzYUHhUj4Nb0UUPr8dY0mE8K0XlRrDtZyWn6JK3dDJ87Obu xi+ETPR4cJVzakVzVGIhuOGhltsDaiO8vapGEDRjgZVq7rLxOR93cbMXu01QkE2WSTB4 jhQyrcP4R//uwdxPLeJnRryNDYxxhT4yDy3bQFZGmto5Sp6QwINZtK+XANnFpP2N+UR8 UfXzcP13tGWeERaD/KbR+4XK5U1xdQ1MLZfwFk4Lc4TCZh3IRNHy0e485WpsxpkvkHOG fDtA== X-Gm-Message-State: AOAM533NhrwJjaCTtRrsurPsWgxdDlAeLvmYTUYUjxX0UY23QsXsdzHN UnMlKTf+i17R16bAO5SpYylATSKj1B3iGQ== X-Google-Smtp-Source: ABdhPJw1j2pT4GB4solIrBVNLbi/FxGYTlQZnOaXMysgSuYqdh7zzzbgKqD19p8jSzjcCRLxmgh63w== X-Received: by 2002:a9d:3424:: with SMTP id v33mr15063037otb.137.1619453753978; Mon, 26 Apr 2021 09:15:53 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id 88sm3503139otx.2.2021.04.26.09.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:53 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 11/43] completion: bash: get rid of any non-append code Date: Mon, 26 Apr 2021 11:14:26 -0500 Message-Id: <20210426161458.49860-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 d87d1ad12a..e05588e109 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 Mon Apr 26 16:14:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224505 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,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 B735AC433B4 for ; Mon, 26 Apr 2021 16:16:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B0E761139 for ; Mon, 26 Apr 2021 16:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234356AbhDZQQl (ORCPT ); Mon, 26 Apr 2021 12:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234355AbhDZQQl (ORCPT ); Mon, 26 Apr 2021 12:16:41 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A0F8C061574 for ; Mon, 26 Apr 2021 09:15:59 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id z20-20020a0568301294b02902a52ecbaf18so240664otp.8 for ; Mon, 26 Apr 2021 09:15:59 -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=2Vhw3XbjeOHteQa7HFxqAjjBI4kBKlE6wqvnhG7RLNg=; b=K97yfJaDgXTJjqGdpzV/4lJz6YjwqUi3GnnapGbAmdfOr7etCaZxBQWRqyU8gqzBtb 1QInwMTjXu+1d0k1LMOxKin/2u8D2WX6+UHiNecRAuSg7Nu36tShLvB5Ic7kBvtINhOQ GL7RdnEpBOIY2biqapQWlfe+a9yLEVVpcipewWst2QAksf/Hj1sakzm6m/2iZ7Fr39Ne 4I94p1J7iOGZ9gX4wOdvMPxSTCv0zyyEKO+XU/ECC64V2EIFFi4afGxaHAXHmzgwakaU CpdPXFSjAdDnnh0RZXH/nNtqZXHeegw/t16KOZv8X/7KmPAazrljnPBrKW8K4ls2kciK UHYw== 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=2Vhw3XbjeOHteQa7HFxqAjjBI4kBKlE6wqvnhG7RLNg=; b=KV6do/w6kOuciZu5lDelq4Q4ow+Bw5y/1NxaKiWejAupHsdmro7c7fbYIf0MmVLKCr KSeF1VYDxr6ZHp6j5Orpbmne+b+H4PXW6iTq+cgpYw8MTG/Btu8q5/bZ4ogGladJSsCQ KT3i0JliQtUPwbLFYihdkBt4zpr5e4GM5SoYihit1jRuqs2L2SHm+9Ag3HqfiuJsmTyZ dz6DLrEPfMUjx/VaK2Uc/fGSHyGoG9fl4y+2M02t6+wXor3d1Vm2vBdKRAjaFW8TWiMq PJvrhgMzZmKlvHgu9DkK+7JhZmOy2jTtn5g5Mjh3yEiPO7B0dlW/h21EW68/gl45E+ZD YhyQ== X-Gm-Message-State: AOAM530G0qUK1PW/Z440s62WUzEa7zHyENgcKhCbt1HHIZKcNWR7zgrA roQY++65+xX7ROg7Y2Pus4oNvoOlRsB85g== X-Google-Smtp-Source: ABdhPJwvQyJiU3lBqClFOnxi7rZJMykP4guobI6OvGKFM9xt/RgFkl/PQZWD/TuoxIbinM1SxzdI4A== X-Received: by 2002:a9d:4d9a:: with SMTP id u26mr15382807otk.161.1619453758704; Mon, 26 Apr 2021 09:15:58 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id p2sm64810ool.15.2021.04.26.09.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:15:58 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 12/43] completion: zsh: fix options with arguments Date: Mon, 26 Apr 2021 11:14:27 -0500 Message-Id: <20210426161458.49860-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 97d2bcadd6..966b2d9277 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -217,15 +217,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 Mon Apr 26 16:14:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224507 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,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 23172C43460 for ; Mon, 26 Apr 2021 16:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4B2361166 for ; Mon, 26 Apr 2021 16:16:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234360AbhDZQQt (ORCPT ); Mon, 26 Apr 2021 12:16:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234351AbhDZQQq (ORCPT ); Mon, 26 Apr 2021 12:16: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 EF6B7C061574 for ; Mon, 26 Apr 2021 09:16:03 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id c8-20020a9d78480000b0290289e9d1b7bcso38529862otm.4 for ; Mon, 26 Apr 2021 09:16: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=+o9SlKPJQYIkGFHCKhrfKvRoe4G7Vu37d1Y9ElXihzs=; b=ZuqV1gKmYvYf6tS7+oJdsh1kWGVf8oMveRy1L2pr/cuA01h2ozLpm2r1QqAPl058ng KBHinNk38eEoO+hib8+96UKAUAYZFXQFBzl2Tv45N3jgZyS7yunvZxU27p77Zh03z4Dp 2xYF3XN451WWs+NCIODbrVMVmR4b7VALpWlIlChnHnekaRAYBAVBEvur8lG1d/rBH+oH cPEWRIcAF5KrR526Vo02dcvtnT6jSb14xCg5a0KMqG8CD/A97LHnJbjp9v4A6EgazGAk ZqXtFvax3XcWN1OPl0p6zUG3D1TDUjVruoaaPAYsMdvLLLy4MCdfGC0QaQI8Oga/eyHj e4rQ== 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=+o9SlKPJQYIkGFHCKhrfKvRoe4G7Vu37d1Y9ElXihzs=; b=SQhWHxB8wXZ7FPK3noN0mb784W+y6syO98eeaDA2Vwg7CaaOQ6FpMUWwujNVSY9e4w eiND2C+29QtYvJQEpl7/x/ztQUAfnwO1wUC+VB5OMNMjSTE3HWCCrQ2splzVPta6fEyx 7r0jb3xaagxzlxnHXkr7eS6AilmQkOtPhRKB0hgucCgf/VSozDsn/6rWO8g8YikAIqla ZvalHb698vnPj48UE/1D4Koe73s8YMCGsGmzvqj0Rf5CBGuxfTM/lxK3SuxDfAsewWEh S01E2ZWFZeSOv5trVnN2ncFCTMLb96eOMiDlvc5Sis/XbCDEhXwdzgLFPf1f1p3Z9jnl z39Q== X-Gm-Message-State: AOAM530GeTwr6OfJXjk2myUgfKDN3fl6fBdn1HwblXM2cz8dM371mRgZ 5QrBoF47WaTpfQEmMy0L9hIV7w5QFQqfaQ== X-Google-Smtp-Source: ABdhPJwzHfB49WnwIjNlQV6SJA3V69OC5VtyJS9UQ7sN1uOzbgeFzOTY0+Dg4byu1XCG7LqnyelmRA== X-Received: by 2002:a9d:628f:: with SMTP id x15mr15634523otk.186.1619453763215; Mon, 26 Apr 2021 09:16:03 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id l8sm1673455otk.36.2021.04.26.09.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:16:02 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 13/43] completion: zsh: expand --git-dir file argument Date: Mon, 26 Apr 2021 11:14:28 -0500 Message-Id: <20210426161458.49860-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 966b2d9277..755135a2a5 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -247,7 +247,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 Mon Apr 26 16:14:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224511 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 6E7D6C43462 for ; Mon, 26 Apr 2021 16:16:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C11B61175 for ; Mon, 26 Apr 2021 16:16:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234378AbhDZQQ5 (ORCPT ); Mon, 26 Apr 2021 12:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234365AbhDZQQy (ORCPT ); Mon, 26 Apr 2021 12:16:54 -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 8229CC061574 for ; Mon, 26 Apr 2021 09:16:08 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id c8-20020a9d78480000b0290289e9d1b7bcso38530165otm.4 for ; Mon, 26 Apr 2021 09:16: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=i2MOBtdHMahanoqvZUvSdq1kGIAekDpUtvAp9RouC+w=; b=nWJuB1AShFfc1lx35PuepgvRAYGLhtJxA3DLaE9aiE3NIW5oTBqqjtcGbD9MC74CpX paLocp4sfAbm1N4qOkmSWEJ11GeIt0MEEadUtjRhm2bHQR4TzSGnNguZ6/1yuZ3kmf1y tskjgGZC6xDwyDbh9jAuP1mq3kBPcUFWJzHgS3FyiR9d8fo52goAy3c1jXtWRrzZSUp0 D7kxmvq1aTfPEh1ie/Tm3IaY9JjMTuFjyr8v7GSrvhj1NM4Ez2pfU8XH2sToFwNWCGfd HO+R9zQWf7VRjrI78HMsEMZ7xp+n6+AyqnCAxgMneyRF4WRJVUEyG1miD4PnFXxNojff 0mug== 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=i2MOBtdHMahanoqvZUvSdq1kGIAekDpUtvAp9RouC+w=; b=MHK7M3vurWPJcq+JUko7TCydlbgy8AtsCvxkBAnQeO8NV3XsU1pFW9+gwRcmA5WbeH Ld9RLAaxdFy6rpQTspUGzpByBDovUNoDbMHKBwnIoWJ5GDFJXln38pfrhLro3z7Un912 wp9A2YTyO2s3geOfYUpvI60drDXVTID6ItOyZp+MWms0M9XdlSC+gvYkyNNusrvUljRs hw8iPv7BOY1amrYhEFnkZo6l2ZikpQAVr1AY4uRrETprLYlYNAllBHl6RjxKtjJE1IKe LLZ+orQfEIB43ARpJEGGcXKHUjLP6FSZ7Rw68tELWjghRxYBRkDxQ8GxN56HTl8zobVU Uk5g== X-Gm-Message-State: AOAM5329NoYPSUA8Viupk2tDTn03fBBgZ8Ew1IfzeysuYipF/QSnG2lu 24LtvwfGpupwN4RN8AsNjGPWguQUfdqTYQ== X-Google-Smtp-Source: ABdhPJxBHUylGBOUSU02vDKBel29C4hPIH/uvKTLXrTXiDlOnkX62rp6tWqPLf76DlRbCmXS76TqDg== X-Received: by 2002:a9d:f28:: with SMTP id 37mr16485167ott.286.1619453767721; Mon, 26 Apr 2021 09:16:07 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id v3sm69444oom.38.2021.04.26.09.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:16:07 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 14/43] completion: zsh: add support for general -C opts Date: Mon, 26 Apr 2021 11:14:29 -0500 Message-Id: <20210426161458.49860-15-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 755135a2a5..a9177c7dcb 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -210,7 +210,7 @@ __git_zsh_main () { local curcontext="$curcontext" state state_descr line typeset -A opt_args - local -a orig_words + local -a orig_words __git_C_args orig_words=( ${words[@]} ) @@ -228,6 +228,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 @@ -250,6 +251,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=( ${orig_words[@]} ) From patchwork Mon Apr 26 16:14:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224509 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,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 7959EC43470 for ; Mon, 26 Apr 2021 16:16:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51583613AE for ; Mon, 26 Apr 2021 16:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234388AbhDZQQ6 (ORCPT ); Mon, 26 Apr 2021 12:16:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234372AbhDZQQy (ORCPT ); Mon, 26 Apr 2021 12:16: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 EEA14C06175F for ; Mon, 26 Apr 2021 09:16:12 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 92-20020a9d02e50000b029028fcc3d2c9eso30109578otl.0 for ; Mon, 26 Apr 2021 09:16: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=RKoUy7drQJiipYRKCrljZ34NjTyXIpQgKkMvUxwB+VQ=; b=Oy3VnXZORjItuq349CyAiovmRvLnS8zyRvt63CB+nwjJIMi+24a3c7egUXRTLbvfVZ evkUtSQwpoxkHwlpXOZ13TAqfMjeyzOeCvKeuI9vwO+9glmeifLChe2C7icjqjOdd+WU AAHwemWsspPLcNgVEQi0yd3Hz99apfKY0wOm4ShuGrhrJ15iquhGY89ZqPxD/yK7aM87 Npc4vdTJAO3sdgLvil2ZZhXz8/Qswd0J5nyhUGTYd1nGk6cKEbNaomaqd8GtzjelTE40 BDU+aHybF2wuk3U+iByQjjYTe09H1htaOpmL0hwUmWDNdjtTah4ijU6+TG5hdibfDKgu 671g== 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=RKoUy7drQJiipYRKCrljZ34NjTyXIpQgKkMvUxwB+VQ=; b=KrQtlXzOBVFQoItF+du7FeNQ7yg2Cospq+cyzEhi/BMPUE0QikaCQ7mah/Oe43EBsW o+mFyrGEO8hv30u6WABfeV2zRbegjvC+7aguRhWKjuNsB9fMsVT1Oku2NDuZeUo7QGyC If9Z4rbzBkrhW9wZXjAtkZZzmOnbHbZFQ8XofzDUs5eMQOsNTnJHv2kr5mOI33Qtt1gB vxl69vEjRaVT36pYOJg49lKzFAWxBJzWU4YshgtUm2ne1y8dA2v6M20zXCskBK2dYgK/ pZbeTyNzRgldudDq6+V80Nvmd7PbPbaAdcA78B93D5X/7N25as5WEFw1aHJK66PQc5Cc AWyQ== X-Gm-Message-State: AOAM531MNafyY0jn5p4geBUTil7/DLwaaTzfLJCgIZurQ1hgk4ZwQhVg yEQXW6yXgkHvyAO41xl9szwTAM2j1S4Krg== X-Google-Smtp-Source: ABdhPJysetSdk/ETN8uxoVMcwsdT/+gaF3trnIoWDus/W7UVAUCTvyrAFkujMok061f1ehmyKdRM7A== X-Received: by 2002:a9d:2622:: with SMTP id a31mr16024529otb.275.1619453772202; Mon, 26 Apr 2021 09:16:12 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id h12sm3543283otk.55.2021.04.26.09.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:16:11 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 15/43] completion: zsh: fix for undefined completions Date: Mon, 26 Apr 2021 11:14:30 -0500 Message-Id: <20210426161458.49860-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 a9177c7dcb..46564126e4 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -140,6 +140,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 Mon Apr 26 16:14:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224513 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,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 DEC08C43603 for ; Mon, 26 Apr 2021 16:16:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B03BF61164 for ; Mon, 26 Apr 2021 16:16:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234401AbhDZQRB (ORCPT ); Mon, 26 Apr 2021 12:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234393AbhDZQQ7 (ORCPT ); Mon, 26 Apr 2021 12:16:59 -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 6FB4DC061574 for ; Mon, 26 Apr 2021 09:16:17 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id e89-20020a9d01e20000b0290294134181aeso26802862ote.5 for ; Mon, 26 Apr 2021 09:16:17 -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=YE93WeQLkhDC8PCnEEAgY+GsjpFprY/UOVl8NiYKJ8Y=; b=gxXfu1PuEhbH5gFf0ROwv+FqdUJ638Kuq8dK3hzHdrdDl1X571eoqCeOVjAXIcJvbj MtiN6fiJWMj7eqp32WY+GpyZWDQ5UMQC4Q4ahj8OrQSYoGrV5+Jp5VdGUSBQcYKNc0Ag 7TpG4KLMPZOdXHrG+B75q7pI1HLUE+Bd19rdDYd3jvH4gDEo1bgDVtXsM1JcSOfakCA4 53/PU1XyYivuuKT+b4tHNSjM6lB1Jj21u/4rAxMNwtAlALF1mb3fqqiMDup7Y3O2eSIG IZi1SRqpNz24XUNCq8GaubZh25Tb9hOYjow/Q2Y4yq6Lhr5KN5idbFhahBR5ThY+6HJz ms1A== 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=YE93WeQLkhDC8PCnEEAgY+GsjpFprY/UOVl8NiYKJ8Y=; b=r/5wKT7cYH6oXWN+ijnd9AXPeH/KZu3lxufp2eNX/zJKEek20BEO3KwH5hZfEn0GAp PJRf5YE8hS1dsue1sTCZDpatF93S2kiey1IhhebeDIhEfMV79Pb1VX5IPrMm4GvFaMu3 cOjla4pW2rg1TZ7rfcmoJp83JzTT5okLxgQzLTdW09K+aaf+G4tcLzbm3BDj+YdFQdWd nJU10EAeMb7BZndltaN/eZ9er9+uad3tZ1qXGLATmXWU8pBxypP8QK+QIxzwY8goharJ s4PRd8QiyQ/FH56DTgs4jchDzDZq3XdI11BuCUu9PP5yC+GK0TinnAPvj97sxyRVLch9 F3rg== X-Gm-Message-State: AOAM533EWajkJ/DHAC0SI3sGX8WnX6vo1qMrKd0cla9gSZB3yKqyZ+Ie cd8IUvcjY1k9IOIqTQlocfWPdmfelUHWnQ== X-Google-Smtp-Source: ABdhPJxGBz/arJwNKthysMh7h6CLcDNbHmlMnsRk1W7iPHghhF9Rdq3PHC8h6/umQ5yUgDbC7C8ruw== X-Received: by 2002:a9d:3e4a:: with SMTP id h10mr15687407otg.252.1619453776691; Mon, 26 Apr 2021 09:16:16 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id 2sm69881ooy.22.2021.04.26.09.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:16:16 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 16/43] completion: zsh: add support for general -c opts Date: Mon, 26 Apr 2021 11:14:31 -0500 Message-Id: <20210426161458.49860-17-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 46564126e4..6232d0a823 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -232,6 +232,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 @@ -245,6 +246,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 Mon Apr 26 16:14:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224515 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 C7481C43460 for ; Mon, 26 Apr 2021 16:16:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 906A461164 for ; Mon, 26 Apr 2021 16:16:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234402AbhDZQRI (ORCPT ); Mon, 26 Apr 2021 12:17:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234170AbhDZQRD (ORCPT ); Mon, 26 Apr 2021 12:17:03 -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 F1899C061574 for ; Mon, 26 Apr 2021 09:16:21 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id i81so56951079oif.6 for ; Mon, 26 Apr 2021 09:16: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=uMJvwmyU+l8oG8yGKAfmlKQa4GNrJ3s75/vQURhiX7A=; b=lm663jJc1x75xMliNqw+KqEJLeHB7wgXJGQpWKlLLxUL9LJhPUyFTfNu1YWD+d8zcb NunUHZZnVYd4LNKcPtlGVLmGcKpXo+aWPFs0aHhzHX1/8hVKNYotRMh0BZ9fujqburtC Ih1TMZJJTaM6Mt55G8Z8UQR8gX3O8LP13irk+gPUE6nCcM9syDBp9UOPjkwGefAWQ7Vq EZHJL4nGWNsNqSaTsnrig+nxaAAQ7IAdSIepB5v9gyRMslLNQxAkneNPLGw704zLHOip E9Us761fXST14S8ueS9qGEiHm/syoyHDf7Z09Tg63PNEKDI7VBmeuUEqn/Au84t8YnFj uzxg== 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=uMJvwmyU+l8oG8yGKAfmlKQa4GNrJ3s75/vQURhiX7A=; b=lMqZfsiTZbE4hzbVN1urMpvk/ZKTWTIWFJC6VlEeaBQpzECaN2fpFln0S4R1pjHTKe G8wVXnX/ScpatPk48XxAeZVUNiQpBLo8S4Kzkso3OQgLHmcqK/Usc7M+Lt+TfprZS6tB Hy0fe68G4F8uFY8fquL0xvmfVBrmhXbB4vsl0iU69JlDgoUGaaG1TnM802SSxTLmki1b gk5NSYhLvBcMvJzHFKmalOlxr1qFpD/ekNAFig9YGUkBe7jqfH6lnsdWjY04LFDJ9Fqo EZ9L/h+A3t9FEuYMzVlfEVlUg76Urn5mFYD+oxSNorJzDoK2IH26T72t9PkbVra/APGl iYYA== X-Gm-Message-State: AOAM530E9EanUSqkPlVxZrA9KziJswexGahe9q8vGgLhTzu92PKagJ7j q2d8QbUmHDJredLkKF6WLGxsTttS9gGx9w== X-Google-Smtp-Source: ABdhPJxD/glY2sfh0Ug81Ar6m0opMxb4G5s/3cfWlYahbXRLsHpi0s9a49PPL3K2j2jAldIhJgBphQ== X-Received: by 2002:aca:5307:: with SMTP id h7mr13721432oib.140.1619453781218; Mon, 26 Apr 2021 09:16:21 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id r19sm3098320oie.58.2021.04.26.09.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:16:20 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 17/43] completion: zsh: fix extra space on foo= Date: Mon, 26 Apr 2021 11:14:32 -0500 Message-Id: <20210426161458.49860-18-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 6232d0a823..073f7d91d8 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -86,7 +86,7 @@ __gitcomp () fi c="$c${4-}" case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac array+=("$c") From patchwork Mon Apr 26 16:14:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224517 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 E1BEEC433B4 for ; Mon, 26 Apr 2021 16:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC5256135B for ; Mon, 26 Apr 2021 16:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234407AbhDZQRL (ORCPT ); Mon, 26 Apr 2021 12:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234393AbhDZQRL (ORCPT ); Mon, 26 Apr 2021 12:17:11 -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 BD408C061756 for ; Mon, 26 Apr 2021 09:16:29 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id i81so56951520oif.6 for ; Mon, 26 Apr 2021 09:16: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=YIOEL5n9E0ms8ekZ+SF2/qGNCqq9wqO7huF95oRI1xU=; b=uWemPqufzVOkh+SYZkUn+yt+Wgw0aFWuEq1bLqN4GzLthLQH2Lkt4JqcO2yRcapX+d ALLm51EU3TN+naevWW4veyYPTe3LI3ry0pNMD1uaIxCp4P96odPiUBqidFJC8ihp5nqy 3fd/15eje8ifHB2wcvWNc4P2TgsZ7Ukivso9YmDxxeHKaXIKgm87qJb+4tcV7NBtmd9s nSVgTZh9yUTwkleZylBFVdeAXI/d9u+Evj+6IhIbRbeGzUksY79x5zzaKzgnlYZaMz5n RQfHVR1xIWQ6byQgzACVMYf733sqfeC9d0aAJX1VbPN17xVKTsAt3P25+QCOC1eKENy8 0/Ug== 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=YIOEL5n9E0ms8ekZ+SF2/qGNCqq9wqO7huF95oRI1xU=; b=terQ44jwI0pyPK90eFM1W1dBFRRPppYkDDt2fwB/NbEi9pg5Y9siw0GnsQRjDvaQ0x A93u0sxwCFmwyngjEvGxrLZ5Swca+Dn9nH1re2DZoXR7pxVem9q2U1Yq3VDr2N7W/xak 1xPD3ZvP97xx6zjOoRgR5Pz6Me8dND3N47/0Us6okipUshc/4b8AHC5wAbzOULhkindf B9+Y1jogIsgTvXetIuhuat0ANyQAXHhFY1Nmh1kWA9nWXsTm+PxKoyJ2kBqyCkprATPW DWjJnlj4GXtsIggYLva0rmst9Nq9JzIzQ/nU3Ml1e+nWm+HcjZsNYpAU06O+TxaQ7gWi VwKA== X-Gm-Message-State: AOAM533BFizbzELiaLMMDwijNwWVtnKyB92Z1YVuyM/T6SvWaeAf6PY4 BGcmZlJ9eaNcZefx0EY4w6pUfu6RRQW9CA== X-Google-Smtp-Source: ABdhPJwRM9psdNVtRwC++QY+2XYpsxrxW/9OTxwwzaWmK/w3TWTp2kCEt4rR9/ddDTalWvxvuxIPTw== X-Received: by 2002:aca:c350:: with SMTP id t77mr12310269oif.42.1619453788937; Mon, 26 Apr 2021 09:16:28 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id d6sm70186oom.33.2021.04.26.09.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:16:28 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 18/43] completion: zsh: add excluded options Date: Mon, 26 Apr 2021 11:14:33 -0500 Message-Id: <20210426161458.49860-19-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 073f7d91d8..7cb0f33209 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -218,15 +218,16 @@ __git_zsh_main () orig_words=( ${words[@]} ) _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 Mon Apr 26 16:14: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: 12224523 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 E19A7C433ED for ; Mon, 26 Apr 2021 16:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC17961131 for ; Mon, 26 Apr 2021 16:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234170AbhDZQSU (ORCPT ); Mon, 26 Apr 2021 12:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234124AbhDZQSU (ORCPT ); Mon, 26 Apr 2021 12:18:20 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C256CC061574 for ; Mon, 26 Apr 2021 09:17:38 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id n184so30938008oia.12 for ; Mon, 26 Apr 2021 09:17:38 -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=V6UfQxIxsalvtrGNwglxAOOmRAOF5u8G5oVXrT36s9M=; b=AQ8dt8ScFCEriPH7meTNbebMn4N52SNstqNr7BfoWDlAeSXLyk6uu5dcfIokkdKkOP ZIPnsmiD1BeSLrQUaUZQalkuDZT5raLHxkSixNNd5Ol5ALlDEWV5Mf3XsyZLsO9Pk71o kWEIj2RcXd3zApCAPHM2tZHzFdG+iB6gsERhXSu2lWnVCLBsmSFgd7+GWZeaNRcL0pii JXzDLKzs/2GeWniJdm5Sgr9zHxaSa/YIx/FbqRSWepeTQ9/5ygJv+sb/4nCgJhVFLm1g lydjPIJ3Tfprv28PrS27j1KKhi3wy3gCnHBkVm0qX8pgp+OeH2tXbI8QzuFoaGVUdh4p LEDQ== 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=V6UfQxIxsalvtrGNwglxAOOmRAOF5u8G5oVXrT36s9M=; b=iA55wWPUpS7gvArW7ve1ApP3fQWibMKfr6uCxNCcez1L04EnZUEd0TSpPtU74DzPeK S+XbWmTIHclB6Xz/iyr2JNI4T0Y0Lkzl5JAyTHNdtajCANY/I8B3h/yLyDfJOg8LmMH3 7VROmsEw9GG1/IYTHjWipQFaWPFBXzIq/7zzTM0fNCC+/jxv09+PLjg0Tgat3NFCOcw3 SbpdVjloUasCO9vcVgtGUNkMVoayyeQ25x28xmobRSXMyRZBlCexkGNLYmiSlq9LaMZU T5q/uYJkMc7LvEY5FficyMS7gY5pGWYfEaMZJnMNxBn1gLkoPkmzl+a6DrpCoi8UVHP3 EnFA== X-Gm-Message-State: AOAM532Fr2qql1tIvaaCYlX/R12mfiQl/XPAB3X5USeyWlYnI4D85+gV USM0ZKKqRKe/qqSEppTchd0EzFvnDbp8/Q== X-Google-Smtp-Source: ABdhPJw9jyHkI/SZpCLiEgaGQGig/Z3qZX/eNQswZtBuGUprxF6vGfU0CeR4ZHp0/AaFqNz/ktt72A== X-Received: by 2002:aca:6088:: with SMTP id u130mr4709467oib.51.1619453858001; Mon, 26 Apr 2021 09:17:38 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id p64sm3123971oib.57.2021.04.26.09.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:17:37 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 19/43] completion: zsh: always set compset Date: Mon, 26 Apr 2021 11:14:34 -0500 Message-Id: <20210426161458.49860-20-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 7cb0f33209..d754086877 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -72,7 +72,6 @@ __gitcomp () esac array+=("$c") done - compset -P '*[=:]' compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 ;; *) @@ -91,7 +90,6 @@ __gitcomp () esac array+=("$c") done - compset -P '*[=:]' compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 ;; esac @@ -101,7 +99,6 @@ __gitcomp_direct () { emulate -L zsh - compset -P '*[=:]' compadd -Q -S '' -- ${(f)1} && _ret=0 } @@ -109,7 +106,6 @@ __gitcomp_nl () { emulate -L zsh - compset -P '*[=:]' compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 } @@ -117,7 +113,6 @@ __gitcomp_file () { emulate -L zsh - compset -P '*[=:]' compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } @@ -135,6 +130,8 @@ __git_complete_command () { emulate -L zsh + compset -P '*[=:]' + local command="$1" local completion_func="_git_${command//-/_}" if (( $+functions[$completion_func] )); then From patchwork Mon Apr 26 16:14: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: 12224525 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 4F400C433ED for ; Mon, 26 Apr 2021 16:17:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EBAF61158 for ; Mon, 26 Apr 2021 16:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234316AbhDZQSc (ORCPT ); Mon, 26 Apr 2021 12:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234124AbhDZQSb (ORCPT ); Mon, 26 Apr 2021 12:18:31 -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 468D3C061574 for ; Mon, 26 Apr 2021 09:17:50 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id e89-20020a9d01e20000b0290294134181aeso26807963ote.5 for ; Mon, 26 Apr 2021 09:17:50 -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=NkCy8Zj7/tFE0ohbC712KF8zRYjbl34aNl+fKWbx5iY=; b=DGQ4Aysa6pbxdmj0ou5P2r6TjRjJS/EOOvVGI4OUfJNXA6kwqXixAue8Q3YaxCfxs6 vpi5cIdtUDoQMnOC4oZ+4rsE+UMwYb25qSUweNvbuLJpu1zHXJ6CSpHZHEOxf5Pz1/Ix AC2+kaOhoB0pQvpb2Dc0bSIjCVKbwJbwETxE5GXWu0sM/mkQLHrY/Iwa3PJVkFyAN9a9 T3EcMsNT0sZcVLv6qiDnaSEUc1Koz2PavZCGBlYlDKJTF6mjlMAH6E00ge34r4rRvBbu skndNcuolP4z6+uWsVgtnDME5SuX71PhnGnzJUYqssLyF0DVgUdsDL3348Kwy1Teo47c Z1og== 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=NkCy8Zj7/tFE0ohbC712KF8zRYjbl34aNl+fKWbx5iY=; b=HbYL4TDYxqlrMFMMSRooAvSyUNDJe+ZeFXfRirHbU1Hhtg+A2GPBgq15pj+cKbNOVH zcljj0+uS9Jn6NzBbNYM5bNu7cyyeZy/fetLI50YN4lrSnovf7HvFUfQpaFH6hZmHhTV +nW5OeOHKsuqi4FGOrybfcsll/HWFFyLBC0qNm4LVLKnl02trQoghQSjKIrBNwn0kKKh hbnBJCnv9TyQr1Vw4zuY85Eywn+sn8SiOoM5qUCGchNwicz852yXSnN1HgwABfqrrhW/ KJc6/+uVM0RL3YEoJ/qFbKACTIJ6zXzkl/L7PhMvFOOrkLbQA4hmgShc6le+JtbGXuRN luGw== X-Gm-Message-State: AOAM533J+G9mZN+WlQT6pSY1V8my+zWNjC31yTgEoDIuudcDqwbNq8wG qUcWS2hB6WlKVQ7kg9sBLvX1HtTFIZf2WQ== X-Google-Smtp-Source: ABdhPJya9mZcJc7pgz5EJh1bAvPEP/xZymRCqfILzTsHclSQjtx7A2vPf3qABRq/al7znDFi1hVR+Q== X-Received: by 2002:a9d:2608:: with SMTP id a8mr15599145otb.136.1619453869501; Mon, 26 Apr 2021 09:17:49 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id c65sm3123034oia.47.2021.04.26.09.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:17:49 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 20/43] completion: factor out check in __gitcomp Date: Mon, 26 Apr 2021 11:14:35 -0500 Message-Id: <20210426161458.49860-21-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 e05588e109..0d00bfe83b 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 d754086877..090c644b71 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -55,9 +55,9 @@ __gitcomp () local cur_="${3-$cur}" + [[ "$cur_" == *= ]] && return + case "$cur_" in - *=) - ;; --no-*) local c IFS=$' \t\n' local -a array From patchwork Mon Apr 26 16:14: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: 12224527 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 B53F1C433ED for ; Mon, 26 Apr 2021 16:18:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 839E960C3D for ; Mon, 26 Apr 2021 16:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234393AbhDZQSx (ORCPT ); Mon, 26 Apr 2021 12:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234454AbhDZQSv (ORCPT ); Mon, 26 Apr 2021 12:18:51 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D682C061760 for ; Mon, 26 Apr 2021 09:18:10 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id u16so39645430oiu.7 for ; Mon, 26 Apr 2021 09:18:10 -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=9b+ft01Mh+8KepunERauSp/wqCcfeGnl/4X7z843wfw=; b=I+zMDsC30NSEKPWUAEdjI1KOFNvRKmcMkj1ojmY4wyabAQCe70qPboDZiBmKLPUyyH rMRJdzkwET6oEDwW99LgUjfzYJjZbdqLBLPl+dnqx+AQXYxI1WEK6YttZa9UzV/usCIz /CgiiMAnA8AVXhN4EoYLnmHWv0r26rH5sUF82nuDaEQIabKHt1PP1XsWPJ4pCnsfDdyl akcGLLfcn40KEusFW9bs762Nziew5KgyAH01EqQsjCcfeL8tGG6Ook8HXfzsPy7zYKjA Xf/maveY8osduzexD+RrJgdZ+3WE2G2zv0ckCHpw7WtgIpq2q0TV+uKlVaBtKV/7wq3g d5Ag== 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=9b+ft01Mh+8KepunERauSp/wqCcfeGnl/4X7z843wfw=; b=GsEu+W7FsU/BHTDCpVMr8DG91QrLUIjdoZaZHVFBoX02Fr7b6wqQHrhwQ8Cf2Hve4a TGHT76Kr0iNZfET10IFeyyv/jl5PLu/JqDOGbFPvcOCHm38Zpm++2rxA4DbfHdA210fz AsOj8tJEVFgeV6wXe6EQXO50riQ+FQloYgwXGn0dIgG1+izfjbvWXVDMMZp30UcvsPlA QSD+XmzvP+HXrh/VqrU7rSvOQ0AkoSAzPi/cbK63BniFBoP41hDDheiiDkaKhxI8aW/t 4iT4qYpm4unwmErs7cOiOcTeeVaUwxAXvHWKzjvDBeNapmY/ccmm5A3W20kqAZ3H6QSb 5oVg== X-Gm-Message-State: AOAM533w+iqfUWcAXFKdDsYMTchudR4pmy4PR9QRjZxmCBkZnm4//5wR yLP+BSmYr73/CF8JzsgF0f7m8wUbSCFn+A== X-Google-Smtp-Source: ABdhPJxq+xxU1UpfvQ89bejxYGmM8p3UD+Y3vQWgq52tbxwD7RkF2T6dUkIGlV8ixCc1vKht4TaN0g== X-Received: by 2002:aca:33d5:: with SMTP id z204mr14218582oiz.32.1619453889132; Mon, 26 Apr 2021 09:18:09 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id z23sm152011otm.51.2021.04.26.09.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:08 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 21/43] completion: simplify equal suffix check Date: Mon, 26 Apr 2021 11:14:36 -0500 Message-Id: <20210426161458.49860-22-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 0d00bfe83b..cd1e0ba704 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 090c644b71..8db7d0693d 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -67,7 +67,7 @@ __gitcomp () fi c="$c${4-}" case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac array+=("$c") From patchwork Mon Apr 26 16:14: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: 12224529 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 E8676C433ED for ; Mon, 26 Apr 2021 16:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB62761158 for ; Mon, 26 Apr 2021 16:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234445AbhDZQTB (ORCPT ); Mon, 26 Apr 2021 12:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234428AbhDZQS6 (ORCPT ); Mon, 26 Apr 2021 12:18:58 -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 AEB46C061574 for ; Mon, 26 Apr 2021 09:18:14 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id f75-20020a9d03d10000b0290280def9ab76so47506420otf.12 for ; Mon, 26 Apr 2021 09:18: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=GRwlvvsPZHYd1Dt472oV/8cSH1PkrSf+r/I7eRUzh5E=; b=qRt8S1BkcH6j0C7lW83VekX0LIyPUOjd5cx0Vd5sQ7RiUrmYVlTsLLh+/6DiCPZLkZ NYJT7BSuWcG79BPerwxx44jbIDDzSctweZPRqs42kHjfklRqRZAwFtxLUawdRI/HHJHU UxWlpZ00qE8051fwk4ZzaWwjmez59G2I38pIu8LxlC0rc3Fwm/u9R5xpKsepyFG07Zf+ iAEYsJ8uVjCnfgYgsSvsgp1NnK6PJGpEhFH6KCUP/SXIXcpXPyO7/rTGqBxvimWmP6l5 ZcgVCwjQyi3RP2PhsI3Zb3muOT/yoejJbzYDCiQWdbwNAr0h/qF09fSKf9HkIIuK38gP FoOA== 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=GRwlvvsPZHYd1Dt472oV/8cSH1PkrSf+r/I7eRUzh5E=; b=askzLy/xZIrStp8xVS3PZmJlFkdnOwVDVo44YUIJ833iIMPpT5LU42Wmo0rBs35A3s mk1cn6Ed+moZ3Bzx4uSE+Y/TRjHpM9/Q+lRy7NvYoc+i/d+hMIisTP6FCQBtDJKzgNVs JNQ+4oXXAAre+EUOS8pKcI42f+6/Y2QLs0337PjDNhT+3NdHmouBMHHxxKwcjriCiUn6 H04Mwug6CdAcFO4zC3T/C7wIhi10Fa+6NjOq5htnCaQarKzSS+YyyTmaplDcxAh+yzlo WTp9OX0E1yp+CcbIrg2+lB60IvKQ4qZhLbV+rRcED7LxLU2u+Udc+rnTQGetoBwf7hED dKdg== X-Gm-Message-State: AOAM530kdV+w+z3hGlCnk1wzfzLtrLF+xjL3mY52WX3wd9ayMLjnZeOp dTS4SEShSn9zgiRYjhwXs5tSKQ/Gc/t8CQ== X-Google-Smtp-Source: ABdhPJz/h+Lnq8E+SKqSJxJ9n5IL4sxF/6m9mJ6j+Uj8AIM4qN92LMY8CLrausPmjzRhSA40YnP//Q== X-Received: by 2002:a05:6830:19dd:: with SMTP id p29mr14812668otp.368.1619453893743; Mon, 26 Apr 2021 09:18:13 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id b2sm3622714otq.80.2021.04.26.09.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:13 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 22/43] completion: refactor __gitcomp Date: Mon, 26 Apr 2021 11:14:37 -0500 Message-Id: <20210426161458.49860-23-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 cd1e0ba704..6c8a8f6f5f 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 8db7d0693d..fbd03a0180 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -57,42 +57,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 Mon Apr 26 16:14: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: 12224531 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,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 9BAAFC433B4 for ; Mon, 26 Apr 2021 16:18:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 612C46109E for ; Mon, 26 Apr 2021 16:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234448AbhDZQTC (ORCPT ); Mon, 26 Apr 2021 12:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234315AbhDZQTB (ORCPT ); Mon, 26 Apr 2021 12:19:01 -0400 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E893EC061574 for ; Mon, 26 Apr 2021 09:18:18 -0700 (PDT) Received: by mail-oo1-xc2c.google.com with SMTP id d16-20020a4a3c100000b02901f0590a614eso4585090ooa.8 for ; Mon, 26 Apr 2021 09:18: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=ZYgQl0Spbq4LtnaXl/F1K/rUqpPWbk4hPCxHx4anthI=; b=aZi1d5jV70qtG7t4kllEAz68toJLHCXInXkwtzlqi7qpid/IPEFHTohmdNr0gC4r/K TDhViDzgwSPNP8lg61xnPOp2Ox6/VD/3jpAc+B2TmYl4mJ4kaTCi+3JT7ShRV8CZqpbA 37ReIAVhIRArMPzz8HmdLNpw2Muw+Cv8aDMFo13hmqctn1p9kmgkkmWFhc+6YUIKhsdM twlHsyo4bWePjW0xMwsAChyLZZt13xwcAZsfIe5gdxC9A1AL1isqd7xVVrfqQNUjHU6M eXhIxhXkRZBKWUjSdKTbNJbfkaLbniNj/YXnVj5z992ApRBZ3fJF+rX42mlIzX/eJG43 HJrA== 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=ZYgQl0Spbq4LtnaXl/F1K/rUqpPWbk4hPCxHx4anthI=; b=X74zZf3WSRLnYslMMLsD35cmBzPVnAhoZuwDiwSWcUTk9sjS4prn/qxM7n10XsZuMd 1X1/RkXpYboSln2U+knYfPXDnegw8rjsTSL0uwx3p+sKSqiDpbfazLMB4iyRUOUWSQO8 8zkEv1ly3mrZZui1F9AyO//rR744PFPBAoIqNmJ/ZX86TBKcbEdUaR7d3bucZYuLR/x6 cU1bKRUJfSc6nOD7PdO1AMeEjI1+SV/YdDD8850s7RqMsuvOZXOteJvHerVIDihsOQQ7 RIslFmCA5R19M1CBftt6RhqY/Zzhzh9fOjvoZweYN/P6irH8ferbyRO2eIoQlJbKSC8u 9SlQ== X-Gm-Message-State: AOAM533HzuGlMZk5OtPUgKT7qQSkSKyeCx8VBCZrxL0T1pznMGj6kMbz q6NZ5UF2mG9JQs+pJfBCChLc6GXdQv5ZQg== X-Google-Smtp-Source: ABdhPJzo2ssB3zusIY4su9gU64DmOhGMFFsQEzqQ4/HuAGdiLjQwH4ORFvm4oSqttTdL0GXhJ51xbA== X-Received: by 2002:a4a:3352:: with SMTP id q79mr13993582ooq.23.1619453898197; Mon, 26 Apr 2021 09:18:18 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id q20sm194049oic.41.2021.04.26.09.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:17 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 23/43] completion: simplify __gitcomp Date: Mon, 26 Apr 2021 11:14:38 -0500 Message-Id: <20210426161458.49860-24-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 6c8a8f6f5f..766c7f57c7 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 fbd03a0180..4eef9c5199 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -62,7 +62,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 Mon Apr 26 16:14: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: 12224533 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,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 D72B5C43460 for ; Mon, 26 Apr 2021 16:18:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD7226109E for ; Mon, 26 Apr 2021 16:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234487AbhDZQTG (ORCPT ); Mon, 26 Apr 2021 12:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234315AbhDZQTF (ORCPT ); Mon, 26 Apr 2021 12:19:05 -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 4D3C7C061574 for ; Mon, 26 Apr 2021 09:18:23 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id f75-20020a9d03d10000b0290280def9ab76so47506835otf.12 for ; Mon, 26 Apr 2021 09:18: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=pkpqofsC6vSb0sqju36o+DrgZ50Q5Sj9L9IIsXoOv0k=; b=cc9L6Lads9TOMjNNi/tFz+gTfdKMy5DYIbUj+H3U+EqmKaC8oPQsgwFES6ZRIJCjRI SRpIk7u8uW3z8Wsj8MJP5dCpgdZkmNharDJh6F9TqChnZJii8SjXZ5ieYQWqbQ6+aChw Otl3b59RihIWJbonsQF5as+wz+66TKKt9+hcZszgjHt9POwAGbjYd5yhiHK95ML7i5n7 pLNFlu0T6IPnYv8aqeHvyUfYDC76e4hPYI432UKq3hfOrPYCbgw5lJE0a+2a/1vFkuR2 6M6191xqH7hhIitezOYGW72zCdOcAtWiDLtIkJWgwcQgwtZGZtc/hUAowQIhmq4h3z+1 PTRQ== 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=pkpqofsC6vSb0sqju36o+DrgZ50Q5Sj9L9IIsXoOv0k=; b=AeoZKaXpzpUpOxbgQMyvoxks4wkeVJpZuV5UL40R2oGhGBlJtIHZ6rUxHBsyGnyGi3 1eyB17I/2f5OUpuMVnanzH0POoUpNz2nwwXUuI3U+7gvzGtH5LXB+Gpf1B0xfhKi7jFu 2NcO3iOda1bXuiRhSw89DdVyElWRULOF2j64TRpoGrf3t5BXHa42chNvRGFxEil//W+3 SB+cs1galrEAvKPlY8Itz/oHT/9O8jeIe/U0sFTYdjJXfsC7Crm5drUxdkePTut5QaVG PxvBsiZYGHOXc5fnGe5R5mlRHDM7/nCRwuFAbDGh9ldqog6x17Mm7cYhhgyJQghqxfQx K1Vg== X-Gm-Message-State: AOAM533+YNgj7dokx3Ab1dHzWPZby6KEJt2qHJUdTC/2bL1ST91Qw8a4 PDcmpnu7Xgw6lNyRCJwSQin+goWUBBqnfA== X-Google-Smtp-Source: ABdhPJyY3jHr1gO0cuLmkoxQtsfbb9Nv5hHZIfrczV+3GdI7xkmvJ4efpu3/qBMHp2F69cslmxsG8g== X-Received: by 2002:a9d:6483:: with SMTP id g3mr15639615otl.332.1619453902583; Mon, 26 Apr 2021 09:18:22 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id d12sm72940ook.1.2021.04.26.09.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:22 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 24/43] completion: bash: change suffix check in __gitcomp Date: Mon, 26 Apr 2021 11:14:39 -0500 Message-Id: <20210426161458.49860-25-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 766c7f57c7..82ef19097d 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 Mon Apr 26 16:14: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: 12224537 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,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 8B6F4C433ED for ; Mon, 26 Apr 2021 16:18:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56BC861158 for ; Mon, 26 Apr 2021 16:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234509AbhDZQTL (ORCPT ); Mon, 26 Apr 2021 12:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234507AbhDZQTJ (ORCPT ); Mon, 26 Apr 2021 12:19:09 -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 D1C20C061574 for ; Mon, 26 Apr 2021 09:18:27 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id 92-20020a9d02e50000b029028fcc3d2c9eso30116399otl.0 for ; Mon, 26 Apr 2021 09:18: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=AxXYflkxK6oOIVPavnjj/0TF6aV/yoobhFYoeo1WMvQ=; b=cX2Twyp76sSXbFe/pxxBxUG6TFHHvaC6shKOuI24i2NJoxRCmjpixm7+cwDLgcKKkH aQpTSZjblOpIQdh7JZZm6BJ98Z/+bGf3nYCjDdu+h/wrG3D3tFWQmoth1ys0qiPkWY6u xUxw70qIMB9dnwsgHoqv3hMUhvWjlK3Aa9fmF+CNJhJEEWFP9xak+SdGtAmOnXOaxORA oJxLqMoZkw7tqciu+T9mBGqcXLUMwQcpM4czMPbj7R+FXW42f99hgmfTbfivU1xmTmOP k8h4s3XJaLescZclV/xO3tsBZv3rUFw890dpujUA/X0najfHCULmf5s2MU9OM8tObmne HLcQ== 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=AxXYflkxK6oOIVPavnjj/0TF6aV/yoobhFYoeo1WMvQ=; b=RP18h6vitHYDkm2x1VZUo7rJMJXZw41LYiz/NiqQ6x3uCyne31nsiyjmWT7FL3pkWp vqF1ymsNlPzSovEkXaQGiNw2lLD1Lub7agUDnoxiu55wgCfoy5m5cf2ybVXOBXendrVA Uc0/K0QkxI434zfqMEZIqFXVzHZaZDmi4jnbgiem4NMlD3iORfrR/bwMzePcRFZKWqJ3 Zt9epvLGhBTGZSa8v8mjPpDKLqamCIPA0rD9hbSBOK+LL3vljO3F4580wHthOGI408Uy gph6MHd6i+3XsDcYhVq1/JZmWd/e9P12FnWvCgF3u+083rXsyddexaMcWKJk6mr+emOh Wvhg== X-Gm-Message-State: AOAM533yhBaodoLo22twjayZzRNLRtwZF3l8Nl2+K0ZIZGRSAmvCC2tk d5/mB28HuzxpR+REs3Lq0yfLTNi3liWjOw== X-Google-Smtp-Source: ABdhPJy+tatkZZMM7yc5gHaGo7trkEg7nsRNIjRw2sYB+TUgjDolB+6rVAhnGlDNF068uekMkik9HQ== X-Received: by 2002:a05:6830:1450:: with SMTP id w16mr7941251otp.305.1619453907053; Mon, 26 Apr 2021 09:18:27 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id x45sm3623250otr.35.2021.04.26.09.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:26 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 25/43] completion: improve __gitcomp suffix code Date: Mon, 26 Apr 2021 11:14:40 -0500 Message-Id: <20210426161458.49860-26-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 82ef19097d..096aa7b6e9 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 4eef9c5199..0ef15ff643 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -57,7 +57,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 @@ -65,12 +65,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 Mon Apr 26 16:14: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: 12224535 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,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 61188C43462 for ; Mon, 26 Apr 2021 16:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28CB46105A for ; Mon, 26 Apr 2021 16:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234492AbhDZQTO (ORCPT ); Mon, 26 Apr 2021 12:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234382AbhDZQTN (ORCPT ); Mon, 26 Apr 2021 12:19:13 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7FFC061574 for ; Mon, 26 Apr 2021 09:18:32 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id r3so3564341oic.1 for ; Mon, 26 Apr 2021 09:18: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=9ZXxkWPxz+Oilj7lF7mHPf1MEs79yaEDB4yyEpC1xvA=; b=FFExhWrn8E0OJXdpH+uZd3ou2KUVE2KzOZZqEtcwljUonQXH/Ma1pSrvm6n9DIzrni XhegQYl7YQZf7pX4ZpOkXNOQeSb4MvM7rRWe8XL8oUilCuieYz5Nxz13dW1FpX/Dcbca 5ftCO0CqWtoaZ9xkGF7CRvckzxSvrdZdyuJg/0mlBnrXMqU8cVEc9GSHxiug3uXmGIOb Ss11MoL2hwdhldwFthoz/K9i9Ivw4Z9k56U9jzkiRROPxhMrXj+OaYPwe9O/RSATtn0N mf88uR/9dZ41b22Li7MJNVoqe2iQmaYNlbAS8aPX26ZVmEYDb9UUbqC9kgdNSXfqleQy 50lg== 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=9ZXxkWPxz+Oilj7lF7mHPf1MEs79yaEDB4yyEpC1xvA=; b=BV9F/qlmSRjig0gGdHfW/LK5ArRBzWtiD4o2dfhsWZb80yEnujSd+9fPeBfyI8A9LI zRSkoYtKS5ysnPCagKd74AEORc5woen/uPmkkDlNeJRZYQzYeEF/YQ4o/ebqTKzRuRtn avNcbvr90igurgdaoodpUYGidWB+jB0phjUpYGHO+dR9AbSddQosbbpZCob4Q+bKrVgJ Sq3WhPyetGXSqcdhCdmJLKkNc0QWyMYUeMeNjpXUQWtqmd38r8YkQAVsV1DE5OkppvGB fC41wa8SE50ym7qOJprXGKwBxFN2U9krXXjKMRyILxucuZS0YIYVdl6Y0CvjI/dhEA1U QP7w== X-Gm-Message-State: AOAM531bfOulFm9y4ga2VQICFbMPV167gr+YByGWK395ZLeZ6tOXdoi6 oU7C6mEwgCsX5LxdFOgVm9skolVpizyv5g== X-Google-Smtp-Source: ABdhPJyqT/M+4COWKabt6Advz3tbYLDSQzYNbQgPkTS0WJqLl1pVofR0VUEzZBJF60Zz0VyJFU4PeA== X-Received: by 2002:aca:4056:: with SMTP id n83mr13949599oia.47.1619453911514; Mon, 26 Apr 2021 09:18:31 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id d62sm3115859oia.37.2021.04.26.09.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:31 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 26/43] completion: bash: simplify config_variable_name Date: Mon, 26 Apr 2021 11:14:41 -0500 Message-Id: <20210426161458.49860-27-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 096aa7b6e9..14882297c6 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2580,7 +2580,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 @@ -2602,7 +2602,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.*.*) @@ -2636,7 +2636,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.*.*) @@ -2652,7 +2652,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 Mon Apr 26 16:14: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: 12224539 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 A610EC433B4 for ; Mon, 26 Apr 2021 16:18:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70AF761158 for ; Mon, 26 Apr 2021 16:18:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234382AbhDZQTg (ORCPT ); Mon, 26 Apr 2021 12:19:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234263AbhDZQTd (ORCPT ); Mon, 26 Apr 2021 12:19:33 -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 0E8F9C061574 for ; Mon, 26 Apr 2021 09:18:52 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id y14-20020a056830208eb02902a1c9fa4c64so16119269otq.9 for ; Mon, 26 Apr 2021 09:18:52 -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=IOJKPqOeFx/TQGntZS7ZLedzJIeaulaJ9v77KNbJ0xs=; b=W0EPiQft+O1OWgk3Wu/Gui9yxpp9ukgJqCIHLqMzBPURVf1M8tEz6rXE04eACNlyPs pIP6M4p9kkNDRbn23vc6yYH/UKnSQd00mMZxPwKW/jqApzROaPsV/8ODUBj04W7Hz/de PqxOVX3MO8b+IiCgEO+nHr7MqD3SxS5SqzwxgitpXaOudEOyLmpXiP9/rYXdaublcWzg 5S09oZk9gHquOSpSnUZSIyeF7ppTn2tOeEtVYD0iQwZoIaUiMG4uQjjmVu/sbAqabfyh r+VonSyC9LB9VdbjX2san2eDSiqFYy8Nli/u/OTQzEDMoVDPShQU2/3cL8beq+2+nz+n MA+g== 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=IOJKPqOeFx/TQGntZS7ZLedzJIeaulaJ9v77KNbJ0xs=; b=Hd8wJSUbtrp0A0tIROYFOtyyFxMzfhv0z78candIOCNCVnbNa2aLfcA4B8U7QEElVW evNUFIC9W7j2Z9pAae+pbEsqt1z8g+t59YId5IjoUvsrIHnt6lm6mAa4VJGeGk5k4jDQ PGD2H/R0K3d8xugOFKSF9vqz1Eo0jkmWpIkNG3JOSMYQMU1OpCXoenoMndwIz9kpMlAo im1VYa9M1gZAuJxedIOB6gNdgINKUXZYGNbUpBTJNnCwexiU6frZtmF+feFXQkvSseW0 uk70Te/a+PUgJwRBWQS3HPOUk9s+Lw6QfgXc4nHqHd3HfSKnlz06WwRX3tJtfVi/Ax7G /APQ== X-Gm-Message-State: AOAM5312/f4LRvoZr8aaIcppfQqCLNQjLqklFxNtWkG2LAH0/+BTV48S 3cz+GWFr8urO8NCanJ2adtQKvBXwD3lM/A== X-Google-Smtp-Source: ABdhPJzJIHTxUJwH8yj8EsrZ+8yDJa7mMdnizTiDUVNir9bizBcTF0hqTgaYRHI5njerEc1Fexno9Q== X-Received: by 2002:a05:6830:3151:: with SMTP id c17mr15651735ots.245.1619453931272; Mon, 26 Apr 2021 09:18:51 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id e30sm67208oow.11.2021.04.26.09.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:50 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 27/43] test: completion: add missing test Date: Mon, 26 Apr 2021 11:14:42 -0500 Message-Id: <20210426161458.49860-28-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 3528463047..bbea339a45 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2315,6 +2315,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 Mon Apr 26 16:14: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: 12224541 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 B78CBC433ED for ; Mon, 26 Apr 2021 16:19:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85E6960C3D for ; Mon, 26 Apr 2021 16:19:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234076AbhDZQTm (ORCPT ); Mon, 26 Apr 2021 12:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234263AbhDZQTl (ORCPT ); Mon, 26 Apr 2021 12:19:41 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3EDCC061574 for ; Mon, 26 Apr 2021 09:18:59 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id u80so23354705oia.0 for ; Mon, 26 Apr 2021 09:18:59 -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=syUABEO1C+p5G+myrsPvE9wf9xjIVx27sXBfRET2cSc=; b=R0G2vt9PmVyiGpZRxv8zpSkQPhjqV7Oc5F2nhbQAXmYKCo46gMMdTPb43FNSPQHlM7 zKdLp8SY60v/BliWYc28IRNMw8fzmh9u2Gp+pedI0fn0U60PfoEvwdQ6B9g/8TiMFnIm qII/3aAACNsdlCHtCUEmP5niutG6OafmlzWUAzntYGIBDcEMeKAjpfTOSomiwXj3UVeG ZUCPDWwgmqvJsmOnclt1puYKAOEIuR9oRSEHQo9NN9oWhn5mI7PqYlAZErKrL0y0FOuC ggqd6Ns093eNEn6G3YsoJkwo4ReG7vgNglH6e6JgMrElCAKXRidwYO490FlW6zFX648a Ghvg== 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=syUABEO1C+p5G+myrsPvE9wf9xjIVx27sXBfRET2cSc=; b=WnItCPLXnLBXwtUg27rg9oLS5Oz56Z500ZZtF6DSzWVpK9ESFD7rZSQIPf4yxAvJU4 J9j2SFzsGVC4L2w56xkW401WLqHIMhhUZmIjatMuSbT8j3UxOfzVU4p3X/RrR5naK1a5 7unqwvCLx1CCEuThpLYVAA6c1x9HN00p0g1lScQT4hTsGpooTTyCJceDS72DXsXtU6mD uHo7mTgO1Ggk0VGNIEZL8BmRMhNGItqQ/cUp62MBmn3EOEK08xpQnCsvBIttvx0eFtr2 8srVst5d9avvIHuWmofiA4KVI80KKBlCcaQw6x1UExYCYrZcPY6rV2symEbAbktGVczO N4aA== X-Gm-Message-State: AOAM533Ci7J23Rz/KX4XHxMqtgbUX3qt3vuCCJ4SJ10veCJTxM0f78hM q896uiaiFDNUGS/01wv+oTp3BgJs4D3NZQ== X-Google-Smtp-Source: ABdhPJzf1lQ3YCokMF4PDzRDkX4o5kwVysVvopeafz8zyZNCnvoy/j8jsH85M/ywQy6FtUVHlcJPzw== X-Received: by 2002:aca:bb0b:: with SMTP id l11mr13916971oif.146.1619453939122; Mon, 26 Apr 2021 09:18:59 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id v28sm76152ood.27.2021.04.26.09.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:18:58 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 28/43] completion: bash: improve __gitcomp description Date: Mon, 26 Apr 2021 11:14:43 -0500 Message-Id: <20210426161458.49860-29-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 14882297c6..b2a04a6b8c 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 Mon Apr 26 16:14: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: 12224543 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 AB16CC433B4 for ; Mon, 26 Apr 2021 16:19:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 592516115C for ; Mon, 26 Apr 2021 16:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234411AbhDZQTy (ORCPT ); Mon, 26 Apr 2021 12:19:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234263AbhDZQTx (ORCPT ); Mon, 26 Apr 2021 12:19:53 -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 529A7C061574 for ; Mon, 26 Apr 2021 09:19:12 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id z7so4740419oix.9 for ; Mon, 26 Apr 2021 09:19: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=fsU/sfVQdC5LbwT4bDtnySSwnTLILy3H1e4tFtPQ6Qw=; b=qSLx2+Gio4h+wiFgocghGfM9NZUZLdBWKSPCn3KKqhrTcSn1KSbEH8cN//sCoaM298 qCGAcXGRHI++sc3Y8GkZc/1dHvvfaplhe1BeDUSar8KoYZ5QmiqOwPRBVhMH7WnMfrme YDyvDX/1SbKYk75lJkp/kDLblrNSS1fOIbSiVqs+rwa64EES1yspBelOEUAiYlnmBgge TCs6WWha0w3YulKN1w0PiVwhmBSwveSus0duDuoRfmofmay7TTzy+LGfoXvEtPsraqUI 8xfhvJMNm3l9b2ecTR426adSGbR1Jm6eYFftxcNECpJV11lm6a6xuHAG5VMk6HSYKC+P uhvA== 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=fsU/sfVQdC5LbwT4bDtnySSwnTLILy3H1e4tFtPQ6Qw=; b=mhz8R1nPHF7lw147nbjeFkKuKcF/spvRUY+iQTPqNmWh3YzcKYNBnPa4APEF188jiL /2V0925oAbpkS0qUeGlLBQPquZFMeOzOolxAShjBbMzpyTHoci4OIBp4KU9Kuj68CEYp JNnui+oqPt7DnEnSQtv7KzDCCQoPC7q/LzjRgmvTegqFOCd3nmSsY5LtsXeSIl45kNAM muUZpyADC/5FR8OWPxObBGwNDqM3D1/muWidJVIc9MGzYER91gMiGGDDAZfqu84pnUGm iH5epGQnGhLIQQlmXb7FYFf9K0PFDIX5Mfa3Ai2zPlGmzIo0ko/u+VBpan6Y4yflj/KI B1MA== X-Gm-Message-State: AOAM530pZezWoTAsh6oSb8GiHD6/ngaO4wauK0GhTC9D4hILMrF0sHBZ SVfgKsnp7fi/OEQa7H4yElKF/IPRyuChvQ== X-Google-Smtp-Source: ABdhPJxItSRN9cQZwrK56sK48QUmHX4sEQQU5P0oRJ5VfmXxg/8QPYptCKb/6VHXFYxGzQOAjPFEXg== X-Received: by 2002:aca:db05:: with SMTP id s5mr13498246oig.134.1619453951056; Mon, 26 Apr 2021 09:19:11 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id q10sm62575ooo.34.2021.04.26.09.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:19:10 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 29/43] completion: add __gitcomp_opts Date: Mon, 26 Apr 2021 11:14:44 -0500 Message-Id: <20210426161458.49860-30-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 | 114 ++++++++++++++----------- contrib/completion/git-completion.zsh | 8 ++ t/t9902-completion.sh | 58 ++++++------- 3 files changed, 100 insertions(+), 80 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b2a04a6b8c..00fd782e57 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 @@ -1292,7 +1304,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 @@ -1548,7 +1560,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 @@ -1706,7 +1718,7 @@ _git_diff () return ;; --*) - __gitcomp "$__git_diff_difftool_options" + __gitcomp_opts "$__git_diff_difftool_options" return ;; esac @@ -2000,7 +2012,7 @@ _git_log () return ;; --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options @@ -2063,7 +2075,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" + __gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui" return ;; esac @@ -2211,7 +2223,7 @@ _git_range_diff () { case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --creation-factor= --no-dual-color $__git_diff_common_options " @@ -2228,11 +2240,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 @@ -2674,7 +2686,7 @@ __git_complete_config_variable_name () for (s in sections) print s "." } - ')" "" "$cur_" + ')" "" "$cur_" "" ;; esac } @@ -2852,7 +2864,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 @@ -2884,7 +2896,7 @@ _git_shortlog () case "$cur" in --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options --numbered --summary --email @@ -2922,7 +2934,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 @@ -2955,10 +2967,10 @@ _git_sparse_checkout () case "$subcommand,$cur" in init,--*) - __gitcomp "--cone" + __gitcomp_opts "--cone" ;; set,--*) - __gitcomp "--stdin" + __gitcomp_opts "--stdin" ;; *) ;; @@ -2976,7 +2988,7 @@ _git_stash () if [ -z "$subcommand" ]; then case "$cur" in --*) - __gitcomp "$save_opts" + __gitcomp_opts "$save_opts" ;; sa*) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then @@ -2992,22 +3004,22 @@ _git_stash () else case "$subcommand,$cur" in push,--*) - __gitcomp "$save_opts --message" + __gitcomp_opts "$save_opts --message" ;; save,--*) - __gitcomp "$save_opts" + __gitcomp_opts "$save_opts" ;; apply,--*|pop,--*) - __gitcomp "--index --quiet" + __gitcomp_opts "--index --quiet" ;; drop,--*) - __gitcomp "--quiet" + __gitcomp_opts "--quiet" ;; list,--*) - __gitcomp "--name-status --oneline --patch-with-stat" + __gitcomp_opts "--name-status --oneline --patch-with-stat" ;; show,--*) - __gitcomp "$__git_diff_common_options" + __gitcomp_opts "$__git_diff_common_options" ;; branch,--*) ;; @@ -3038,7 +3050,7 @@ _git_submodule () if [ -z "$subcommand" ]; then case "$cur" in --*) - __gitcomp "--quiet" + __gitcomp_opts "--quiet" ;; *) __gitcomp "$subcommands" @@ -3049,29 +3061,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" ;; *) ;; @@ -3112,64 +3124,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" ;; *) ;; @@ -3388,7 +3400,7 @@ __git_main () ;; esac case "$cur" in - --*) __gitcomp " + --*) __gitcomp_opts " --paginate --no-pager --git-dir= @@ -3439,7 +3451,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 0ef15ff643..d5ec8a1417 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -53,6 +53,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 bbea339a45..205083184a 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 Mon Apr 26 16:14: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: 12224545 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 2BBABC433B4 for ; Mon, 26 Apr 2021 16:19:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F19DF6109E for ; Mon, 26 Apr 2021 16:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234397AbhDZQUF (ORCPT ); Mon, 26 Apr 2021 12:20:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbhDZQUF (ORCPT ); Mon, 26 Apr 2021 12:20:05 -0400 Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A23ECC061574 for ; Mon, 26 Apr 2021 09:19:23 -0700 (PDT) Received: by mail-oo1-xc2b.google.com with SMTP id g9-20020a4ad3090000b02901ec6daba49aso5587308oos.6 for ; Mon, 26 Apr 2021 09:19: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=RAXdm3HDE373LbfGMjVwSevhnkkSYJ9glzm4V2KycEU=; b=I53KHORbTIeaihyXbatrEIbJBf0r1eX3YQP3SFTbMnTxRGlHJKa3jcMIUKgcsk5Hin FT66TX+bB2P88+vwhwmCyO4FwOZSuwa/5bC/tFkS0X7aZr4UMJz6sIyWKEJGnOS/EqlA OQz7dUNL/9wxpPMT7+dOOHkAk7KP8ElnnJr+zBbDmwnUpvJ+IvhfcYzR4+cBdiwP0F/D QjmFwyf1xjTx0W3giGJRUlSBl7IDqN+HNnSsnKOLXFC5fTLuNIvBwWU23KZlT8M+X9RX LoyBo5NE1JfGp6Kp9HZQqa+W/wOXz+Lxx7Wnyer8BGwX2NPc6sRONbdyUD+/ZzxZjhhr MdRA== 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=RAXdm3HDE373LbfGMjVwSevhnkkSYJ9glzm4V2KycEU=; b=G+sDQ4IlTNuSjFyqKl8r17ulmSZB6reNkr6i3FsvM9E2PlvTWUpumM8yR8ST47zY8Q j8lmCJlPU2kQxkL1AjLXI2dmkKsOuZLp96xsJ3jq8+K9T1U3QBSAWCTQ1rmy7QAfaA0F xOwQIS4XLsJfX8YUYYx2YPIqNskQemWHT3foJ5bbb8Wk8fbr0aDoa+L8F61rriSRq8BS uM6PJr3uDZOwtMgIDTQp+eTEG4tGN4ekSBgaGwsJgUS5IipcI+DRvu1fj+eLZbFLy1la yiE/vStHwSErFb4PAlvn5rCXBSX3+IdJvZwXATIRBSSGioL/rCH6o51B9rAS22mERQUF DfUA== X-Gm-Message-State: AOAM5300UcTViaL0zpwrUF3ovlTruw+ufkdMzHFb3xdPd22ojE61cl1I B3kDmPXBfl6rLH5aURZgtTMLpgsxOYz5ww== X-Google-Smtp-Source: ABdhPJxyB5FKFRizVgTBdPHuhMosqzdrJIUt7RYrPycAsvawjXvcvTuUjI8Bj9tOcrOO6KhgRhkGWw== X-Received: by 2002:a4a:9f45:: with SMTP id d5mr14043258ool.91.1619453962860; Mon, 26 Apr 2021 09:19:22 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id y6sm3696157otk.42.2021.04.26.09.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:19:22 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 30/43] completion: bash: cleanup __gitcomp* invocations Date: Mon, 26 Apr 2021 11:14:45 -0500 Message-Id: <20210426161458.49860-31-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 00fd782e57..44cf70daa4 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1364,7 +1364,7 @@ _git_archive () { case "$cur" in --format=*) - __gitcomp "$(git archive --list)" "" "${cur##--format=}" + __gitcomp_nl "$(git archive --list)" "" "${cur##--format=}" return ;; --remote=*) @@ -1777,9 +1777,7 @@ _git_format_patch () { case "$cur" in --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --base=*|--interdiff=*|--range-diff=*) @@ -2285,7 +2283,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 @@ -2309,9 +2307,7 @@ _git_send_email () return ;; --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --to=*|--cc=*|--bcc=*|--from=*) @@ -2613,7 +2609,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.*.*) @@ -2663,7 +2659,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.*.*) @@ -2678,7 +2674,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 } @@ -2780,7 +2776,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 @@ -3422,7 +3418,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 Mon Apr 26 16:14: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: 12224547 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 3BFECC43460 for ; Mon, 26 Apr 2021 16:19:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC38F61158 for ; Mon, 26 Apr 2021 16:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234485AbhDZQUN (ORCPT ); Mon, 26 Apr 2021 12:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234156AbhDZQUN (ORCPT ); Mon, 26 Apr 2021 12:20:13 -0400 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B03C2C061574 for ; Mon, 26 Apr 2021 09:19:31 -0700 (PDT) Received: by mail-oo1-xc35.google.com with SMTP id w6-20020a4a9d060000b02901f9175244e7so289759ooj.9 for ; Mon, 26 Apr 2021 09:19:31 -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=36Ps/c6tYITbKpd1B9O85sbHJPq0DBcBeFZfKDNIsJo=; b=WlBeUoKPmgspMVv9dTfQlQgMem42pOEvZPFkb5GhjebNWeE/aXRsuJah6iXYtqYM7q 2Fa1IYC+BFeluYSfSpdS/1JKg1/EL/XHsaFUFeowgQC+G0dzq2wyqnwpxkGkvlI/BnlT thV4otQGEjxwHy3chGxrM00BeYS+10iH3KzBGOnRFQLKOTOT4Ierm7UZV5vBWzamhOwV QAOr4GIExMWpgI1zWiHfdImElDYkpcbeARrpR5/0/rC9U2VRIjAWdkriiN2RoqSkRShg F5mJK5hlbW/zdxbT8pzFy6ezwjhDXVP6Zj/tqLyabdbudsAu6/IMYMJ8I3l9+WPYxSzP cyVw== 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=36Ps/c6tYITbKpd1B9O85sbHJPq0DBcBeFZfKDNIsJo=; b=AaqGKF791ZdB3po6sJUxQgYeF3IrLyoalW+Ba1GpmS0ATqZjQ7rjvuriXd1hcKDu28 QC0QQvOnOqZAuVSdBTysSFXC9Acr/t/JnCRn/X2XMMZB2Qp9iMF1X1qkohbD55ldm9WK vrTurD/9p/DnsqudITfmCxOFDqtHsXLe7eKPXugyu3AMKDnJyhoxt5q65m+MhfIO0wzW zrZOwMFhKt/tl6IN5e67dAC2hECnPzJyj/XuKzcI3HwTFyhooWIbBnnmxBVGwJHcL4oV QUcR11KcANaKjOl8vEYySA2oR//j4E+lfGXoiDEqNwaepuvtMnVywCgYfJW/aSjFGmPo FXbg== X-Gm-Message-State: AOAM533bSj9+B3TgjSPfzwhtBso7AQvdT8sgXjroRm+Vgt8b0wViAgo2 cOTZsnfMvLS0VjfWBJ7wkUD+3Dcpws6TaA== X-Google-Smtp-Source: ABdhPJxAs7U8fRusCk2/QS+ZNjl/7DYdjNNwez4izTuxKI5PR/8uQOHENTNlY+RS2/aqHltqqRgAcg== X-Received: by 2002:a4a:8e18:: with SMTP id q24mr14191949ook.66.1619453970676; Mon, 26 Apr 2021 09:19:30 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id o25sm619744oie.45.2021.04.26.09.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:19:30 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 31/43] completion: bash: shuffle __gitcomp functions Date: Mon, 26 Apr 2021 11:14:46 -0500 Message-Id: <20210426161458.49860-32-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 44cf70daa4..d760434c0c 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 Mon Apr 26 16:14: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: 12224549 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 5B264C433ED for ; Mon, 26 Apr 2021 16:19:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E1266109E for ; Mon, 26 Apr 2021 16:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234499AbhDZQUS (ORCPT ); Mon, 26 Apr 2021 12:20:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234156AbhDZQUR (ORCPT ); Mon, 26 Apr 2021 12:20:17 -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 E161EC061574 for ; Mon, 26 Apr 2021 09:19:35 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id c8-20020a9d78480000b0290289e9d1b7bcso38541160otm.4 for ; Mon, 26 Apr 2021 09:19: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=/EHczxNq6fJMk/YF46UPA4tVUWxxo6EtvVEuagpeZTc=; b=AZHDxzTiwlqeXvDW5R9tB32WHr6JnfkdCzjohZXTg1kgnMvXfFeKw7DoVS6b9imjbb ztQNbm6H4fknG/nhTPR8ZwuJqFDaveG3q6g6iZU8FFEdYLaSo47L9WW7bGNxLgZfS0p/ O2k0EpByZP24sOL1QmJtJnMw4uOXPoswEE85ZB7ZsWa763NSJu4daGnxEkITaS047fna cPvxHKNbCvp0FA5OzubscLbboiE3VocGH7KUgJ/9YcZ1mO3uroANtGUU5t47tpyOFQTk A89g9EVHpMdsMHHI1IYGM+0cF3sZp8eAPob07ySjKiLiEfuVeqQpSLKuildb0c8FPKC4 yDJg== 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=/EHczxNq6fJMk/YF46UPA4tVUWxxo6EtvVEuagpeZTc=; b=bgpXUzmC17Y7revcdYgY11ZzXnUh3wkXZtewWx+1/rZkXUp77lpQB1J7pk1Mwlz3fg Nft1gy9BZ4f5dn/WuMNIGRnsknkebCEBfnDEOqbOdJhAzw/Wv5hg2cFw+/wdSz3d3Ga0 v/cOrz0pUczqpqb0j+yPoti14pGuqbnVmDq61aZ+gKV+ZRvHnpOs5MI1YiGn5GIAOTBS nnZQwMYHKtdPiyfOTv+4wKQwovtoGNkZtaXqrzUr9v/QUjY4ttubF0RKcb7dCBKAeV5Y 5HIgjgYKEFDercDui5T3qOHKEsrIoFDMra0FFoihXhUceS2rfBIh59EkshShPhv461H9 bWTA== X-Gm-Message-State: AOAM532WKR+eRedBZ0D31m/ANFPuQknWGd92PdxyjKAS1ejHDXztELJx qvygCZdaFot28iTk9zUsB3wghj/sKtwW6w== X-Google-Smtp-Source: ABdhPJxTJWjZV8/6br5lxQF3LjuboO9Pt6GWQy4chvkljtBXYNocGXo0MrwzBHkjLhQa6LpkhfqZnA== X-Received: by 2002:a9d:4e9a:: with SMTP id v26mr5507277otk.74.1619453975180; Mon, 26 Apr 2021 09:19:35 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id x2sm73551ooe.13.2021.04.26.09.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:19:34 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 32/43] completion: zsh: simplify __gitcomp_direct Date: Mon, 26 Apr 2021 11:14:47 -0500 Message-Id: <20210426161458.49860-33-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 d5ec8a1417..6afcf1810b 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -89,9 +89,7 @@ __gitcomp_opts () __gitcomp_direct () { - emulate -L zsh - - compadd -Q -S '' -- ${(f)1} && _ret=0 + __gitcomp_nl "$1" "" "" "" } __gitcomp_nl () From patchwork Mon Apr 26 16:14: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: 12224551 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 B2470C43460 for ; Mon, 26 Apr 2021 16:19:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8511F6105A for ; Mon, 26 Apr 2021 16:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234534AbhDZQUc (ORCPT ); Mon, 26 Apr 2021 12:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234524AbhDZQUa (ORCPT ); Mon, 26 Apr 2021 12:20:30 -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 2CBA8C061574 for ; Mon, 26 Apr 2021 09:19:49 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 35-20020a9d05260000b029029c82502d7bso21188363otw.2 for ; Mon, 26 Apr 2021 09:19:49 -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=L2fUlfveS0C8CnjRwhf7QKxanU9/P6mi3DIHkBJAnBc=; b=ius+6UzW8MHdT1xrlG0qpwwNGSgzg2CHGuopc39ATwELPmjGlC4Ar7u0U0KqNkzzh6 Plkhb3Qfvc2OTBQ7+radF/BiQxBtoh7Q5PqHkCQhU5fFdsug8sg59swjpjg/gTiFE/2y wtQqjkfnljCAZPnCpkL6ddnjZrWVWtb6o0jWPPZSBG8xvRfDAMvaVslOJvjZ9XmfNWow Qa7nhls0u5VhqgztG1ZoZfDtZgFiCsMYx+opNvnjVWYhNxp7scLoEtxeOX5d3Fu7+Ptm RHTikjr2J0g2ah2I21sC9rPIiET5yEgWDKTuoErzhZAW4B2IdhccEEPSXh3YwavXCqud g2eQ== 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=L2fUlfveS0C8CnjRwhf7QKxanU9/P6mi3DIHkBJAnBc=; b=hxknpdxki7reYR6jDg+NbyMGKsK1bevoj3iIa9lTQgGrOD2437CQRBz6WwUK+zOg7F I9rhW74NRTyRrdHUdh/mlgSmOGKb7TJAWbKiT6MfuStY2MjYzq4p20k6yOtHjNANvzpV mrZIE9JJP5Dc5i4V0klllACHQX8QmQsT5IwF7SJkVT+z7TUA/X7W3toWfMnoxUqS7tLa YpZULMsfBu2OH7BMvW3FiVS1UPLLh+cnpkV4MgUDvzBGp7pkHM3aUVJF84+x+U5CqgGS fxCJDHUP0xyOxzM7N3OR5sTyQUskIgdoot5HS2k4FZY5FXocNShB4fom2cCN3CTn1g75 Qyzw== X-Gm-Message-State: AOAM530SJCqnJOUG30GA6Oh7d3+/+CgGvgW2iOqpodc4sQfy7zTdShCW 8KY67LzrYg8K+hJboZ4+NqcLOR45DKAu/w== X-Google-Smtp-Source: ABdhPJzBmSaoJ19IoMjaCKj79lMk2XUC1ywPRn3WBmWnZNyBofgnMOKlRHOOTnEI7Xf7J0R6Y84Rjg== X-Received: by 2002:a05:6830:1507:: with SMTP id k7mr3615757otp.106.1619453986965; Mon, 26 Apr 2021 09:19:46 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id l11sm67760ooq.44.2021.04.26.09.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:19:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 33/43] completion: zsh: shuffle __gitcomp* functions Date: Mon, 26 Apr 2021 11:14:48 -0500 Message-Id: <20210426161458.49860-34-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 6afcf1810b..3665167b3f 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -87,11 +87,6 @@ __gitcomp_opts () compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 } -__gitcomp_direct () -{ - __gitcomp_nl "$1" "" "" "" -} - __gitcomp_nl () { emulate -L zsh @@ -106,6 +101,11 @@ __gitcomp_file () compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } +__gitcomp_direct () +{ + __gitcomp_nl "$1" "" "" "" +} + __gitcomp_file_direct () { __gitcomp_file "$1" "" From patchwork Mon Apr 26 16:14: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: 12224553 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 DD346C433B4 for ; Mon, 26 Apr 2021 16:19:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADDA76115C for ; Mon, 26 Apr 2021 16:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234549AbhDZQUg (ORCPT ); Mon, 26 Apr 2021 12:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234546AbhDZQUe (ORCPT ); Mon, 26 Apr 2021 12:20:34 -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 6035DC061574 for ; Mon, 26 Apr 2021 09:19:52 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id x54-20020a05683040b6b02902a527443e2fso1519561ott.1 for ; Mon, 26 Apr 2021 09:19:52 -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=v1Carr5nFWwqLMAQMrCfsgkPiY7L1Ez7UH1WoS5YxbM=; b=g6hAzbg1lTfW19W8dKvzG4g6+f6njsUFf9Bsmd2yD1r3EsI1v75lhaXUltIZMwpW0R 3/WtSdHi/j1oZg8kf6vLdt+wzhdETkNeFnAZPWaPY73/KzvylCg7HfwWT9X6EPG67Z+/ 1WAVmpMugEjeeUZf9VfyRxtcy7gIFgHaWhO6rqNRYtoG25AIcQapIo7phpGTBLx0YGON Im0kXai6CSulz1r8vIfgRqYEpgbF5Iuns9fh6jE2EIyI+Qwux23XVWxiMUhgvOMmmaTM DFpW8hl+/3vV8yVE/kH0+4zqbzh2mwV/gEI/DsVq0BQSQlxd05EMiBmYLm+Cngc0oKv9 FRbA== 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=v1Carr5nFWwqLMAQMrCfsgkPiY7L1Ez7UH1WoS5YxbM=; b=t5jjLTV6TMEfAPwRYfkJR0/6CgSSu/HQ+wsn6VCTPbBxckdydw2zdi3FeN79MP4qdu a+iNQB3K0/QBo/vu9JfpMAYPq5EX/RwQLsrZbiH6JOZj1F7TczbumrXS7lnMR6AZPv5x t1deSB+puaeCK117aPvMf/biEXS45W05YLlx/3YJBQnQ5xfuaV0FxkkJCzncj5m2UMAY LKj2a0WoyqsIbnkSrow68Wj/7e7wU2pMRIK3RXnMSJ9H+h+4JDLtlc8cT6GWrmuNeeQ6 1uzxsEsb3xDIwZJ+3F8LAk6/cfGRV3vSvz4E24Fg3Rr+Es94hBZA6llDBLo8vDPEgOCj sbzw== X-Gm-Message-State: AOAM530GzHPJNuXiR6e3SaoxGn14lmlKO+wzVMmixGiOfuX8nElndHuh bfQS0p4WixrpNsw6glYqcy8Al2Un0QYpSQ== X-Google-Smtp-Source: ABdhPJw5hgJEzvUWr49d7PAveMAjkUnF78EdrUAuVcxjzgukJ1YxlZKJxkm47y6QBpvO0/mcRRJPGQ== X-Received: by 2002:a05:6830:1543:: with SMTP id l3mr4115754otp.31.1619453991617; Mon, 26 Apr 2021 09:19:51 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id x129sm927934oix.9.2021.04.26.09.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:19:51 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 34/43] completion: zsh: fix direct quoting Date: Mon, 26 Apr 2021 11:14:49 -0500 Message-Id: <20210426161458.49860-35-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 3665167b3f..2faf435087 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -54,7 +54,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 () @@ -84,14 +84,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 Mon Apr 26 16:14: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: 12224555 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 D765FC433B4 for ; Mon, 26 Apr 2021 16:20:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9543160C3D for ; Mon, 26 Apr 2021 16:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234383AbhDZQUs (ORCPT ); Mon, 26 Apr 2021 12:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233919AbhDZQUm (ORCPT ); Mon, 26 Apr 2021 12:20:42 -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 443BEC061574 for ; Mon, 26 Apr 2021 09:20:00 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id w6-20020a4a9d060000b02901f9175244e7so290056ooj.9 for ; Mon, 26 Apr 2021 09:20: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=2rKM0jsvPMc46w9HiUZvdwt6cYPr2zXcWxKnnOjtcKc=; b=vUsP5YuwJha5MmWG+WTcf4dvlEs1emtWk43/DDC3b1AIOOdoBS9oMCUWGd4QGW6OKC uCN1pLh4UQbvolgvWYqGp+OqETgyiYKUrCc/ISEqQ/7i4voWXOaHiaBDR4oj3U+3I5fk CZMI58quC0uksklu6Ap2eT7nNQUXiz5lpXq/Pq4e2jYcYdWtxn79/ZTsM3+2E+gDO8h/ E7dRp2lYEmn5B3d8NgoYmLlPWG72u7oqirk3CypGjs9t7J+Gh65S+xXVQ6BT4fDcU/cQ 0C02hepP5QhSDDTPjiTNffq4xaeI/tiGQ2xC6XIR99SBI1EouF6dM9OqIq9fAati2s3k AvZA== 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=2rKM0jsvPMc46w9HiUZvdwt6cYPr2zXcWxKnnOjtcKc=; b=GhMYC56RGpwFA3rMhGNVyehaLfWLjNQ73Pi/bK/Bi62ZClazV68LPVe9XeZ6TNwvpe foxLt5zUBbV7tcEPUpJUFN5wkm284oOnexTOuSBYGGnmIS5/u2IyppMc8BDCZGUGlV8+ NV1iEELbz1PBoOZWBrgWWs9JvKdMdmmXp1xuHO4PsezfoH2wTSO8V+uNBPTvrV9XKQFz iTBz/NOu3YVJ81dlzlkz09l++vWs6otAawS7BrzORxavYRROXzErKa2zL+aXDEA0jE2t ZNOricwEfB4bN22AhpFnGeYufkAmMCTkJmKwRKdnv2JaSiesH+Isx0J6N+HwaoF675AI KeaA== X-Gm-Message-State: AOAM531VRoEY6GLhQw+lx/0opHKPvlpmR5mbFB3phf3wV/m/9lvYLOVo Vom0j5ELiK/uDezX0mg0+Wy0GuDrAvx5fQ== X-Google-Smtp-Source: ABdhPJzIuOs/ko/eO6JljSvF/RINVWcilg+Z44irHzjXG13iri7BsgNKjWgUQXjr1ytuVA5GzYdBtw== X-Received: by 2002:a4a:dc84:: with SMTP id g4mr14147945oou.24.1619453996535; Mon, 26 Apr 2021 09:19:56 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id m129sm3130748oif.34.2021.04.26.09.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:19:56 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 35/43] completion: zsh: add elements individually in __gitcomp_opts Date: Mon, 26 Apr 2021 11:14:50 -0500 Message-Id: <20210426161458.49860-36-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 2faf435087..82a4d6f470 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -66,11 +66,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 @@ -82,9 +81,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 Mon Apr 26 16:14: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: 12224557 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 30A70C433ED for ; Mon, 26 Apr 2021 16:20:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECEAD61166 for ; Mon, 26 Apr 2021 16:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234136AbhDZQVA (ORCPT ); Mon, 26 Apr 2021 12:21:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234546AbhDZQUo (ORCPT ); Mon, 26 Apr 2021 12:20:44 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10A04C061574 for ; Mon, 26 Apr 2021 09:20:02 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id d25so19445970oij.5 for ; Mon, 26 Apr 2021 09:20:02 -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=658dBV+rQOBB7RM26X6T1MZ7Pdt89BJgSwB8/raGX7Y=; b=rceG2/NGzuRG8gSc5yySSd0Nqf86U3oOqxxrDbFl0y3ljklauXU+5oQRBRU6Zn+VVQ 0682mMo08X3qfqtQXerK/J0qk9RZQ0DjAD1bx6+MjT+gjeu2N+A7aLXTpRMFP1wdUU1D O9k+XZ5K4MJRgVNPWH9aJgQ1W0s8xm7XLONlxOwXE/H2+rkmAPVoRvbbAkDl88jTH/X3 LhmKxghGDSH2aZRc9oQPLTFDiMIiF3b8yX507cX5q2Y83YSX/YFBPvraNdm1Oxp/xKPr pMHubIOsAaKF/rXzk14reXDiQLakigHOPfxfL4aM8NlWsUEpAIg+h36X0uxTIkFcAxzM 8Jow== 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=658dBV+rQOBB7RM26X6T1MZ7Pdt89BJgSwB8/raGX7Y=; b=lE5mYp4nAwak1oZQWpHmL+QYz5vZpHV6cZFFmSWQTA1syW5jltp006zn4JNu0SMGz6 OL71gjJvm23smItqP1seY0QbM3mdWnF1NOqC5JLWMMTskpnfveR4F9R6OPV/k7lFd9gW AodQjYbN1MW95jt/JR4yHv/KWIX98y5UtANd7cYHOqI+8h6x/rux6c+W1kaF74ZLV3fd t1AtbuoCMzeZHYaf8NO7EPxcSlPZEFSXFBecTWKrIbGbbm44Tn5C9VEJPiWAbfOUtvBB PAFVbsBPthAbKbncqENHf0mio6FiE3sc4YZU8iP4XG+M+v7LdiO5KZmcu4wwezXcqe2a 79Iw== X-Gm-Message-State: AOAM530xdY4KY7y0QAalZyGH8Xn0XOrfLrV5NKc4BA6ObCVjtgTAnRxI +Qb+UDZ+M0BCkoa6ZG55HyPB2fJyAmgw/w== X-Google-Smtp-Source: ABdhPJxeY/gltBSDbEcYbbATR9sR4RM4f26LPpWouhYThfm2BpI8O4ct+bw2roWzl4xnGOq1y2ZHWA== X-Received: by 2002:aca:f553:: with SMTP id t80mr13726692oih.149.1619454001264; Mon, 26 Apr 2021 09:20:01 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id f17sm3606617otf.11.2021.04.26.09.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:20:00 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 36/43] completion: zsh: add __gitcompadd helper Date: Mon, 26 Apr 2021 11:14:51 -0500 Message-Id: <20210426161458.49860-37-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 82a4d6f470..4e9699f542 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -49,12 +49,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 () @@ -69,7 +73,7 @@ __gitcomp_opts () for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - compadd -S " " -- "--no-..." && _ret=0 + __gitcompadd "--no-..." break fi @@ -81,7 +85,7 @@ __gitcomp_opts () else sfx="$4" fi - compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0 + __gitcompadd "$c" "${2-}" "$sfx" done } From patchwork Mon Apr 26 16:14: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: 12224559 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 0D454C433B4 for ; Mon, 26 Apr 2021 16:20:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C67036115C for ; Mon, 26 Apr 2021 16:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234553AbhDZQVF (ORCPT ); Mon, 26 Apr 2021 12:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234566AbhDZQUx (ORCPT ); Mon, 26 Apr 2021 12:20:53 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9DF2C061763 for ; Mon, 26 Apr 2021 09:20:09 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id m13so56924157oiw.13 for ; Mon, 26 Apr 2021 09:20: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=rzp4KIn25C6/1vn0IjwPISUvQBAaHVB5nSknZ59c4wg=; b=uke9d3IO+Gnib+/u+HNOVrKWT8qktRZLAbE3dsiFCIIy1C0f2KLZbyqBgpRPp/xR+Y csYfdagTo3JAsKN4dT0+L9Jkg1mxO7kz8luPw/3HHKOdQ9mPcffkPs4Jy7+6OQhCEfTb FMxOhtovk4RtHGykHsyZyHda39jKXx+HRSm0nX/q7cu+oXmHal/PEZJKkVXYBfDj031n JIDfAlm1tPsxKxekjQsUJSAv4w0FXYxmXVSIvtx8RcI5SY9b9majIIyqxUmxcUaToq2Y x81nqFU2gpz4kFZv3tzoxuGlNEv+SMsqNPFGGZjfuk+XrTgRiq0qqmbx7jJ4UqJ35JVl 3hZQ== 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=rzp4KIn25C6/1vn0IjwPISUvQBAaHVB5nSknZ59c4wg=; b=RQs560YI7GAj7EgKPzrSntdex5R+RT+NvQd6Y0TsS2s/P2Naw+ySSj3R6Rq0aIwro1 yVsnmyw3+wuJVBWYpkX+pM+jkCqFgqr8M3RTEzbrp0UtNnM11D4sR3jYT6ciIlKoOaiF QdTY7e5DmjVtsy8IKv1BPPRglUDG+rsrKgnreGdj04apKq1C1OSCTL168ONXnHa5+eqx T774VuvrEEes97Hy+pf9DOuBfnVBAnfQLqp9PGZSaxwm0dD5R1oI5zUd8dypFm9q/RMs 2f0rcGt4yb7fP9Ua1RXNa4SdYbt+HMUOLI2c6d7Ux6PMW4LmLjPxPXDpD+NSUql13PBT ij/g== X-Gm-Message-State: AOAM5329vam8e6RjmDXEeJ9/bDrUbON9PAFdj2uYrdD+HlbiaqHWa842 OJS+y2nf2se443ltW2Ua6lPkGH7Ar4BULw== X-Google-Smtp-Source: ABdhPJwxoBv+4XGNryM/lqUVCqd7ZphPY/7mV6HZ9bAsbx09HTYZjqNta59mOQ4es3EXDS30zBzHUw== X-Received: by 2002:a05:6808:a8c:: with SMTP id q12mr13440342oij.112.1619454009100; Mon, 26 Apr 2021 09:20:09 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id j11sm66347ooo.45.2021.04.26.09.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:20:08 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 37/43] completion: zsh: add correct removable suffix Date: Mon, 26 Apr 2021 11:14:52 -0500 Message-Id: <20210426161458.49860-38-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 4e9699f542..43b7c1b210 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -51,7 +51,7 @@ functions[complete]="$old_complete" __gitcompadd () { - compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0 + compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0 } __gitcomp () @@ -79,7 +79,8 @@ __gitcomp_opts () if [[ -z "${4+set}" ]]; then case $c in - *=|*.) sfx="" ;; + *=) c="${c%=}"; sfx="=" ;; + *.) sfx="" ;; *) sfx=" " ;; esac else From patchwork Mon Apr 26 16:14: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: 12224561 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,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 CE465C433ED for ; Mon, 26 Apr 2021 16:20:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DBB96115C for ; Mon, 26 Apr 2021 16:20:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234355AbhDZQV3 (ORCPT ); Mon, 26 Apr 2021 12:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233919AbhDZQV1 (ORCPT ); Mon, 26 Apr 2021 12:21:27 -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 5F894C061574 for ; Mon, 26 Apr 2021 09:20:46 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id d3-20020a9d29030000b029027e8019067fso50721843otb.13 for ; Mon, 26 Apr 2021 09:20:46 -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=R/TvVZKpQvdPHiHieOqBXvy/cQQ9HTuFFVCq3/qawCI=; b=ZBImQt+P0/UyMZA20R37UkljdxdaqX4SMxI1Sy+Z2jRTNUtOo595VJBcmBAO0zuh6t oKLcUipGPzRhQ6ieC/fLJ4be0VYrx+Q4kGKbiXxRqWY/ru9F9TF4jqZ5QiLq1axDg5bW jqZboaPHMSSlJknTZ3gFmpn9YPPGZVMNUCe26Vz5n7tnnNy0I+Hposg5B5ZHZ0lmV9si 63nxCiItrspJZ7SB6gHchH/QRXiAWIHG6LWT6CZLTG7hnTHJDt72+AddGHNeIzxMbxTW SEylFB2NSH3aqADB0qWI9ktRGWB/o6FxrDjZbH2Oa4OYM6Ja68vpvFkpBqAZ+1mOHqi3 W69g== 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=R/TvVZKpQvdPHiHieOqBXvy/cQQ9HTuFFVCq3/qawCI=; b=dBDV7IoWBgRxPClSa+d0njBj/hBjytx4T4vRcJ2/AVIFvAS65fchUTvTrdzLfrf0uF 9pfJTxMcJ5MqMPBpag3iTCN3fau3fU22hNhXlpkRfaVhpJIG4tRtsSbXYTiXr6yWrOA8 wh3cvDJJ5iizu7iVGUCY/dxTvO1lf3CsYLclauoqbfPiihWbmUXAIvoI7rSs5z9PHCLz GbmuXcAThxO6QpYYElnvUisaBEBr9X2vT1uwiO09rmjBqp51YEJ5nigNeWYsWMpyM5I2 a3u/k+rNh07dDebOrW75DWfW7aW9NbGVi/LRQ5mu3EEZfwroXnowNZ11VFtVx/ge2Y66 PumA== X-Gm-Message-State: AOAM531ghM9VoaqWTA7jvHSMsBjFplF4Xr+LEXAktRTQTUIDidLGHZ1r 7RDeiO1xgX9adDXF21REyFBWP9jA3KdQrQ== X-Google-Smtp-Source: ABdhPJyJb6LOG8yB2PWkag81ye+mQXyJuosMFA7qfwIXuDkiKtAPw3RpYY04YhkK1pfeoqC5QqUnSg== X-Received: by 2002:a9d:342:: with SMTP id 60mr15406277otv.295.1619454045567; Mon, 26 Apr 2021 09:20:45 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id j8sm3702895otj.49.2021.04.26.09.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:20:45 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 38/43] completion: bash: simplify _get_comp_words_by_ref() Date: Mon, 26 Apr 2021 11:14:53 -0500 Message-Id: <20210426161458.49860-39-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 d760434c0c..cbea35441c 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 205083184a..dfa2cb3b21 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 Mon Apr 26 16:14: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: 12224563 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,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 D2630C433B4 for ; Mon, 26 Apr 2021 16:20:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A68E61164 for ; Mon, 26 Apr 2021 16:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234523AbhDZQVe (ORCPT ); Mon, 26 Apr 2021 12:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233919AbhDZQVd (ORCPT ); Mon, 26 Apr 2021 12:21:33 -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 E981DC061574 for ; Mon, 26 Apr 2021 09:20:51 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id k25so56978270oic.4 for ; Mon, 26 Apr 2021 09:20:51 -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=O7RW+8hJP0Nay3XXmOTYHw106DOqFYPtV5o2FLwxBgE=; b=OVXEGH7dtBucvMccIrxXKudSgTKefwLkVoqXI/Lw/f4c3HhMq6we5rUTT8iPE85Zzt /l4W1FkpNmIDJCePC5p5pVwrACmKWxh+0urlqnYZV34IGeoUy8BmN9s0v+F/b9iF6x6y 1cwcCUFknwCra/6F/PTaruDVJFIALdV9JDQKBjpXsKqSs4GB4IryoQw/f3Y46OVPduS8 LS6owkcZ3mwisbVIi6t7TMeipVjImFq9nZnsJdI6dSXCml6U209t34hbMKWg6PttjVbb Xf0qZOTtAWZTb+GPxPThgsuFUIFVFAUSZ8kDg/stA2F7kAdWzXjARVO8ekHRSeyZdxu8 l/rg== 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=O7RW+8hJP0Nay3XXmOTYHw106DOqFYPtV5o2FLwxBgE=; b=oCwwA3coSSsodqycM4iP5v+f8wZY1AIm0rydUtf08dO/HwCrkL3sSb+97JQ6payOf3 6+muZaQIKJ11CsYx+geUxfV0EcnNPB1cSiQxQtX/MWB9W0rf5/bgQ7++5m6VeYQUv6KJ 7A8tShHZG40OG1AeJPzZEincm23+Fd4LSw8Eg2eAtKEcjiQKMjJctUJ4u2W8fuSr508o ufdiQIA6JNoIFQjKkuWyDzVyEnmPqg17xRcncCcUnzqPhE5PKmV8HBg7t5Oe7PA6tQKX j0nPtAhEfZIdNxMtF2GzsIda9yc18BE3+zbkLTe9g4cmwdo7PvJg5kHqawOPvCCupLTd ILIA== X-Gm-Message-State: AOAM533SzIcQmMXXuByo/BdPQ0wOuo2tn2ZoppUZVwbn9XVbwjViVQbc qgRA24LMGngs0KkZUpJCA1LYwv+rLdIf+g== X-Google-Smtp-Source: ABdhPJxllk45qSiaEiyKi9BzZnc4W1/H31dgYgQ3xcpaKZI8zkqg8QNoyWTFhb53tob5esjPr1lb4Q== X-Received: by 2002:a05:6808:699:: with SMTP id k25mr13638527oig.101.1619454051060; Mon, 26 Apr 2021 09:20:51 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id 10sm3088665oiq.48.2021.04.26.09.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:20:50 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 39/43] completion: bash: refactor _get_comp_words_by_ref() Date: Mon, 26 Apr 2021 11:14:54 -0500 Message-Id: <20210426161458.49860-40-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 cbea35441c..05b6762210 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 Mon Apr 26 16:14: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: 12224565 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,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 81356C43460 for ; Mon, 26 Apr 2021 16:21:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44D7161158 for ; Mon, 26 Apr 2021 16:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234546AbhDZQVi (ORCPT ); Mon, 26 Apr 2021 12:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234279AbhDZQVi (ORCPT ); Mon, 26 Apr 2021 12:21:38 -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 6DA0DC061574 for ; Mon, 26 Apr 2021 09:20:56 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id g4-20020a9d6b040000b029029debbbb3ecso19643897otp.7 for ; Mon, 26 Apr 2021 09:20:56 -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=ip6oa/1BmqqMO9VmS4ezgMQBQCHod7yBpmCLsS8sGYU=; b=Orr5+KswXMfRZKJ5fGYEJ+xFzpa7eTuBHLCNpGdL+V/HiCV5p9Jvi5nDoixcPMMtwq jI69ddgr4f9fTTFu8C9mImkulIVYLjeLMi9o93O2Xembws3Bkrlg5pGS0Z33NFYs/izq IYuYu1hIoSA4eCIX5v6q9COtJp18Q+Ck7b2HGcYgaxKl+8FYE3VOsjYpvmdLG8cyIynS g6iuTaXh0fub3Tq8LUDz36tjz3P+eZcNapoqVbFNh5Si8wAJ+M+lXphYIAurGHsFYQZH nQnHDi3uu70SUY21hn/EToLwcjRJlbBsK3M9y5FVO57VFMMYHvkHMoT/b6dnpUjTByyF MEqA== 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=ip6oa/1BmqqMO9VmS4ezgMQBQCHod7yBpmCLsS8sGYU=; b=A/DuygGZRfUXlG+mcl09Vpe28rXBWUDGQu/ERzQYpklKQvtLhs6a6fqt29wHwZJMYY g3xXou9/U9wbP4WW206vbpfm8WSWMSR4zo+JumXJAuv+6/UafbHV7TZNqs4pzVifUlzW Qlf0/HpR3EP0CwiVZXSjVxxFs3tm5F5Ndyn9x7RSbow0DPZwRY70jchNHBHLFgLET4tj OsPJgvZiGV7SxnSF7Sc/TDo5phSW8BpzVn+EKuiwC4TVkaVJUXHUrrCQMPzuypsguOib Bl+bNSpgK791DhaU5juatzOLhNS7SenizXy/2c1wY5J8afesHvTla9D1xATzsbRgjmvr YMNQ== X-Gm-Message-State: AOAM531+4pAscL2eHCXNRYUw9dqjacOc0Zq/LcGYk9xLWlp6royNSZw1 PDV85qCOujHk3/6jSNuY6NcHw/eqdWkIVA== X-Google-Smtp-Source: ABdhPJwlfJ/80YF1VEhsbstnwY1t4JbyRwm9yOputxPkap9K3XPZG6kG38oPjOePSLkeTX05WpTzOg== X-Received: by 2002:a9d:7ad7:: with SMTP id m23mr14916765otn.347.1619454055664; Mon, 26 Apr 2021 09:20:55 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id k8sm3132313oig.6.2021.04.26.09.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:20:55 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 40/43] completion: bash: cleanup _get_comp_words_by_ref() Date: Mon, 26 Apr 2021 11:14:55 -0500 Message-Id: <20210426161458.49860-41-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 05b6762210..4b01de38a9 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 Mon Apr 26 16:14: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: 12224569 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_NONE,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 51DC9C433ED for ; Mon, 26 Apr 2021 16:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27D026109E for ; Mon, 26 Apr 2021 16:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234554AbhDZQVm (ORCPT ); Mon, 26 Apr 2021 12:21:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234156AbhDZQVm (ORCPT ); Mon, 26 Apr 2021 12:21:42 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBC81C061574 for ; Mon, 26 Apr 2021 09:21:00 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id d25so19448671oij.5 for ; Mon, 26 Apr 2021 09:21: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=Qt8puCLeEk0kBL/J008NHabnhWsHxnR+OCzSibOTT1w=; b=tZzPFiB/SxkAWQBo7mfFqscPWpRfX7i8akENd4eLaXbGojN4aCWi6Kbj/VChkyRLIE 3GKHQoAyJ9XuFooHuBX1tK11e63TPJGTelCqGJmn+q9al3ZDA0jOx9gngDqohrnprCre CE7fGnzyMXEew6poaeb8zpl24li18CSouPA88gJw6PFGTAOr+S9OjOvyI6KlTrXMuieH 8MvcRyQt7rsB3ueX55eBvH35PWIT6OfBSYqygXmcNyP6rLFGeRRKmNRHKpAz4J1mTYOd 8MNfz3En5DpiCYMWqsBVT6Xo3PgNk6GueWxc7Br6w556ou20V0UvtlPEEZo8+6QElq0E aC4Q== 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=Qt8puCLeEk0kBL/J008NHabnhWsHxnR+OCzSibOTT1w=; b=fYG2cFWfaZyjq8T94xlTKKtko2QuwuHV7UkfoM9Kq8Dym9M7xozsLDAOiNny3ofZfn JXvmZfKchAeF+L2oDusDhkyLptFMeEupmSRRw8Ow5sVOrwCOGrWMW0vprRvswXP+M4Lk ifdoOmFNPACE+/5sLdmd4qvfYIBPIEGJGTRgSrKj5ZbGUj3QOvJiZGnvbVD75tZk7IOo Ah+K3pHl+CYiq/JxhyEOykW2/1egTavL+i5l5qPQjI6p7bHSQqRh62VlzqXYIfHBpF5a l+po3QsLK051WEpMwAkDdaAdcoRuRF/hGw2Qhx63a8xcGfN37EtfY7eQm/DBFtBJO+2y KcUg== X-Gm-Message-State: AOAM530JsLM7hatvV0fOukazJVq55GqM4eSWGMTCgaQFvHtX5WxmqcEa dejeTZiFdATv7VvfPCNp+RxCi+MIdRoG8w== X-Google-Smtp-Source: ABdhPJyWYlxK6iB7GcAwg94v29AN1S/NcMN9mnlRiAgTyKMXGGAGDdVUUA2JtdZpwYr8EBVLGSIjsQ== X-Received: by 2002:aca:af45:: with SMTP id y66mr12446065oie.43.1619454060054; Mon, 26 Apr 2021 09:21:00 -0700 (PDT) Received: from localhost (fixed-187-190-78-172.totalplay.net. [187.190.78.172]) by smtp.gmail.com with ESMTPSA id 186sm76899oof.14.2021.04.26.09.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:20:59 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 41/43] completion: bash: trivial cleanup Date: Mon, 26 Apr 2021 11:14:56 -0500 Message-Id: <20210426161458.49860-42-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 4b01de38a9..1cd249383b 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 Mon Apr 26 16:14:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12224567 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_NONE,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 8B28CC43461 for ; Mon, 26 Apr 2021 16:21:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D4476109E for ; Mon, 26 Apr 2021 16:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234507AbhDZQVs (ORCPT ); Mon, 26 Apr 2021 12:21:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233919AbhDZQVr (ORCPT ); Mon, 26 Apr 2021 12:21:47 -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 8464FC061574 for ; Mon, 26 Apr 2021 09:21:05 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id 5-20020a9d09050000b029029432d8d8c5so26667803otp.11 for ; Mon, 26 Apr 2021 09:21:05 -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=sh9OuoY8vDNSir6QIrw5CcTHciXB5hZVSx7h7iUQD+k=; b=aGwa45mcwqBfgKFBh17qgZGlzhEcsWIftwyVzvUUzgjwoY+P9ZI/26SOyN8VMKCrhJ FaarxYaeLF4kyx1qL9/AtMCtUgT1VukSaaZaxq9I/ZZJ7hA650wq5Dp24kmIGfdQwRpu ut/WXu2BuJLiI/ntugnekALNCsVFFGFfT6pG6Qx7EE13toGbcd+rn6zM4CJKxLjyWyys 7AxhwIBFKKAKnuLDh6r8jsyKawdpVWn3958zZyIPmmZaQ9B7N+jJvjXuiyeEobP58Fh1 Ge6FkQbWMHiISxaD5ruY8xWcMQ3hqF5MG7zSnquL6UxNH0sGeq7GqDumCiPeoS3Jp7nB X4Pw== 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=sh9OuoY8vDNSir6QIrw5CcTHciXB5hZVSx7h7iUQD+k=; b=YLl5c2LXnl1OmUhnRhYnvVvvFoyvDk2mXKJhmlopzlFVwiAM4CiCPGC5AyZtXwtGQ/ RgVCX6tm62Wo+zVtAm7IxEKIrcju9X9o5l5AD3aIrfkO0odA8NZ4PYO354OAm1FbcgnJ eof4WFF4LXkbXNGFV6RiK74l7DJQTDgB8xo0YEaH1+yKoozlhZFZjs+1rxlng5j5pbBd +YiIrmhYpRdMlwf87lCxMSWlJO39Zs1vJa6vcrMCGv7jYGJuZuTbxKOHuPsK4w27khbu Q7ItFLg0r8dVd/MKlVOFYloOP9xqZeKdiKKskS0uKGM3QoX6nfcaa4dk3bBUh04rVeh8 6IYA== X-Gm-Message-State: AOAM533x3lPBuEtMN/vk1MaSyDTmk96woHTSuyVSUtIgvBK+GreIKXSp 9LWSWbboTHneiMbW0js8sTSBsXlvLkwFCA== X-Google-Smtp-Source: ABdhPJxuZeeM26BijxXoiJYGhcIuH9lKj7nGM+n1d3v0RDo2qnvZFTaCvlVrUxq7pC+PTxohCaOB7g== X-Received: by 2002:a9d:60f:: with SMTP id 15mr15635648otn.81.1619454064586; Mon, 26 Apr 2021 09:21:04 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id t9sm3549778otl.5.2021.04.26.09.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:21:04 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 42/43] completion: bash: rename _get_comp_words_by_ref() Date: Mon, 26 Apr 2021 11:14:57 -0500 Message-Id: <20210426161458.49860-43-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 1cd249383b..d66db0ea99 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 @@ -3435,10 +3343,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 - _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 dfa2cb3b21..a184254891 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]} From patchwork Mon Apr 26 16:14: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: 12224571 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_NONE,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 C06E5C433B4 for ; Mon, 26 Apr 2021 16:21:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9DFD60C3D for ; Mon, 26 Apr 2021 16:21:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234572AbhDZQVw (ORCPT ); Mon, 26 Apr 2021 12:21:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234362AbhDZQVv (ORCPT ); Mon, 26 Apr 2021 12:21:51 -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 0CBFBC061756 for ; Mon, 26 Apr 2021 09:21:10 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id e89-20020a9d01e20000b0290294134181aeso26818550ote.5 for ; Mon, 26 Apr 2021 09:21:10 -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=i7+vS/5aoAuq3LL9K7r+djOAxgDMZpd4DD73V+p+p+0=; b=p5KaLVMid/8gP9APDOof6dqoITKWNMz7kUGLZg9ZH8zIAxbg+tOfZfiTDYM24iCoJ9 lwit745nkdr5s+FIyOS6UbfeOaT5t3SitEhUtW80yfEpd5ao/Er6xmMrSdfo6d/v2T5X n+RiKAJBV3dInPCVhS65gJL8f/eHPs1O1NENp5vxYfvZjXeO9gHbvknRWmkqu0L2aUf/ L4QEJF/FxzfwYKRuarDzS4lC5CEeq3hws402mbZ2Sxwi7Y2m668pydx5sut9fEw0wumm x4ZPfYKrqDtR0kdF16JZjuf9hWQsES1RkpGzSSOXMco/M+YaOK0EzaAQ/zgRri5Rmril wUDw== 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=i7+vS/5aoAuq3LL9K7r+djOAxgDMZpd4DD73V+p+p+0=; b=d6QcSbVOoAWCGiO4Vp9BdT4CEWl1+VCDNLb9wiiZdV9XM0HJznt/TbjTr9DNxIxA1j kzqmb4CxNDiJE622SENhvDCy9k99w1eSELtxTmCQwnOcqprptg3aORL0qOHl09US1Uwr ToPsoea2GxD+yzBOcC2Dbns7wPSVHHk42H3XOn+8tB7QCVy4tTfJSfFpbggJMShxktaQ Q1xUoNtSfyFUlOwJSXzSpweChgLdJaTmu4qt95ddAUfqdb62V8MjiLfD4VLOO1x1jYJi mWt8ibG2Cmp95WIKKnf/lElIZrximTTwcv4CkKn7Uxk9wqoRjU4in0nkSfT8q9EbG8ed CeYg== X-Gm-Message-State: AOAM531kz0ET21DUeUhnECEImqToAHOKZ09dnGnE+q8G6WuqEr+9dB7G RU5HWW0ZC/egTzECwBLznEBZEbTDdJhwWw== X-Google-Smtp-Source: ABdhPJzMfbF4cKLxnevd3DasqEMkVFdQYTen0CNaRub9BgFhPD9buTRk25YvJPp73VF4p60stjZlGw== X-Received: by 2002:a05:6830:618:: with SMTP id w24mr15425548oti.147.1619454069313; Mon, 26 Apr 2021 09:21:09 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id b21sm74039oov.6.2021.04.26.09.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 09:21:08 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v1 43/43] completion: zsh: add higher-priority location Date: Mon, 26 Apr 2021 11:14:58 -0500 Message-Id: <20210426161458.49860-44-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210426161458.49860-1-felipe.contreras@gmail.com> References: <20210426161458.49860-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 43b7c1b210..0024fd742c 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 )