From patchwork Sat Apr 1 08:45:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14957C76196 for ; Sat, 1 Apr 2023 08:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229508AbjDAIqf (ORCPT ); Sat, 1 Apr 2023 04:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjDAIqd (ORCPT ); Sat, 1 Apr 2023 04:46: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 3751BEB75 for ; Sat, 1 Apr 2023 01:46:32 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id b19so18412724oib.7 for ; Sat, 01 Apr 2023 01:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t+Ik/mgc5Vo++KuKdyyS+fCJV9CAMDLDsNWzL8FJmPQ=; b=XNOlyu93QxwD/etPkqOWa49wjz0EY5vPN1PhQsRbZKZ8Sp6xSga3Ko39RP9p4Mn4Gz /TZjEcTBvEr/lOoesT4IHRWH2FH3zw4Q7z917+FUL4t2nB7Jkkwfjm4cCiPh/33SzEUr HVIleQv0eUPXa6g+YJQ5cP0js7pQRImVqR8thukUPIoHiBnlxbbOTZURKdUPRipT4OIr XD3RALFkaMnbTAGEUVZIZuHFdiyRKkNXlx3ym5r1uIoPYgAdRGx0yos0KhMa9zwWdhy8 X9haTeyfJDyCredvxCCbRuC4gTLJqHuWLc/FcU/6JF2aciGL2barbVAcKAMBg8gLT+wA v9Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t+Ik/mgc5Vo++KuKdyyS+fCJV9CAMDLDsNWzL8FJmPQ=; b=n7XHuJd3bObD2jypRGEzVKaU/dThyfUJYaqUtFHhJK81W99qekIjK8xNpj0u6/FAt4 7AFI6m31MTV26/a3CuW2WMWxh1JAxxlv+ULK0L7w3O8BZL9veSf9GpsckGZwm29BhPhZ jkl1Bp0Ul3ou5j/zPYKcmjDSAkf2SGvdB/97TgGFdW5V3uID1VFVQW4BJyxvvhNV0R24 CSUK6PZNORjd1/BL8R/Q3p3ZT1bC7z0E24KEksrL4ekNdx39jTYOmyCt0lLN+o0L2ZId cNOhlfjxvtqlKScW7ujjHA9KhiWV3BsRroJ1yqZKTOJE5CwF2frqYhbmpXOVvvkYBeCX D6GA== X-Gm-Message-State: AO0yUKUefrK4fuW9DHuG9YthRz4iZxlc6FdHYGEnG+4iHmvEyOrMrzGp +UiyHsKQtD4mRyLzA3i0z+w4fr5ecAk= X-Google-Smtp-Source: AK7set8TLsND47mJVFBBccjbi1rPa667jzmeMONq3Pn4ucBFjrlPRP2v1RTsuxn5aXeBSgjfa1l0xQ== X-Received: by 2002:a05:6808:2d3:b0:37f:a6cb:7a86 with SMTP id a19-20020a05680802d300b0037fa6cb7a86mr9682875oid.10.1680338789652; Sat, 01 Apr 2023 01:46:29 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id et18-20020a056808281200b003872148d322sm1847155oib.22.2023.04.01.01.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:29 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 01/49] test: completion add test for __git_cmd_idx Date: Sat, 1 Apr 2023 02:45:38 -0600 Message-Id: <20230401084626.304356-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When __git_func_wrap was fixed to set correctly __git_cmd_idx in cea232194d (completion: bash: fix late declaration of __git_cmd_idx, 2021-06-18) no test was added, therefore we could hit the same bug in the future. To ensure that doesn't happen add a test which adds an alias for 'git add' with __git_complete, and then pretend the user typed this alias. To make sure __git_cmd_idx is correct we add the --update option to ensure the result of __git_find_on_cmdline (which uses __git_cmd_idx) is correct. When __git_cmd_idx isn't correct __git_find_on_cmdline fails, and therefore the --update option isn't interpreted correctly. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index d6c0478d98..561f06b46a 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2689,4 +2689,13 @@ test_expect_success '__git_complete' ' test_must_fail __git_complete ga missing ' +test_expect_success '__git_complete has correct __git_cmd_idx' ' + __git_complete ga _git_add && + echo modified > file1 && + touch file3 && + _words=(ga --update f) _cword=2 && + __git_wrap_git_add && + test "${COMPREPLY[*]}" = "file1" +' + test_done From patchwork Sat Apr 1 08:45:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03BEBC6FD1D for ; Sat, 1 Apr 2023 08:46:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbjDAIqd (ORCPT ); Sat, 1 Apr 2023 04:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjDAIqc (ORCPT ); Sat, 1 Apr 2023 04:46:32 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC3EEB73 for ; Sat, 1 Apr 2023 01:46:31 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-17fcc07d6c4so11578202fac.8 for ; Sat, 01 Apr 2023 01:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XfJghv4IwcBwZqf10lXzGVtOiySdrg8aI+L2KSpQUlE=; b=E9rQ32S/kxbg9juf+KViOO/WQaaupQo63trNhGh55BwY452kpvMhqoKLrndaiIdiAz nNB5B/mB80cUZE3dXFWC7nv8wnG4MmfpyWJ7IewbgDEiL+BGjAXdnLSnBzl3b6P8yzSm 4NTQDroEkgCJBS2RCSl4a8MNeFwag/cJz1XQifQzFynLHIsms3K5g4tihfLs85XNchr8 /9pFZDIKW3DS3UegH8tVsMMbE5Vt/p7RyOGVitFQkRIllWAOoTWPfx3ju+HDqUbZBv1H 7bfwyFT9DOZPH0qkZPILQ6nXmmxsz40ka9Bx/CxDowKU6wUrLPaevtBR5+x2xODVcRdQ Pj2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XfJghv4IwcBwZqf10lXzGVtOiySdrg8aI+L2KSpQUlE=; b=auep49mpum3Xo5qsaFFYdqRsExKtMPuPat7fGEuFihMAgs4qBNh/d37M55V+jlQeh8 h3XrWDBH2btAyvcNaUOqnaBjPxyukYK3OR/rEdwi30lgfwYpI9lhsPGSRPyO/v/P+AG0 1uRPoddI9N2ovJPmUNvD8on+JniY7Uix/iY9LnegnOvvj/N1Nx3bi9iuHm+gjukcvW/s f+9N0Jssb7AMxJkzI1Qj7Y2jFr9ZIeavo0U/ltxFalrtbOrqhketgNn27QvQ0x2tfy1K 3fGjRy5W55htoxbNt86PagNiWPQmVZ5GcPoWpFrUkscKuN94/OXZ/L+2MEh6AG6tETq0 Nqyg== X-Gm-Message-State: AO0yUKVORaumQKzbX/PZJ+zuOwVXQMn3AV1Y91dv5iXYHoC1OApZZGjm OWtFj0nee1dxI1UtGMMqEEibnI823/c= X-Google-Smtp-Source: AKy350aTdmXlwWnPtS9QWY+cbIrcb1e/PGJEelIA2Omwg5gHk7/pQNUQYEaYtnclS0VGjQyAEIldxA== X-Received: by 2002:a05:6870:88aa:b0:177:b62d:cc1c with SMTP id m42-20020a05687088aa00b00177b62dcc1cmr18340199oam.0.1680338791061; Sat, 01 Apr 2023 01:46:31 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id vj12-20020a0568710e0c00b001762ce27f9asm1742679oab.23.2023.04.01.01.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:30 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 02/49] completion: bash: trivial cleanup Date: Sat, 1 Apr 2023 02:45:39 -0600 Message-Id: <20230401084626.304356-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index dc95c34cc8..45eaea57d5 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3565,8 +3565,7 @@ fi __git_func_wrap () { - local cur words cword prev - local __git_cmd_idx=0 + local cur words cword prev __git_cmd_idx=0 _get_comp_words_by_ref -n =: cur words cword prev $1 } From patchwork Sat Apr 1 08:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06B1CC6FD1D for ; Sat, 1 Apr 2023 08:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbjDAIqk (ORCPT ); Sat, 1 Apr 2023 04:46:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjDAIqe (ORCPT ); Sat, 1 Apr 2023 04:46:34 -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 3967AEB61 for ; Sat, 1 Apr 2023 01:46:33 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id f14so4864391oiw.10 for ; Sat, 01 Apr 2023 01:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dgKE71beAWoC8WrJ3PpwJo/E2/kKUMDFrNC9BHDi1H0=; b=pDFWjWcsmuFNHm9qwcO/qWfwVpM4ckpDsjS4BJZ/aq1du0PcG6B5w8AMemQJuumnj+ DNJ4WRdxkV2IHfAFRkUQ81YX6sMzT4eaAfXh9CNY7OHdnp2evxd97Y1QDO1ND1ofqNp9 pEEwhvyrKTZQ1RLCl++/PQau9w+uD2lmrWE3kLvLGN8dCJEO2MUkiFS6vThBpzpjgqTw R0bw5rl3NIFce1ytYPcyeJHbl6v4cMlAGZmFxryY6bhqQvR1TzofDVJp58MFF0/GTwGz cfreL5rsiEtVIt9Zs11NTTtvFe5xOG6HSsSXVdLs8KQMp46ntt8fDSwtHjUak7ULp0yk NxEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dgKE71beAWoC8WrJ3PpwJo/E2/kKUMDFrNC9BHDi1H0=; b=1m5cmX8SsGWM8FkL/+F+GH3EfHeNni4u2S/bjC4RYoufkbObq34mDPxrjimKK/sYxC SUCeLO85t8I6FIhiboGjMOKtOPpxo0GxJjtMmFXwI0u46p59g5mx9uv7siMaysxvIAup NwvoY64iRvGMedh1kCKW7b8hKlOlZGa0H/XsBRBszqByaoJtXnMvmjn/O6LnPlZHx2nu 5lEGKTOQg6vjx9TBB/MTGAvuXSf3r0raXyG9Zu8jR8mDsAPa1o53SbL2PxX+DuISOqR0 zLVT4KLA4mQkzLL/Z4LVggiK9mQJczs9dBclci/XYsgdXs0ydTs2LDgKICnZxVE+0WKz mjgg== X-Gm-Message-State: AAQBX9dqVhLB+KyKD90xcI8rGBqmB0+jGTtjQXRxPoKUO/BbGYADtSvy Iic4U+3V2ERvw7e2XNHngGZrm0LBEhU= X-Google-Smtp-Source: AKy350Z/xBqM5SkCXlas6VWaHyShs093xGNmJl05HW9cu1O2sEHVK3bBB/h6eNFFzz25y937ac+1DA== X-Received: by 2002:a05:6808:3c3:b0:389:50f2:4ab0 with SMTP id o3-20020a05680803c300b0038950f24ab0mr7564881oie.10.1680338792335; Sat, 01 Apr 2023 01:46:32 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id t4-20020a4aadc4000000b005264a1472adsm1743481oon.15.2023.04.01.01.46.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:31 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 03/49] zsh: remove version Date: Sat, 1 Apr 2023 02:45:40 -0600 Message-Id: <20230401084626.304356-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Doesn't seem to be useful. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index cac6f61881..c7bc6a8f8e 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -135,11 +135,6 @@ __gitcomp_file_direct () __gitcomp_file "$1" "" } -_git_zsh () -{ - __gitcomp "v1.1" -} - __git_complete_command () { emulate -L zsh From patchwork Sat Apr 1 08:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B4F9C6FD1D for ; Sat, 1 Apr 2023 08:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229535AbjDAIqm (ORCPT ); Sat, 1 Apr 2023 04:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjDAIqf (ORCPT ); Sat, 1 Apr 2023 04:46:35 -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 85D77EC6B for ; Sat, 1 Apr 2023 01:46:34 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id ca2-20020a056830610200b006a11ab58c3fso12466849otb.4 for ; Sat, 01 Apr 2023 01:46:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rr0wkzEqfI6Hg6o91HnD2M/16KjNG1MP5jbC34nQk8o=; b=Z817JxJWnNVurssXL535JsDChuTzMOSMFji6XfFwR0+d9PREKG0ilY9IM4/rNOu+hX g83S5IrthFktReIMPzaijhu2AueKX58HT47dh+Q2Xd9sC7zlI8Ru3AHPEH72rHNycoTt 25PaxcoSJcAqlIvSK6qlbdPuAjqTsYqPzOkGeo80Kj8n1aJ0QjIsNiPPBIzC9l4504Ya ioU2qAdn8mAFOUQrTZ+hnEZv0/KNZgkqeBOQlpx6jqka5Sp0jnCHbHXuhKgPhYQTy7OR EEkmiMslO6AG3kunmR2Wp8yZDUtMoJQj1Ulu8zI0N+ct4iRyqRHpE9OsZmy2T0bYgb89 7RBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rr0wkzEqfI6Hg6o91HnD2M/16KjNG1MP5jbC34nQk8o=; b=3pkne3pQ2yEjHXRc9VTEeIRYqYK+4Nw2Mw9Qo84pTz/VjVfxozuuPbs2iNj5ARfKyR ODyXsHoKkaaRNYzyyukU2MgX6X33XI38x8Pmumnmpgtcl3++Eht0n/X/By2U2R1IySDn yqtsupecDj7L3cOwy9cHgqRiJOJFC2Jj0GXj3vBp6Z4O0Crh8ydxXtc3n49K7IRwhWLh thxlbAjFB/SF2LNPOsw56TLanMU45/yxVlbWOzDiRmohKy7zMKzv3tPWDh4cS0/JSGVq W8LdUeCOli2K2QQ5H1EG0H/wmwsBMGbs4RfE32m5MAXRtYkjxFdeuS3qBvvHZIwvo8or VxwQ== X-Gm-Message-State: AO0yUKW4HgTwINOzR4Ka/3yO+wpLSntcUN1nhWuP+hWIlH+c4RUA1FsX a9ZZBP9qxQqqn1ybcwcGzgdmXIgasd4= X-Google-Smtp-Source: AK7set/e4kfduXrp7WGlUIvud3HcALQlaLvdI3MrQXimx7sn8j+L8EJ5Seex/dbN/KHJH9rBLANiEw== X-Received: by 2002:a05:6830:1bc7:b0:69f:9779:a216 with SMTP id v7-20020a0568301bc700b0069f9779a216mr13601441ota.30.1680338793594; Sat, 01 Apr 2023 01:46:33 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id d27-20020a05683018fb00b006a2f4a754e8sm1152114otf.60.2023.04.01.01.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:33 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 04/49] completion: bash: trivial grammar fix Date: Sat, 1 Apr 2023 02:45:41 -0600 Message-Id: <20230401084626.304356-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 45eaea57d5..cf6ff0595f 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3330,7 +3330,7 @@ _git_worktree () # Here we are not completing an --option, it's either the # path or a ref. case "$prev" in - -b|-B) # Complete refs for branch to be created/reseted. + -b|-B) # Complete refs for branch to be created/reset. __git_complete_refs ;; -*) # The previous word is an -o|--option without an From patchwork Sat Apr 1 08:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDC2AC76196 for ; Sat, 1 Apr 2023 08:46:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229518AbjDAIqq (ORCPT ); Sat, 1 Apr 2023 04:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjDAIqg (ORCPT ); Sat, 1 Apr 2023 04:46:36 -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 28AE7EFAE for ; Sat, 1 Apr 2023 01:46:36 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id r17-20020a05683002f100b006a131458abfso10559547ote.2 for ; Sat, 01 Apr 2023 01:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v95+I5JULBbOj8wfzqVH7loGQ+8IyMbpP0Y/C5uKICs=; b=LvtDf1MxbuTpeP8X/lgEK4szWMgK2dGHVowEEoZJMo1jr1Ka3VL6nQikgS6LzKJcXG 53dVVkFcvanIwiuF3tvWn/2PwPCjMsIu6tqtiQhwvY5hNPe8Oc/pHPgGH37u7jLyvKvN zs54efmDwsB9sDUfW9RvlaOjEf3YaYlSW1StFIsv3z8vpwUb7oGl/FBTBeEtv+0+VkGc w02p3YbyZtahJqa4O1VopZ0EgfFAZD0FRyDvzxTFHCYQDqI/xYdtWH47Nt3KYHELwwMq bjv9ln8Q3a5dDYaknrlSkb6lVfyCxWocODympeA2MXVN4QYgYUA0zSzWkjJNNnJSx2dV 3o2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v95+I5JULBbOj8wfzqVH7loGQ+8IyMbpP0Y/C5uKICs=; b=pmAZItFPqLFwb45C7qF4WZJt47lh38skuNwmMIcpowayXaem3W0Hy/ESEj9XS0SxKU c5u3iWJLtRYj2YO1gMCi8Bd+dFCvvQsCsS0KQg4gx19izC/A5T7qFoJBL7mV+IvefbAb aoWQQ5sZjgmGci7Jwzqd2iaJYg2GUWqNI77smBLkp6fZKwFG1n9i9cKns15BQG5WPIYi ku9TWf8XlfeHgIYPHsOgdZrkQvvQIPEgVwy6rYL8hJjV8tIAiWWqPx1+k0Y93aE7phUT vrXbmJrviv+raBjL4+PdnEGPsuiC6Rpp1s6TnNSMGSB+j0AJE9ZL0YX4n8DZel+NuzJ/ 369g== X-Gm-Message-State: AAQBX9eDViQ9ahtO3210VTGR3wu0cexYZoiz6zylN5iKpjRQhIE8Enz/ pX84xPK/4HFml9+gD+xRJCHVflFEXdE= X-Google-Smtp-Source: AKy350auMr+JWEom2uS9nijqAdAX6qq7w1ouPGRqkhSQTGYUJYoZ/xK2vIhvsKaVlT9bA5NBhPA/GQ== X-Received: by 2002:a9d:6c04:0:b0:6a1:20da:8cee with SMTP id f4-20020a9d6c04000000b006a120da8ceemr12479508otq.31.1680338795055; Sat, 01 Apr 2023 01:46:35 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id m15-20020a9d6acf000000b0069f0794861asm2021877otq.63.2023.04.01.01.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:34 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 05/49] completion: zsh: add higher-priority location Date: Sat, 1 Apr 2023 02:45:42 -0600 Message-Id: <20230401084626.304356-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 c7bc6a8f8e..5f2c63236d 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -35,6 +35,7 @@ if [ -z "$script" ]; then locations=( "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash "$HOME/.local/share/bash-completion/completions/git" + '/usr/local/share/bash-completion/completions/git' "$bash_completion/git" '/etc/bash_completion.d/git' # old debian ) From patchwork Sat Apr 1 08:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 644E0C6FD1D for ; Sat, 1 Apr 2023 08:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbjDAIqr (ORCPT ); Sat, 1 Apr 2023 04:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjDAIqj (ORCPT ); Sat, 1 Apr 2023 04:46:39 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF424F74E for ; Sat, 1 Apr 2023 01:46:37 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id r14so12747584oiw.12 for ; Sat, 01 Apr 2023 01:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ux3n5HafMSlbprFuxRK6bFQoW7jxZooRkaDvi9NccYI=; b=EDPE/TcPzJrDsLvWGYI9VkN2vNyPzYt8xNr3Mo5jjGGSjzJKa5OtumNYQcf1fGa5+C 3KtpN6yP+Fnz7QbFcXMm30J4MFBPFlz36FC5imcxCRK4Ej7nM5Pa6DcbCJ+P7Ci5BY0y 8c00YM/UwJM4zSoF6fIYt2Y0dzmxTs583jrLY5FcBPqTJGkjry74qde/8jbDDSiIWsrn omojMb6oPCWo2SMnFkLCVCM5JYYSjaPRPCBtnDrkUcT/XXtwH/MBxJ03q4J+trb95d5I N7DcmHC4MkdhBhImtEN3O3DSPMlQDL3WNS7fKMvIs7NN75Fk6CaKqi9cHuzkHnVpJoL9 0Umw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338797; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ux3n5HafMSlbprFuxRK6bFQoW7jxZooRkaDvi9NccYI=; b=FWxNg7Lm1ElhFwLY5yMyykKTalimY+1jIYphmPvL2IhQh9Q9iCRlHAG7APdE4P3RM1 UMrm1yszd37FQYZh80u9LKxBDsPVnvM0TMVtFYsAWV1D+YSfp5w+1JgHbAsz6MjSVhih Aa6VhgonaYCXtuRXO9MEkYAiSAuhxnNDWrdhChwiuDUD7BJrX/80hEZN/fqmki4u1aww x2R9AivAUIPtjW0TCScpq3tXGAGKahquEGL4v+4YUSA8KNzWgqsjqWbyFzAI7ajqT+80 LMNkFdebCK/+gRF64ssPI02vTSEkjmE+G1IU/YGUhqR3vczA/i0sKZC0bRMaQuVhKDn9 W26w== X-Gm-Message-State: AO0yUKXmQUcXidj9xRdrLri66LC8sd56ZhC6IqMwUaqYCHPNJROR5eK6 hCxoUQD7rLZnpS9ixB5KKBmKN4jzzEM= X-Google-Smtp-Source: AK7set/lu82gFpRVovStix3hVFStslLJ+k9fyeMiMJkX4QMz5HQA5zf0YJs/uW2XYjFjASmL/plxjQ== X-Received: by 2002:a05:6808:18a0:b0:387:205b:70c7 with SMTP id bi32-20020a05680818a000b00387205b70c7mr17864278oib.13.1680338796643; Sat, 01 Apr 2023 01:46:36 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id y35-20020a4a9826000000b00524fe20aee5sm1743917ooi.34.2023.04.01.01.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:35 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Michael Bianco , Felipe Contreras Subject: [PATCH v7 06/49] zsh: resolve symlink of script Date: Sat, 1 Apr 2023 02:45:43 -0600 Message-Id: <20230401084626.304356-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Michael Bianco When using zinit the completions are symlinked to ~/.zinit/completions, this causes the zsh script to not be able to find the bash script. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 5f2c63236d..75bb44d41a 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -33,7 +33,7 @@ if [ -z "$script" ]; then bash_completion='/usr/share/bash-completion/completions/' locations=( - "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash + "$(dirname $(realpath ${funcsourcetrace[1]%:*}))"/git-completion.bash "$HOME/.local/share/bash-completion/completions/git" '/usr/local/share/bash-completion/completions/git' "$bash_completion/git" From patchwork Sat Apr 1 08:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13F46C76196 for ; Sat, 1 Apr 2023 08:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbjDAIqy (ORCPT ); Sat, 1 Apr 2023 04:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjDAIqp (ORCPT ); Sat, 1 Apr 2023 04:46:45 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF9910A82 for ; Sat, 1 Apr 2023 01:46:38 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id l18so18397105oic.13 for ; Sat, 01 Apr 2023 01:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FWLZZzZSM4/MpiTNasv+Z75s8Mh1UYH3jnDgIhWXEV0=; b=YTmG6liWL6flTLa+CUD7/tvs+Qtuzp2+B9ItndET0m4f+AldnSxdnkG7L9840kFTKx vJGLRGcn2Fo/r5EahYC2oRPlYTeBY2iftO/GqxNz2LTM5ymwyZMNYloCgajlN6ZpyTdu DHfUtSwkVslDGJWbA82ek/VNXX4gofuAJL62KP68/Um34bSwioQ/u73HUR4DeZT20GzY o2MdimZMfxRD12Yvg+7JlNFSYgfdirquBued/GT3b+6fJG3VoX6TF+IczcG5KoNtLXa7 7lysbUtRmNC8z+DN5a6hiScfxWR5p8ILbGno+4CMo8Iy3N3xAng41Dn1N5MxxouqJGaV Fz3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWLZZzZSM4/MpiTNasv+Z75s8Mh1UYH3jnDgIhWXEV0=; b=m9pVjoy331WY979PO9evV5URRDvvtb0hXpaES+UI9m/7HV7PPQdW1rcbPe9Nd4TKWa 80uTeJNDellEKrssWnFaMBf94IIgJUPLQUMh1XigCPoX16IpUgXdSFPYuANKYGZBoAfw FJqKSFnL7QlKdr7IpTnoA86b23RMhAam1eCbMnDsb+Okyy/SuDzkK9MCqUMII9oYTlfv iyYwA6UWfyVpIx8BKq2OY6kLYQr/oqpOeMbs2Vy+KvNpgmISAonqle+uhuGmfDqrpM7J df94dU81++urbojbMHxGIfn0Djmh0sFYw8tfaidtAIUXonPB9PGdMLldNy9ldZS7GiYg m7fA== X-Gm-Message-State: AO0yUKW27As0cKWctip03UjOhQvBY00id3X748zB7CNYY5RszvBfevbQ qMv4o8Uw9duGZqzeshhIyPrkdOdoA3o= X-Google-Smtp-Source: AK7set9RqkkhrPUR+guohiATUhHvBYlExA/JJKsppE3xTm+O/tYjNQC/Vc77Rr2KsayxIjkDX3jlAA== X-Received: by 2002:aca:1718:0:b0:383:fb11:6513 with SMTP id j24-20020aca1718000000b00383fb116513mr11781056oii.46.1680338797913; Sat, 01 Apr 2023 01:46:37 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id l2-20020acabb02000000b003896df086b0sm1864399oif.15.2023.04.01.01.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:37 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 07/49] zsh: simplify realpath dirname idiom Date: Sat, 1 Apr 2023 02:45:44 -0600 Message-Id: <20230401084626.304356-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's a much simpler way in zsh. It's a shame that ${0:A:h} doesn't work probably due to a bug in zsh. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 75bb44d41a..4f22e8f85b 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -33,7 +33,7 @@ if [ -z "$script" ]; then bash_completion='/usr/share/bash-completion/completions/' locations=( - "$(dirname $(realpath ${funcsourcetrace[1]%:*}))"/git-completion.bash + "${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash "$HOME/.local/share/bash-completion/completions/git" '/usr/local/share/bash-completion/completions/git' "$bash_completion/git" From patchwork Sat Apr 1 08:45:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA4D5C6FD1D for ; Sat, 1 Apr 2023 08:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229519AbjDAIqz (ORCPT ); Sat, 1 Apr 2023 04:46:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbjDAIqq (ORCPT ); Sat, 1 Apr 2023 04:46:46 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C1671D938 for ; Sat, 1 Apr 2023 01:46:40 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id w13so7037717oik.2 for ; Sat, 01 Apr 2023 01:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CBrcaWeKXD8fS8LWKYgvLIk/E2ugz0dBaeZpddjiLK4=; b=DneFT4uQxkoYgK96r4mq7tLNa5ph8ou6I2MDok7vSBxj6+47z3K7j3DAVw0YWp6XXC 919LyJOz4JQcBWHMUTA0mUx/Mzol7ijJvdTfaALSb2/ig79YYu91ASM6ZTxY0VVdI1cd SdKafN5azcstTb3NuVjy93acFMqbRnB2F6oN8u/1rXzGtrGYI6O2NkeoHZL/qltisEA/ MC8QygTr27lYypSG4u+IgY5NvhlbFbcLFfbcCeKl4BDp7wRxxuXHR0Q3kO38VR4K18Fr XKRdXYj61xjVLoVPjLxpwVYf9VUQWjnkvNXIoercaelC+sSYcozA59SKMIcH13TGhKK3 719g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CBrcaWeKXD8fS8LWKYgvLIk/E2ugz0dBaeZpddjiLK4=; b=A7Tbd3RWUjAiFPN+nyIXPZ5JT557RaIB44WMPCI/eLwZHdx8sLzx3LpcxMifU1Nth6 0t4phH3rai/lRsuYiOLSa0tOglbWg54PacKGeahazueXRF0ixo/i+l2fVDWnJQxiH3f3 Sz3bQZ/lBff9WtEm/GTM1HVE+eLF8KnIRGvRHpc7U4DxPE6z3PrFg+IyLtNWIoCJlRyx oxVH8MDH4Kyu9fqzK6FBF1PHCeRl3fxz7DSEIDgk08TQnhgzRcIlf23E/odVkXDQ+c3/ hgVhcd/jSpptsmcRJQIMaz0xToJRovdaIVqNC4UCAc02zMXZhixWKWMa8U36HwJuxoEG GKWw== X-Gm-Message-State: AAQBX9f5+QHaMSJYedoGir2MrkpYydn7X4er2/yOlmRgena9RQr3LwIB quBs7PRY9oQv6bYI9oleBELVmyDW13A= X-Google-Smtp-Source: AKy350ajDf8FpIxCYwC5BxV1559kX+/vbisJCI6VEVGjrmc0jgzx0oxEDfbfVR9lRXvYr81uO9ji4Q== X-Received: by 2002:a54:400a:0:b0:389:9c8:7747 with SMTP id x10-20020a54400a000000b0038909c87747mr10147142oie.21.1680338799236; Sat, 01 Apr 2023 01:46:39 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id o128-20020a4a2c86000000b0053b8ae294f3sm1774218ooo.11.2023.04.01.01.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:38 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 08/49] test: completion: use global config Date: Sat, 1 Apr 2023 02:45:45 -0600 Message-Id: <20230401084626.304356-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Aliases are supposed to be global. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 8 ++++---- t/t9904-completion-zsh.sh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 561f06b46a..6c3cfe7e5a 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2233,7 +2233,7 @@ test_expect_success 'git --help completion' ' ' test_expect_success 'completion.commands removes multiple commands' ' - test_config completion.commands "-cherry -mergetool" && + test_config_global completion.commands "-cherry -mergetool" && git --list-cmds=list-mainporcelain,list-complete,config >out && ! grep -E "^(cherry|mergetool)$" out ' @@ -2430,7 +2430,7 @@ test_expect_success "recursive alias" ' ' test_expect_success "completion uses completion for alias: !sh -c 'git ...'" ' - test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" && + test_config_global alias.co "!sh -c '"'"'git checkout ...'"'"'" && test_completion "git co m" <<-\EOF main Z mybranch Z @@ -2439,7 +2439,7 @@ test_expect_success "completion uses completion for alias: !sh -c 'git completion for alias: !f () { VAR=val git ... }' ' - test_config alias.co "!f () { VAR=val git checkout ... ; } f" && + test_config_global alias.co "!f () { VAR=val git checkout ... ; } f" && test_completion "git co m" <<-\EOF main Z mybranch Z @@ -2448,7 +2448,7 @@ test_expect_success 'completion uses completion for alias: !f () { VAR=val ' test_expect_success 'completion used completion for alias: !f() { : git ; ... }' ' - test_config alias.co "!f() { : git checkout ; if ... } f" && + test_config_global alias.co "!f() { : git checkout ; if ... } f" && test_completion "git co m" <<-\EOF main Z mybranch Z diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 65bdaa011e..cb123261ab 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -1008,7 +1008,7 @@ test_expect_success "recursive alias" ' ' test_expect_success "completion uses completion for alias: !sh -c 'git ...'" ' - test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" && + test_config_global alias.co "!sh -c '"'"'git checkout ...'"'"'" && test_completion "git co m" <<-\EOF main Z mybranch Z @@ -1017,7 +1017,7 @@ test_expect_success "completion uses completion for alias: !sh -c 'git completion for alias: !f () { VAR=val git ... }' ' - test_config alias.co "!f () { VAR=val git checkout ... ; } f" && + test_config_global alias.co "!f () { VAR=val git checkout ... ; } f" && test_completion "git co m" <<-\EOF main Z mybranch Z @@ -1026,7 +1026,7 @@ test_expect_success 'completion uses completion for alias: !f () { VAR=val ' test_expect_success 'completion used completion for alias: !f() { : git ; ... }' ' - test_config alias.co "!f() { : git checkout ; if ... } f" && + test_config_global alias.co "!f() { : git checkout ; if ... } f" && test_completion "git co m" <<-\EOF main Z mybranch Z From patchwork Sat Apr 1 08:45:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00899C6FD1D for ; Sat, 1 Apr 2023 08:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbjDAIrD (ORCPT ); Sat, 1 Apr 2023 04:47:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjDAIqx (ORCPT ); Sat, 1 Apr 2023 04:46:53 -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 E2F2B1D84C for ; Sat, 1 Apr 2023 01:46:41 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id d22-20020a9d5e16000000b0069b5252ced7so13128567oti.13 for ; Sat, 01 Apr 2023 01:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SxY7AUnec4vLmKyh9PxgXeVlLFHg75UqJ5jiZs9xvc8=; b=jyU2iArcXs/sZ92X3mlQ8HQq4No9eKdwfuXFkvfmpxbELwlukqZJyLGLWFRD60JBIU acctGG1sEyHmTRV7PeBGv3H4Sv5eK8vjAsRzqrBRCZCHnh/C5pFUuin6QyqTU3VYzyNg gzo+W3ATzvu41xt4W76G554PiLGLOH3A79tj0z68CItwv1aL58e+bLeN8CIRcUTSCfWT fik3LfNe7C/TgPyyc0s2JNXku46yUT3s+kNZsp/RiXHqs1wd7sSWQAfnAgR+wg3CeUyP l6303vXsDwmsnsRU7KA/yBSA5tMWJh5K4dxJwZMvkKi7lC0r664uSFCjNyyLsEBg/q6Z +FgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SxY7AUnec4vLmKyh9PxgXeVlLFHg75UqJ5jiZs9xvc8=; b=yAVtDVqNOlqiT0GleG+Tl1DGpkz/QsEUIAJ2fawfj4UTe1YuyHFU5CStcYGXdC0KMX ofzkQlr1qymLHDMrmI43I1iVwbsEGwK7IW3sHa3JN+QjDV3HAwiwR6pdW5V3Xveskzmc km0kzLE0NTJT2abZ5GcEnHnIpIx6FeqIFoA5Tt837FO1YMGeyWXirwqmwPS3ut2nsTJV 0J7ZTSJeSY7KfOqvTOWQX/eiKDplBopVbWU1M+Iki2oW2uewtdZrXO3yX2SG3NP3m8zE 3giFnX6sNZu4ZA3uF6SQXQJn3QfDRrZSRq6HiHdWzQ1X4AnY5wqjl656h4L3vg9zTQGt S3tA== X-Gm-Message-State: AAQBX9fN4mdd3+HltKICS8SA2/MW5g12zZ87INzEHhJJl+ADn9lKq6gt Gzgi30S+UOgpb5PHs51VQgpbr0ipdV4= X-Google-Smtp-Source: AKy350YGA4M4bYr/PxnKWYXqaTvXv8aR6D5OwFYhrv4h3sfcjMK8qXe4QWmjqmEvY9S0DiIUW067wQ== X-Received: by 2002:a9d:6395:0:b0:6a1:7f69:ffb2 with SMTP id w21-20020a9d6395000000b006a17f69ffb2mr3488683otk.38.1680338800781; Sat, 01 Apr 2023 01:46:40 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id z1-20020a9d7a41000000b006a144b97e73sm2043860otm.74.2023.04.01.01.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:40 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras , Harrison McCullough Subject: [PATCH v7 09/49] completion: fix __git_cmd_idx regression for zsh Date: Sat, 1 Apr 2023 02:45:46 -0600 Message-Id: <20230401084626.304356-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The commit 59d85a2a05 (git-completion.bash: use $__git_cmd_idx in more places, 2021-04-22) caused a regression when using __git_complete and a command relies on __git_cmd_idx. This was fixed in cea232194d (completion: bash: fix late declaration of __git_cmd_idx, 2021-06-18) but only for bash. We need the function wrapper (__git_func_wrap in bash and _git in zsh) to define __git_cmd_idx. Otherwise the equivalent of __git_complete in zsh fails: compdef _git ga=git_add ga ga __git_find_on_cmdline:[:14: unknown condition: -lt Reported-by: Harrison McCullough Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- t/t9904-completion-zsh.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 4f22e8f85b..d11f4765b6 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -267,7 +267,7 @@ __git_zsh_main () _git () { local _ret=1 - local cur cword prev + local cur cword prev __git_cmd_idx=0 cur=${words[CURRENT]} prev=${words[CURRENT-1]} diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index cb123261ab..b7e4029bf9 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -1140,4 +1140,10 @@ test_expect_failure 'options with value' ' EOF ' +test_expect_success 'main sets correct __git_cmd_idx' ' + echo modified > file1 && + touch file3 && + test_completion "compdef _git ga=git_add${LF}ga --update f" "file1" +' + test_done From patchwork Sat Apr 1 08:45:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E9F4C6FD1D for ; Sat, 1 Apr 2023 08:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbjDAIrI (ORCPT ); Sat, 1 Apr 2023 04:47:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbjDAIqy (ORCPT ); Sat, 1 Apr 2023 04:46:54 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A6EC1F7B3 for ; Sat, 1 Apr 2023 01:46:43 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id q27so17676746oiw.0 for ; Sat, 01 Apr 2023 01:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YALdm2/0a1pXRLq+ru7XwkN3rxaKhRZCMQQLXCsdWm4=; b=DH+n2unKqJp32kRdQXG7Sc1QZ5Pby7Fjq4pVYKAQoYvjIkexLnRtytEJ/Bnmv8/G7v w2kmKLFFyGyJCNXX+g3FBTPYRQ4DCiADh3xrITJ6D2OfawN9xchpGNrbwVF/BRyF33QN TxjlWK4r/x6YgwyRFaN4d4nLEsyU+mldxmkH3Dxfo1dc4ahffgC/YdWTVpsNznEmIb/i 5YbediwV/dbAGtKIJxf5/lVsBNqCnjpu40xZOcADc/vriIEw5cpf2pB1hWO/EK0ygKML 6nXP5vpyF8E14K3lCb6JAP/h+E2R8683ZomlBcug2PQ5zPjT1V+/b4qeMFpcW/xo3h4h d3WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YALdm2/0a1pXRLq+ru7XwkN3rxaKhRZCMQQLXCsdWm4=; b=xsOx+AEa0JgahPF3Fgl3ucBMuo7VfWfM/MjKdbw1A+EKjdLnStZ9l4ZgYAN8Jh+YMY kL9DWxTuXB2tANUrWyncFvWD/ZMJSz6bU25vgVs4DnOrDjIyXcA+SyHTt3WdXGDifsbd tq7Z/NnUfyS2g1UqHHe+ehF0GzDlY/o+Gb5SPS29Iy30TX2b9Z1daNiAQ40GBc37TQem Q7mKfiPEDcB7YK9DY09oaLqGy2tr6nbdfyd6ZR+KOYJOQANDUrYae41CElnQ7qQeOly2 lU7oLUZ+U2E1UMglIQm+s1rdExKvvKPa+OYHXahieCTVWZx5uUfF2P6LmthNKlVunpsw gmgw== X-Gm-Message-State: AO0yUKU7nI+2bVySQ9Xl+I761vozDc7FDZg7f9LB5nzogd6g0lVl2LuM pCPRprQHCRiHU+Xx93k6ufoOWHn0jNo= X-Google-Smtp-Source: AK7set/vXlDDJKbV1sSFzcYNgF21zCKuoalzsc+nknz2YVe/zYsLkc9Hq4zddyIm32gRp7yeJGouUA== X-Received: by 2002:aca:2217:0:b0:387:6a3b:5a86 with SMTP id b23-20020aca2217000000b003876a3b5a86mr13044221oic.28.1680338802165; Sat, 01 Apr 2023 01:46:42 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id h4-20020aca1804000000b003896fc34eddsm1820393oih.52.2023.04.01.01.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:41 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 10/49] completion: fix for suboptions with value Date: Sat, 1 Apr 2023 02:45:47 -0600 Message-Id: <20230401084626.304356-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We need to ignore options that don't start with -- as well. Depending on the value of COMP_WORDBREAKS, the last word could be duplicated otherwise. Can be tested with: git merge -X diff-algorithm= Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- t/t9904-completion-zsh.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index d11f4765b6..13809f7894 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -56,7 +56,7 @@ __gitcomp () local cur_="${3-$cur}" case "$cur_" in - --*=) + *=) ;; --no-*) local c IFS=$' \t\n' diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index b7e4029bf9..994d57a67f 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -176,7 +176,7 @@ test_expect_success '__gitcomp - expand/narrow all negative options' ' EOF ' -test_expect_failure '__gitcomp - equal skip' ' +test_expect_success '__gitcomp - equal skip' ' test_gitcomp "--option=" "--option=" <<-\EOF && EOF @@ -1134,7 +1134,7 @@ test_expect_success 'git clone --config= - value' ' EOF ' -test_expect_failure 'options with value' ' +test_expect_success 'options with value' ' test_completion "git merge -X diff-algorithm=" <<-\EOF EOF From patchwork Sat Apr 1 08:45:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83C08C76196 for ; Sat, 1 Apr 2023 08:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbjDAIrT (ORCPT ); Sat, 1 Apr 2023 04:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjDAIrA (ORCPT ); Sat, 1 Apr 2023 04:47: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 A3A2720C29 for ; Sat, 1 Apr 2023 01:46:44 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id f4-20020a9d0384000000b0069fab3f4cafso13135084otf.9 for ; Sat, 01 Apr 2023 01:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338803; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nIpnDUOgGlPCgKXX0oLBp3OIzqLY1SOFKqnWWMhtFjE=; b=WRkUnJ9BRxQNkT3wo9bNyhiRrBLwKBac4rsB6QxulbLKA/YIyyh6DTuFOsfCkrhcFo 7MuwStPgXbk8HgLbLmMIaqLmDohm+AfVt7cVihf6gyU7eDQ2I5bjCNy9D0nCwJSEpLZm VGJ0yyk//IetMF/N5dNxrNHt+YliyIxMKaUr4+WAaVJXW7KT1mb1xeaYqTQ4l88RY7tX 4knGkGQqKl0rOBgf8cpF9XvJZQRDPJxwQSY9jaUoeXd1dLrH6LtnkjqhKxcRFfKdprg/ DOGhWg2YLmZv9i1h6XspnVHJvVHNz7iJ9stl4h1koGrJFTWyNGjpZYQyMdnAB+EHoSXl UktA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338803; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nIpnDUOgGlPCgKXX0oLBp3OIzqLY1SOFKqnWWMhtFjE=; b=wXtjX+Oy2Y8qavMCuBy6KBcAruqlNhEugdnZsWAtwj/JHtwca5/l18k6qk+CRCq4ZA NVvUZD9LZ2dur4xZ/YLPHNl+8kAGvY1kHRzQZUuekLMZ92m6luvNxbjvLWK/5TSELBl7 Mq69CagXXwS+mFl2xWSvQw9pcH0yCtIiVflwxxcPV9vwWV8IoXdxnNsJfDzkcNPqjjbL qNxtCgJL+M7KYKLuUHD1lxfe45JiogM9WP/s3mKmoURyvsbLs/ZBR2CwHlwJKKBz2ukG /6CnOdwQxKfiYbYoyQTsOTMplk9XWgRg21aXYwkXdl3E1qIKuspdV8OpCc2sW8Za0nQz qWyw== X-Gm-Message-State: AAQBX9dWwS6BIiiXrwFlRQvdrguQzrmt0t5qm/I7O9LGVYQhjAgb/P87 7zwdWDQZRdk8E2l7oCJeyzC5kTktsDc= X-Google-Smtp-Source: AKy350b0Rsn5CpcU18yLk1wPV8/oLeZCDrQ5ICfjI98ntoceFuZKq+27lF3p83B/MqDAdiJLIZUs7Q== X-Received: by 2002:a9d:6d05:0:b0:6a3:780:5848 with SMTP id o5-20020a9d6d05000000b006a307805848mr868908otp.25.1680338803400; Sat, 01 Apr 2023 01:46:43 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id u3-20020a4a5703000000b0053e3da7f810sm1773562ooa.25.2023.04.01.01.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:43 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 11/49] completion: zsh: trivial improvement Date: Sat, 1 Apr 2023 02:45:48 -0600 Message-Id: <20230401084626.304356-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org $words has basically all the words we need, except the first one: git. Lets simply add that instead of passing the original, which contains options we don't want to pass downstream (like -c and -C). Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 13809f7894..790879e319 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -215,9 +215,6 @@ __git_zsh_main () { local curcontext="$curcontext" state state_descr line typeset -A opt_args - local -a orig_words - - orig_words=( ${words[@]} ) _arguments -C \ '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ @@ -257,7 +254,7 @@ __git_zsh_main () (( $+opt_args[--help] )) && command='help' - words=( ${orig_words[@]} ) + words=( git ${words[@]} ) __git_zsh_bash_func $command ;; From patchwork Sat Apr 1 08:45:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5E75C77B60 for ; Sat, 1 Apr 2023 08:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjDAIrW (ORCPT ); Sat, 1 Apr 2023 04:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjDAIrB (ORCPT ); Sat, 1 Apr 2023 04:47:01 -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 614121EA27 for ; Sat, 1 Apr 2023 01:46:45 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id ca2-20020a056830610200b006a11ab58c3fso12466990otb.4 for ; Sat, 01 Apr 2023 01:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R9opIxlyolKgPJ9ZaPi/fz5XBE5t9vm/e6ZtmMdzj/E=; b=X9bS4vqW9PY9DX6ig1DgQ/7Mq3qkqJGXKW1a8DGb/iZSJd+M7FHcBMWAFVu7bJDGLV VeYeIblw0tG/0mqK1D5IAdQ8nkujlyTFKy0Bhv2Kp0TV6c8uazzQtowO0jcP+rmOr3Z6 EbHNPbZY0Bfvn5c5VLywvXDCJBvAyAVbUcsFWwL2VIirtKT3UkUSPzT2vWklJlIumM4J HVUB2R8kxK1qDbsUHo83dWdtUnRXfw9ThAurj7BRl74h9GebVugiv6+5Ki1zJYI/3MaX LuJSi5hvuC28xTdKtcfBnfEvLqZcSNmiNLoE7YEjfB6FmZmK/Q2xr6e3+bpG4BK7tV9f 8+ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R9opIxlyolKgPJ9ZaPi/fz5XBE5t9vm/e6ZtmMdzj/E=; b=3jo4gJfwnd+ADnT4PDvIA809ZdWcjZ8GenV56QfjauTAbdfYW4ZvR1coEV1Jt7AaZ+ 8rF7RjnUvR6KrqQwdUZOKt3KeCKJk1DHmlGDH/f067S2hV2T42m46rPqotYwnl07bt++ ynHpZg1IMk1y5y/TIMoq8RumXX9FKgg7TMhoBA1o1qc1rnJvWUf00bo9apeDGZdQ3wHw ndsyv+Z4QaCej3Mj3YhV1Q23+sle6Ij49VGJeVEhm4bNIdVi7W5JD/V47v7/RtbK+24x a6HoquO7Ziid4qhCAJxkzUjRaNyp7XPRo+yxjCCVKgwC+74WMjDdAdFse4JCGBbZobyV zJHQ== X-Gm-Message-State: AAQBX9d08x7YEKM4lBBjZ5h7bsWNR3tkoF/a6/fmukJ8Ey+aKo9z3+6q p9yBB5clq0ClqP+UEXa5Y4qIwxmJKa8= X-Google-Smtp-Source: AKy350YmDshDETKjvamKcPaagGUAHDknqcTmnpkqr0ryn+THxSdrXGVmvB1fJ+kUmdHHEcF4kN48YA== X-Received: by 2002:a9d:7594:0:b0:6a1:42ee:1f5e with SMTP id s20-20020a9d7594000000b006a142ee1f5emr9441907otk.0.1680338804668; Sat, 01 Apr 2023 01:46:44 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id b11-20020a056830104b00b006a1287ccce6sm2076477otp.31.2023.04.01.01.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:44 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 12/49] completion: bash: do not modify COMP_WORDBREAKS Date: Sat, 1 Apr 2023 02:45:49 -0600 Message-Id: <20230401084626.304356-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 cf6ff0595f..fd2a43de38 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -65,11 +65,6 @@ # case insensitively, even on systems with case sensitive file systems # (e.g., completing tag name "FOO" on "git checkout f"). -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 790879e319..186c49195b 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -46,6 +46,7 @@ fi local old_complete="$functions[complete]" functions[complete]=: +COMP_WORDBREAKS=':' GIT_SOURCING_ZSH_COMPLETION=y . "$script" functions[complete]="$old_complete" From patchwork Sat Apr 1 08:45:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196782 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAA08C6FD1D for ; Sat, 1 Apr 2023 08:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbjDAIra (ORCPT ); Sat, 1 Apr 2023 04:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbjDAIrC (ORCPT ); Sat, 1 Apr 2023 04:47:02 -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 F186E1EFC4 for ; Sat, 1 Apr 2023 01:46:46 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id ca2-20020a056830610200b006a11ab58c3fso12466998otb.4 for ; Sat, 01 Apr 2023 01:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TBIidAvDgd2+eHMeTXcV+ZdHU4h71AR2peyv4lPjnjI=; b=LZg0oVNrAZPvokPAMO/27yYE5oOlASNY5NP/gCgka675elbRitp7AFe/lIG0E5KoDr TGoLRZv8NhftSieK/yxxo7bX1SOAtgUUZ5pDK76+bTLBRQHDkzNoKnBmWIwZoG5Y5iiB kkmvJ//2Qx9FC6RxWC139QdV0Vz50BK5LQ+lcYqZSYqWh9TTmdQnKQ1DSdae7qKkBNbq NIU+hU49V8gB7HaOB0/08/4FbBKuRfZSisqyOuPQBgWINrq/IsqAro0FsLqpxmYGKEDf YMAHDyPYvcRUahuivlnn59qOjptV8y6R+dEhRaB9sDJ5OVNtqGKZ95PVUK2d5WthAhDm FQuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TBIidAvDgd2+eHMeTXcV+ZdHU4h71AR2peyv4lPjnjI=; b=ktu8EKihrfr1SM8hIuJrjmdNMfvF398P0/kWQo4jSd2+a4qObnWVk6RD5KqIST6nwM d9lLwhrE+74nQq2LnbVG0CaHfwYaL6lloPJjPQOOgU0lGNxuSMl+DpLKdtlzAEBmUxJK oG2V71z1etdBPA49OoNnw177oQDKC64tJyXxStW4VfU3ayw9j5sJHAn6Fdcf/IqwDRLU 71d+EwM6B8rH3TsMffPI2yUyPzFxa2nh4Lqao3PDmgYRBv54VoUMr+Ra6PJsyXmjD3BI crR1uEeaQmT+sKbODaQVZnbgEjISJE8U2eKXapwYNkufRKNK8Dqdvsmb0amDPG5GDUzc 0DNg== X-Gm-Message-State: AO0yUKUbDZVHkXQ1sinds+yf7E07AKdQagSIAEaQkJ7abzPfaIhoCLRK +iv8g+aVK1khJzTcffv3KFLVFFMzggQ= X-Google-Smtp-Source: AK7set/5B8gSez46Enw+6NFmwC5ABSDgVrdAO7kFUrX7XnCtX9HRPXpi0ITGidkf9m4m0R5f3JYlxQ== X-Received: by 2002:a9d:76c3:0:b0:694:331b:80b with SMTP id p3-20020a9d76c3000000b00694331b080bmr12854749otl.33.1680338806058; Sat, 01 Apr 2023 01:46:46 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id z1-20020a9d7a41000000b006a144b97e73sm2043910otm.74.2023.04.01.01.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:45 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 13/49] test: completion: fix currently typed words Date: Sat, 1 Apr 2023 02:45:50 -0600 Message-Id: <20230401084626.304356-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org They don't match what we are supposed to be completing. No functional changes. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 4 ++-- t/t9904-completion-zsh.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 6c3cfe7e5a..bfd8570885 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -486,7 +486,7 @@ test_expect_success '__gitcomp - option parameter' ' ' test_expect_success '__gitcomp - prefix' ' - test_gitcomp "branch.me" "remote merge mergeoptions rebase" \ + test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z @@ -494,7 +494,7 @@ test_expect_success '__gitcomp - prefix' ' ' test_expect_success '__gitcomp - suffix' ' - test_gitcomp "branch.me" "master maint next seen" "branch." \ + test_gitcomp "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 994d57a67f..9221539296 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -125,7 +125,7 @@ test_expect_success '__gitcomp - option parameter' ' ' test_expect_failure '__gitcomp - prefix' ' - test_gitcomp "branch.me" "remote merge mergeoptions rebase" \ + test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z @@ -133,7 +133,7 @@ test_expect_failure '__gitcomp - prefix' ' ' test_expect_failure '__gitcomp - suffix' ' - test_gitcomp "branch.me" "master maint next seen" "branch." \ + test_gitcomp "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z From patchwork Sat Apr 1 08:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FC67C76196 for ; Sat, 1 Apr 2023 08:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbjDAIrb (ORCPT ); Sat, 1 Apr 2023 04:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbjDAIrD (ORCPT ); Sat, 1 Apr 2023 04:47:03 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6542921A84 for ; Sat, 1 Apr 2023 01:46:48 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id y184so18416758oiy.8 for ; Sat, 01 Apr 2023 01:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338807; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uv/84jJ95LUJtgSdw6cyvY019USNM/pNv0RPs8c5eMI=; b=pJHxTspIpIJM8kYcdlNN5r8FdKswgv02OR544aZgywkYQKUAxtCZmzDDzzJUHAf0FY 4/V4DrNmrqPZgvajdpY2DipIQRTU1cneZHX2h1JDsze8tBDFtB8S+28YmB3ZkxoIgsKX LE4ECC3aKawMz2YLsLrXAEQokRcu5IyCRNMb0pwbnLTfpRT5RpEG7p4xKNxjc+lG5X7n ORECnvvG+ntlNqVqTzQIRMx9CghYcAy1P3Q41Kx899JyuSS6mbhtAyk1nHIsL/RvG7Nh 5imPXNFHYWxCG6Q6YKIcsAZv9ZbcIdRjon3de+sPC0YqXgsMIjekcm6isvclPtTGAnn/ iI/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338807; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uv/84jJ95LUJtgSdw6cyvY019USNM/pNv0RPs8c5eMI=; b=vRYcNBvhxjKmk0Bkcm6MaC0BOX+gNuWX2kry5YICmBtF+7gPz7wIRRXOAjBhNdElmw /IppvuwerW3Jxv4LDEXl0CxMEP3nGQt18zJV+JG/KrTpwD+uGtxwCbG4MqZrHxU5T+vy UiOWAhkIGy0duGqe17cXp7yGUJZZ0S5gQH4ePUebcidIpx5OCCSoBoO6A18//AUChnCm sYMYhNtpTxl1OsdOoUAkZH1mLUODJcdDJKn0HMsYQq6BfMpyz2fmJTFCrXK5QY7n8hPi Jt1jPhZeOEOvBxGLsJSXcjVBFv7ZxnDP0TqpGrIOWL04sZtiJ1z6y3Zr0eiAbXE1ruyt Bx8w== X-Gm-Message-State: AO0yUKVWPsgvMuAP11ucVGkBxsZkyI3EA05AEXDsIA67999cXCLEWsgC YPAvnMc/rdAWA/QZpJGXONBhxlE9WYQ= X-Google-Smtp-Source: AK7set/dreFN8P2iCipGEEUdXm+Hyq4TLxOJhWy0ocA1q2x2fbAnOeuzldzc5oZMs29qbitR9RD/HQ== X-Received: by 2002:a05:6808:1443:b0:386:9c8a:ed74 with SMTP id x3-20020a056808144300b003869c8aed74mr13105005oiv.38.1680338807349; Sat, 01 Apr 2023 01:46:47 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id o47-20020a4a95b2000000b00524f47b4682sm1780295ooi.10.2023.04.01.01.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 14/49] test: completion: switch __gitcomp_nl prefix test Date: Sat, 1 Apr 2023 02:45:51 -0600 Message-Id: <20230401084626.304356-15-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org By default COMP_WORDBREAKS includes =, so it's not realistic to test for a prefix that almost never will be there. In bash there are no functional changes, but in zsh this makes the test pass. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 6 +++--- t/t9904-completion-zsh.sh | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index bfd8570885..9d973f21ce 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -565,9 +565,9 @@ test_expect_success '__gitcomp_nl - trailing space' ' ' test_expect_success '__gitcomp_nl - prefix' ' - test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF - --fixup=main Z - --fixup=maint Z + test_gitcomp_nl "branch.m" "$refs" "branch." "m" <<-EOF + branch.main Z + branch.maint Z EOF ' diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 9221539296..ee8cbe3320 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -199,10 +199,10 @@ test_expect_success '__gitcomp_nl - trailing space' ' EOF ' -test_expect_failure '__gitcomp_nl - prefix' ' - test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF - --fixup=main Z - --fixup=maint Z +test_expect_success '__gitcomp_nl - prefix' ' + test_gitcomp_nl "branch.m" "$refs" "branch." "m" <<-EOF + branch.main Z + branch.maint Z EOF ' From patchwork Sat Apr 1 08:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196784 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94F13C76196 for ; Sat, 1 Apr 2023 08:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229640AbjDAIri (ORCPT ); Sat, 1 Apr 2023 04:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbjDAIrN (ORCPT ); Sat, 1 Apr 2023 04:47:13 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D92B2223E for ; Sat, 1 Apr 2023 01:46:49 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id cm7-20020a056830650700b006a11f365d13so11840404otb.0 for ; Sat, 01 Apr 2023 01:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PwPaSzTY7tGNZmZV6NfKWLJjnLy0H1qHBJiH/L9DCCQ=; b=NgO5bp4D2K6b56ML5EkhTvuVen4Dg/zcpo01NUdizPXbkjG2/whGNheGuuAlqmJHsM iYHDpHhkmf8WlEtQKuL4RWWS+WGpyLkt7hLIR/uNbijrjHb7MgDWfkr6QKCk5YgOWV1q 6XU36SdNR/Es0rpQ96WFhMvVvIBp5f+SxhaecDZyUCY2Tp4ro3/MZIcrX7aB62wIbNV3 wJRvINHe2lBil89vX5irs5O9dbIti9ecovt50d3q+0Cmph35r1OkxbEcJ94EJnRG/38R gBI6GaaHcuwADamoOAlkvpRAJVhlZde3+B7ol4BJpS8hXkxd6CX2FHNsBudK3ZY8Yf5B 6i8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338808; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PwPaSzTY7tGNZmZV6NfKWLJjnLy0H1qHBJiH/L9DCCQ=; b=5bIIvKRpuefRYUGeWyueccdDGDRnLZ6eahNnYuji9q23RQdgtS67MvhZXQ0fPUZIOS g2DkDO/2QdX8H1VxSS4qbY2D8lP3TdyR7D2T1El3tjw5h6cyC/N066AyCs8XToBcsSgU FBIfErlJ94UOC14Sw1SueV0Pfs7la8uc0h596ym4Cwgm4ImJnPs1qIuU8SRRZ/LxN9FA MWwn7DG7bgeOxOraDXBDGUj7K8FCSfndJoqlKftXlh1EdUfomoVKf6sVENi/o7AsauR6 81BK8TvGATAusMUvUY6W8H87bT0R6D31AXJDUc5BUyvQ2X/3mgrTmKEdwkQOMJrZmqMu UtkQ== X-Gm-Message-State: AAQBX9eneAAN1/7cR5KaM1a3JPankMiY6X7RBYGnVjTQuJJUK7qWApWs 9wN2Yqj7cK0kz6DXCtBMGn+ZVU0OrQs= X-Google-Smtp-Source: AKy350bFY8sAb2n4krNhTwWY6bfKltt0qBVywOw7VllEYYSWdHfA3AZEuZ43jBGd8U2DNx72iFMoOQ== X-Received: by 2002:a9d:7ace:0:b0:6a1:6e94:4b1a with SMTP id m14-20020a9d7ace000000b006a16e944b1amr4979373otn.17.1680338808693; Sat, 01 Apr 2023 01:46:48 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id j5-20020a9d7385000000b006a14579a8besm2109947otk.43.2023.04.01.01.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:48 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 15/49] test: completion: add run_func() helper Date: Sat, 1 Apr 2023 02:45:52 -0600 Message-Id: <20230401084626.304356-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 9d973f21ce..a2f2f9dc09 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -75,6 +75,12 @@ run_completion () __git_wrap__git_main && print_comp } +run_func () +{ + local -a COMPREPLY && + "$@" && print_comp +} + # Test high-level completion # Arguments are: # 1: typed text so far (cur) @@ -452,8 +458,7 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' ' EOF ( cur=should_be_ignored && - __gitcomp_direct "$(cat expected)" && - print_comp + run_func __gitcomp_direct "$(cat expected)" ) && test_cmp expected out ' @@ -547,7 +552,7 @@ test_expect_success '__gitcomp - equal skip' ' ' test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' - __gitcomp "$invalid_variable_name" + run_func __gitcomp "$invalid_variable_name" ' read -r -d "" refs <<-\EOF @@ -586,7 +591,7 @@ test_expect_success '__gitcomp_nl - no suffix' ' ' test_expect_success '__gitcomp_nl - doesnt fail because of invalid variable name' ' - __gitcomp_nl "$invalid_variable_name" + run_func __gitcomp_nl "$invalid_variable_name" ' test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from config file' ' @@ -1087,8 +1092,7 @@ test_expect_success '__git_complete_refs - simple' ' EOF ( cur= && - __git_complete_refs && - print_comp + run_func __git_complete_refs ) && test_cmp expected out ' @@ -1100,8 +1104,7 @@ test_expect_success '__git_complete_refs - matching' ' EOF ( cur=mat && - __git_complete_refs && - print_comp + run_func __git_complete_refs ) && test_cmp expected out ' @@ -1114,8 +1117,7 @@ test_expect_success '__git_complete_refs - remote' ' EOF ( cur= && - __git_complete_refs --remote=other && - print_comp + run_func __git_complete_refs --remote=other ) && test_cmp expected out ' @@ -1133,8 +1135,7 @@ test_expect_success '__git_complete_refs - track' ' EOF ( cur= && - __git_complete_refs --track && - print_comp + run_func __git_complete_refs --track ) && test_cmp expected out ' @@ -1146,8 +1147,7 @@ test_expect_success '__git_complete_refs - current word' ' EOF ( cur="--option=mat" && - __git_complete_refs --cur="${cur#*=}" && - print_comp + run_func __git_complete_refs --cur="${cur#*=}" ) && test_cmp expected out ' @@ -1159,8 +1159,7 @@ test_expect_success '__git_complete_refs - prefix' ' EOF ( cur=v1.0..mat && - __git_complete_refs --pfx=v1.0.. --cur=mat && - print_comp + run_func __git_complete_refs --pfx=v1.0.. --cur=mat ) && test_cmp expected out ' @@ -1176,8 +1175,7 @@ test_expect_success '__git_complete_refs - suffix' ' EOF ( cur= && - __git_complete_refs --sfx=. && - print_comp + run_func __git_complete_refs --sfx=. ) && test_cmp expected out ' @@ -1190,8 +1188,7 @@ test_expect_success '__git_complete_fetch_refspecs - simple' ' EOF ( cur= && - __git_complete_fetch_refspecs other && - print_comp + run_func __git_complete_fetch_refspecs other ) && test_cmp expected out ' @@ -1202,8 +1199,7 @@ test_expect_success '__git_complete_fetch_refspecs - matching' ' EOF ( cur=br && - __git_complete_fetch_refspecs other "" br && - print_comp + run_func __git_complete_fetch_refspecs other "" br ) && test_cmp expected out ' @@ -1216,8 +1212,7 @@ test_expect_success '__git_complete_fetch_refspecs - prefix' ' EOF ( cur="+" && - __git_complete_fetch_refspecs other "+" "" && - print_comp + run_func __git_complete_fetch_refspecs other "+" "" ) && test_cmp expected out ' @@ -1230,8 +1225,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified' ' EOF ( cur=refs/ && - __git_complete_fetch_refspecs other "" refs/ && - print_comp + run_func __git_complete_fetch_refspecs other "" refs/ ) && test_cmp expected out ' @@ -1244,8 +1238,7 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' ' EOF ( cur=+refs/ && - __git_complete_fetch_refspecs other + refs/ && - print_comp + run_func __git_complete_fetch_refspecs other + refs/ ) && test_cmp expected out ' @@ -1931,8 +1924,7 @@ test_path_completion () # unusual characters in path names. By requesting only # untracked files we do not have to bother adding any # paths to the index in those tests. - __git_complete_index_file --others && - print_comp + run_func __git_complete_index_file --others ) && test_cmp expected out } @@ -2487,8 +2479,7 @@ do words=(git push '$flag' other ma) && cword=${#words[@]} cur=${words[cword-1]} && __git_cmd_idx=1 && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' @@ -2501,8 +2492,7 @@ do words=(git push other '$flag' ma) && cword=${#words[@]} cur=${words[cword-1]} && __git_cmd_idx=1 && - __git_complete_remote_or_refspec && - print_comp + run_func __git_complete_remote_or_refspec ) && test_cmp expected out ' From patchwork Sat Apr 1 08:45:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C112C76196 for ; Sat, 1 Apr 2023 08:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbjDAIrp (ORCPT ); Sat, 1 Apr 2023 04:47:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbjDAIrQ (ORCPT ); Sat, 1 Apr 2023 04:47:16 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3451B22910 for ; Sat, 1 Apr 2023 01:46:51 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 6-20020a9d0106000000b006a177038dfeso3969020otu.7 for ; Sat, 01 Apr 2023 01:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338810; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L6P/MjpIc+weSsTibcyDqrbPEc4Eoh/Jp2wlHKqBOjo=; b=odku8DP2kwk6D8UyUMOsX/0lOFl21QWkeTveLNaLQxFAF0W1PR8OIey0YMNTvKhzO5 xagvIo4jCzvV7KJ1b1qha4hfzAFPriNt2oH6TH4jfuRBK6xlMMgjBiR5HmC43eWURJR3 cmWkzqOwtTwHcW/+zFXRj07AnB3YojvLXZsqlqJU4MOVYKImorahmyFPcVgDw6VIn73e Wlc6+dstZdsGjn2AcRINQfaWvnKA52vSppZFktfhcbs6wOeUMLMxUwLm15xB3YKsuz+7 ZYvucP+3razSzQV8FSoaVgrjJRW6xpdGdjoTLfBcOptZ90xUlsA+RjfWf0JNFfkYdqEx Hwhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338810; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L6P/MjpIc+weSsTibcyDqrbPEc4Eoh/Jp2wlHKqBOjo=; b=oPIPAc3KRw6+2XcFQONOjYI8P0dpmBU41YfH4UQLHFbqT9zwa+KIfzoFXD65khZD5x a7MMRcJrRR460Xu+0vv4sleaat5GNnfDifjcTyAFOexxUA0lPttXUKLvyEmz9Vqiuhen GDG+3ZrOKcmi2kFv4TgSvevtcWLIYh9dQydEvsb0HelH6t5/1Pr6r+mVPT8UNBdo/gWy MX6wcNu7k4q+u7GNMNueHkSQJzR5PJ64ywZGBGZNKESh/H00Lni83Wf2Z7BNkE23YfO/ n9vKxS3W2drglQgbDnYyR8F45Nu5IkcmEgvS36aWmAPiFdyEgVKZcLxOh1Ats2P0kOoH T7Ug== X-Gm-Message-State: AO0yUKVuk7mYOGnyJeq2aDmyeHEnwM610cULvueVGTFg8dIKjGVIsQQZ P7O54MJ0dmFCIPHPMO/ILq5G0tQa1Is= X-Google-Smtp-Source: AK7set+l5mAoCk5GpmXWbXr8JP5Tl5e72VyNMFcoQvI+6ybmd8g/dIb0RQJ4KFYefYI/yl0KXO6r+Q== X-Received: by 2002:a9d:6e90:0:b0:6a0:d291:90b0 with SMTP id a16-20020a9d6e90000000b006a0d29190b0mr13623032otr.13.1680338809978; Sat, 01 Apr 2023 01:46:49 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id o204-20020acad7d5000000b0038986062468sm1875526oig.7.2023.04.01.01.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:49 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 16/49] completion: bash: remove non-append functionality Date: Sat, 1 Apr 2023 02:45:53 -0600 Message-Id: <20230401084626.304356-17-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no point in setting COMPREPLY only to override it later, and in fact... we don't do that. Therefore there's no functional difference between __gitcomp_direct() and __gitcomp_direct_append(), since __gitcomp_direct() *always* operates on empty COMPREPLY. The same goes for __gitcomp_nl(). This patch makes the functionality of append and non-append functions the same. No functional changes. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index fd2a43de38..7554c3aeb3 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -318,7 +318,7 @@ __gitcomp_direct () { local IFS=$'\n' - COMPREPLY=($1) + COMPREPLY+=($1) } # Similar to __gitcomp_direct, but appends to COMPREPLY instead. @@ -470,7 +470,6 @@ __gitcomp_nl_append () # appended. __gitcomp_nl () { - COMPREPLY=() __gitcomp_nl_append "$@" } From patchwork Sat Apr 1 08:45:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB542C76196 for ; Sat, 1 Apr 2023 08:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbjDAIry (ORCPT ); Sat, 1 Apr 2023 04:47:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjDAIrR (ORCPT ); Sat, 1 Apr 2023 04:47:17 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF1121AA4 for ; Sat, 1 Apr 2023 01:46:52 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id q27so17676876oiw.0 for ; Sat, 01 Apr 2023 01:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eLw3XIa4ivYcbOW7gAJJgm20Ajzxyvgv1ffaBeSDHyA=; b=geBJz5Qw80IPWljov8ch++eKb2VZ6XOcYRIsH85qTPeDuzoQIu+kVpckH+QFXAyaLt uM5df/OIpacOmqw4WvFuXmQKO6lLuCVOofIVsAUjCZrshRVMX5GiZRBZkW2+LEn4zhL8 58IzBgr0jlkDH2nyxTonPgfzS0WtdHeha0jJxF+FjIZtBbtKwUd3nshF17MTGztrg3IP xWjrRCk805rHzo4S9B+EkSNNoikpbFBPO7zR/aFlVdeTLbSwqNdplfwnZL63O3XI66+S IRpe/0tWdMKQcHbwm01JNLvxikaxuWMbqJr95am0PAAswhXmo+19Cpb+6dfOKdfZojAI wXyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eLw3XIa4ivYcbOW7gAJJgm20Ajzxyvgv1ffaBeSDHyA=; b=rNa+eL2u+vYTwpP5pa9nVJa/nqukVARSJBXvucq5J9oDleNzfHZU47r8XltS5mzqBt jJAk8oMTbjTBgFscY0S0OMBBr9KcelrdXz9ycuk67PBIAafUHUAED0Ovy8cCNH73FsCp 0agqm6z16zMbIxkPiVkCPsJMJ9jEPFWwnb7SbkVAvsj4jC2sruDQYiq5IsQtmHGMAYj9 vDUa6jH2RWwuJbqympjdIXTszSHVGHpDxuBsD+DCorQ3PFI+ieXlTVXuA5eFkjf66Uwj 35tGPFZi+p9blHvLxTunelQUc4ciVTv8b4chsA/cLEif1YbUPlOYiGvFuIqTir86Doav 0ywg== X-Gm-Message-State: AAQBX9fkdnwOwM4Z1QiOE6RN4s7Irmk5vTXpd3KsnClkZBGBE3snVVZ5 cY4xqyI4PaIZSP/7dVfaq851eOeM0VQ= X-Google-Smtp-Source: AKy350aifZMKdJCi+Irl/oj2DJ+hsYOzGNOjwUFBaPC/Yz5CY6MG2bycguH+upuyT0RIV1al8pzALw== X-Received: by 2002:a54:4411:0:b0:389:8232:e215 with SMTP id k17-20020a544411000000b003898232e215mr3289549oiw.8.1680338811499; Sat, 01 Apr 2023 01:46:51 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id bd1-20020a056808220100b0038755008179sm1831156oib.26.2023.04.01.01.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:51 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 17/49] completion: bash: get rid of _append() functions Date: Sat, 1 Apr 2023 02:45:54 -0600 Message-Id: <20230401084626.304356-18-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 7554c3aeb3..3c8f907d45 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -307,8 +307,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. @@ -321,19 +320,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[@]} @@ -451,16 +437,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). @@ -470,7 +448,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 @@ -871,7 +850,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 } @@ -2670,7 +2649,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.*.*) @@ -2720,7 +2699,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 186c49195b..b31c9894e4 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -122,16 +122,6 @@ __gitcomp_file () compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } -__gitcomp_direct_append () -{ - __gitcomp_direct "$@" -} - -__gitcomp_nl_append () -{ - __gitcomp_nl "$@" -} - __gitcomp_file_direct () { __gitcomp_file "$1" "" From patchwork Sat Apr 1 08:45:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1492C6FD1D for ; Sat, 1 Apr 2023 08:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbjDAIr4 (ORCPT ); Sat, 1 Apr 2023 04:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbjDAIrS (ORCPT ); Sat, 1 Apr 2023 04:47:18 -0400 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC5C721A81 for ; Sat, 1 Apr 2023 01:46:53 -0700 (PDT) Received: by mail-oo1-xc32.google.com with SMTP id j12-20020a4ab1cc000000b0053e6062a9eeso2335382ooo.8 for ; Sat, 01 Apr 2023 01:46:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338813; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6lSQdi/dPLdQF8j9Encu99pooeEVxX8fmEDc/gqBk6c=; b=f0mIrbI0b8IXn9YKGxZTC0jXH1ZoVu2K6Mq3Y0mwd/EWHxejOc2oeMCwUhTNXCixIx t+PJVp3gwMnSISJLg5bdY9lXgXORZ/Stw6p92n5uW7V/DY0cbULHTqQhh9yK5flkV4kZ nIJq6f1fgXeg9Gmni7xb74w4v695qPI68tzGDweoZa+I/LlQt4LkN/XTdQ3NAkUR16vK QJsg4dm4Oly6MXkqUm+s3Y8Dit+iowF4975p+37oBoXr45k19VjTuU62NNR4bDzN2N0d NSxHk7McWJbf7Gp/dotKM3/XNn0lEytUW21NlAeKeYijgMnJ3XA+NDoqcYh1QXndAOK7 TFWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338813; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6lSQdi/dPLdQF8j9Encu99pooeEVxX8fmEDc/gqBk6c=; b=GVK5/FW69evpsZUHO/byx248YqrlDaZ72wiDRgZDaRCSQRt7XB5eUfGu712AxR2scd lYjDAT0AFNBEIO5jPi+CxuQUCGl4GzhAM/KMyWxyqIOXJD0OXHm0EauySzRg9FLda3QP 90P4FWrAVPqbCiYeNeNUU/6HxoQGWFSHcQ52HA5fyVqDouOVuOZtI4kFoJC12cqpd9tw /uxxsrNj0Ey7r+e5RcEkpXKvTPaa9tQiXgLw2dG1yKllcuSjVHba58n0LVrsWiwStrg1 3J6wD4lcPD9mpzUDB9MNpPlgccFPPndUXC5dKxST/2qrlBfkwHKgMvH/sI/5GyEt4+9Q umgA== X-Gm-Message-State: AO0yUKXGmsG023ZJzR+p7QzA+prlSuoOZgAYuNgq+hYCD3cf/JaRTN6A tXQwqXJDMt1UiFsTyRqa1bdH3l9HQZo= X-Google-Smtp-Source: AK7set8Vy0cowDWxqFm7woAzS8+cyos6Zv5K212JgBwN90Nd6IJJV+zck4gVssVF4u+CwOQhqbYzJQ== X-Received: by 2002:a4a:d64a:0:b0:53b:4d59:4058 with SMTP id y10-20020a4ad64a000000b0053b4d594058mr14920773oos.4.1680338812827; Sat, 01 Apr 2023 01:46:52 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id v184-20020acadec1000000b003871471f894sm1844538oig.27.2023.04.01.01.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:52 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 18/49] completion: bash: get rid of any non-append code Date: Sat, 1 Apr 2023 02:45:55 -0600 Message-Id: <20230401084626.304356-19-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 3c8f907d45..98eb7c9604 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -320,7 +320,7 @@ __gitcomp_direct () COMPREPLY+=($1) } -__gitcompappend () +__gitcompadd () { local x i=${#COMPREPLY[@]} for x in $1; do @@ -330,12 +330,6 @@ __gitcompappend () done } -__gitcompadd () -{ - COMPREPLY=() - __gitcompappend "$@" -} - # Generates completion reply, appending a space to possible completion words, # if necessary. # It accepts 1 to 4 arguments: @@ -449,7 +443,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 @@ -462,7 +456,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 Sat Apr 1 08:45:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7AB2C77B60 for ; Sat, 1 Apr 2023 08:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjDAIr5 (ORCPT ); Sat, 1 Apr 2023 04:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjDAIrT (ORCPT ); Sat, 1 Apr 2023 04:47:19 -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 3D939191EE for ; Sat, 1 Apr 2023 01:46:55 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id x8-20020a9d3788000000b0069f922cd5ceso13144138otb.12 for ; Sat, 01 Apr 2023 01:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OpignU75XOPRKpUUxUZsEhg8hoR4DwwwSQC2GnPLcmI=; b=fRaBzJaxvMyYj9YKR61BiWYtVdcavfK68xXiJFv1y2tX68DKY8YP4p3fCkO9nEFiRD 1RhvGBokUZRDNWnhEvI15Hm76QNmM4T++PhG5+PPHmlTggruDNhvQqZGW5SXYusSbk/N i0pr65ov9fsbb2LzW9pM47EtQ67T5K/OXnKlMmyJUALsOcbH5L5dcWVqSe514gjHsOZ+ fa2rD30YV7NwDrisMAKQcIe9QuvOd+f9VUQuZo3JA3Pt2ouNd8004B8LMtkkrcvDRrjR 1WHtWjEM9qvtdTcitISNQKdM0AzNS9xcSkukeufHiDp5u3NN7/Jq4Hev6XXJPNoG+Qoq okSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OpignU75XOPRKpUUxUZsEhg8hoR4DwwwSQC2GnPLcmI=; b=K5Qc22nDWHmQ59Q08EFU9/5XpE2419qGQwFJXGY+6uQ6eaAXnxTcKEzq9ePaCz3Wyk 2hNh+oapZ7JzzWWJ7UwrYAAeU1dlSqihe69ww0f8Ie+zgNhGF4AxVxtPoENHE1AzU+5J 8YVsnsWGz9Gu71Wjk+k6Ye2DIgPYUp7HXqfd+76Wwx8SwK0h6ajdjVfdyvmNBunN+7+v Lsr561JqsuAthS25UfZfmuvzmLnBONqkc4ljCNmSsp++hqfnoLlsw/MR1OhSmn9tQMU2 332oQbePV9evfnih004Rfwuehak8WydIxm4ZkzLISBebXXX84XlQSd6cUX+x97Ubl2v8 h2mw== X-Gm-Message-State: AAQBX9cw4mqOyyO4Mki5x8omHDzNJfc2pWqMb2x7pNM8hyh8gCxye0s9 4dfWXdLnXeovIwzyr1n6Rp9Ybqv9xQY= X-Google-Smtp-Source: AKy350YCip4VdEahNrQ8KFpdB0twagLBuvUNmOc/u/iqk/sH/eEzIRvVh1UMxfMv/yPzSSUEPnw3Xg== X-Received: by 2002:a9d:4f18:0:b0:6a1:20b9:34b6 with SMTP id d24-20020a9d4f18000000b006a120b934b6mr12872225otl.0.1680338814356; Sat, 01 Apr 2023 01:46:54 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id d11-20020a9d5e0b000000b006a3170fe3efsm322275oti.27.2023.04.01.01.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:53 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 19/49] completion: zsh: fix options with arguments Date: Sat, 1 Apr 2023 02:45:56 -0600 Message-Id: <20230401084626.304356-20-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 b31c9894e4..0619d05d34 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -210,15 +210,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 Sat Apr 1 08:45:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEC37C6FD1D for ; Sat, 1 Apr 2023 08:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbjDAIr6 (ORCPT ); Sat, 1 Apr 2023 04:47:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjDAIrT (ORCPT ); Sat, 1 Apr 2023 04:47:19 -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 B838622E89 for ; Sat, 1 Apr 2023 01:46:56 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id bj20so18419301oib.3 for ; Sat, 01 Apr 2023 01:46:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TUPD4wT3yVNFqeYKeak3J9i5PQROoZ1ZYgYzlhb+u2Y=; b=TBV24KxbjTQIzhk3F/2K52w+lomqIDc8eVGsV3ePAlIu1iLEiiGhwbKALrrEMAodd9 oKDkaskdm9ddgMD+w+rJQq46b4y5qijibj47oKYOvrbYPxEoNfhx7gLx2Eu5Ku0mqc+A 6UcC/580m0D7sxmykWRaxV6LndlgaW8e4ejCo+uSJCMU7M7jm5q0/CKYzwS1uGPh1nlm zPGqPf04z8bfBL7HkE/3kJNDY2TfAw3XpRG9/5cvTDYPD1Hl+Rq9lUTFc3nUjh6+NjKJ mb99Exvb5RjcdRQl9AUydHEN1x2qr1L67QdpaNXJVhjGszmGPOcOcL4G0wbZS9temtM4 7WfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TUPD4wT3yVNFqeYKeak3J9i5PQROoZ1ZYgYzlhb+u2Y=; b=K60etGIpA44TIC1DhYX9snOCr0eR/9DnKAo4OiGJe5QiFsnDxZWAPNbD9FU4ow5tNd bKGktXb05urXeEeYHJP9C+wW/AcTMco0ohXa6YhfjN7+Ybcghul72fFMJjNd8I0IvQ/+ vUhEJ+vYC0Lv7WsASUt0YD78hyN/UxTNSPqEuy+A5DoyBLUcr3ObI008h4t/AVwIJFCD rVhC+Y/lrrQlea58PmPAGa+bne0UwBtDKGe2MdT0RBP3/5PIhuITN+oixEUvj5CoIqW/ 3Ut+dEW6hmnvy2yKVm3xulz1bdlaJexhPiuJj7LIcpyb1G9EYBYQ4EQ0BrEKWVT5tPNt 8xSQ== X-Gm-Message-State: AO0yUKWATNRKFkaq0+sgUo7Z3rl1YrzIgdse02cRgjy1QDbcQh6U/zRR NpNnZA4ERdCqzB3CRLBd2cwrTYk0tVE= X-Google-Smtp-Source: AK7set+DnWsyCVznOeY6mEeb6XPM8tLi3bfAkI+40VIz3Ns+XTDi2o9r7WQ5XpuMpvzAatyMeay8mg== X-Received: by 2002:aca:909:0:b0:384:102a:46cc with SMTP id 9-20020aca0909000000b00384102a46ccmr12462491oij.58.1680338815667; Sat, 01 Apr 2023 01:46:55 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id q189-20020acad9c6000000b0038756901d1esm1860195oig.35.2023.04.01.01.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:55 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 20/49] completion: zsh: expand --git-dir file argument Date: Sat, 1 Apr 2023 02:45:57 -0600 Message-Id: <20230401084626.304356-21-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 0619d05d34..b49bce51ac 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -240,7 +240,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 Sat Apr 1 08:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E28E8C6FD1D for ; Sat, 1 Apr 2023 08:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbjDAIsI (ORCPT ); Sat, 1 Apr 2023 04:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbjDAIrU (ORCPT ); Sat, 1 Apr 2023 04:47:20 -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 3D1342221A for ; Sat, 1 Apr 2023 01:46:58 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id f19-20020a9d5f13000000b00693ce5a2f3eso13139694oti.8 for ; Sat, 01 Apr 2023 01:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5kVFZsditD9fGYuV6a0EUyPpDwMhqyDg7ZIpT2I+SDs=; b=AjR/i7MxMW1smgwruE/PZLIBxSjlr0c7hj9cbYjmB8anTKlr8oiBYGTDpmZdV3wpRe YLmDLCP0K5rixz+OmeJLWhZ+2HQGj+OQ9oGU2r/Lexew4DaahEngLVajHWfGWCyVyqhp kADqBF3W+AM1/FXjHkODiyqBYeVzxRlLVViqi9QDLgl92V9sGcoRC8k5FF2B7yA0mtFL CIa6yy0vAYS2BoaLCKVHe6IE0VU623LiZ2STXrCLn47nw9WHqGZe5k/E8/V884xF9Ssd hkC15oetY4/wTk8fQndnHCJS2wVoe2g89to8SFaba2caMkCMJQP919harMZhBGZb0q1n SnHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5kVFZsditD9fGYuV6a0EUyPpDwMhqyDg7ZIpT2I+SDs=; b=GNQpqpPYCRmv8sCegbSbOG4b7CymVa/gwCTCDxkLS4jGTGZbgtSzVMyGnfIseIDy8/ dbzc+0AmjZrZj++scLi87mOWIw9izp+JQTpZWOmCe5hrB6T2Zo/RlNd6j/WBLUzW1t7Y Tc7wdGFnir3LYOud/aKBGdKdOYWof7jXCPP75sde8wtaWRahb3lEv+9qX8WVc6stshdl y0WtTrSO77kmLpSda0RaFS/FiRb0VmQoH9O2ThoEuya7odkArtTuHGN1lJrKyK1OUDWA xYdc0YYF97yerOzgGqk/JiOsrgrXT9tGto2TnowkJLaJMAxDHCD1VWt1QvO432Y3jyHp 5p7Q== X-Gm-Message-State: AO0yUKVAvKukXCxGmjmVjftTzTxVJdU+6upVpuaJbQGAiRz31VV3cod+ btLfksvqQ0XJ1EmnTcDwuslwLoq93iU= X-Google-Smtp-Source: AK7set/jGQLuyj7xDk5RLzblIRMtgpPJSC1CjSwcbYR5lYQCiZRPGBUHNMbtit8HYYCAMycIpehYxA== X-Received: by 2002:a05:6830:168c:b0:69f:7b9b:473e with SMTP id k12-20020a056830168c00b0069f7b9b473emr14749566otr.38.1680338817098; Sat, 01 Apr 2023 01:46:57 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id b22-20020a9d7556000000b006a305c68617sm733220otl.53.2023.04.01.01.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:56 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 21/49] completion: zsh: add support for general -C opts Date: Sat, 1 Apr 2023 02:45:58 -0600 Message-Id: <20230401084626.304356-22-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 6 ++++++ t/t9904-completion-zsh.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index b49bce51ac..9e821eab9a 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -206,6 +206,7 @@ __git_zsh_main () { local curcontext="$curcontext" state state_descr line typeset -A opt_args + local -a __git_C_args _arguments -C \ '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ @@ -221,6 +222,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 @@ -243,6 +245,10 @@ __git_zsh_main () __git_dir=${~opt_args[--git-dir]} fi + for x in ${(s.:.)opt_args[-C]}; do + __git_C_args+=('-C' ${~x}) + done + (( $+opt_args[--help] )) && command='help' words=( git ${words[@]} ) diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index ee8cbe3320..27f5b42318 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -863,7 +863,7 @@ test_expect_success 'checkout completes ref names' ' EOF ' -test_expect_failure 'git -C checkout uses the right repo' ' +test_expect_success 'git -C checkout uses the right repo' ' test_completion "git -C subdir -C subsubdir -C .. -C ../otherrepo checkout b" <<-\EOF branch-in-other Z EOF From patchwork Sat Apr 1 08:45:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E80C77B60 for ; Sat, 1 Apr 2023 08:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229610AbjDAIsJ (ORCPT ); Sat, 1 Apr 2023 04:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjDAIrV (ORCPT ); Sat, 1 Apr 2023 04:47:21 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1664423B4B for ; Sat, 1 Apr 2023 01:46:58 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id y184so18416901oiy.8 for ; Sat, 01 Apr 2023 01:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KNciQLgxXJHUBvXK16weR2Wzv1AKn+AF1Fb5rUXeHcM=; b=Id2Wfts59zFPRSqMA0pMESOcpHXkxkQoYyaJ9uER/xVJ40Ue+Vcg3uSQ8cmEs5Z/Tn 3Jfn5ZIwB3nG4Zf1hMi7JUbGw2StwA1ohJsJHqRX+edt1kvvyDy1FPqlyMoqqi96YXzK 8oGuuG462rdLHC7lpBSc5JV+v4Ev6FNd2apatoYTCe+ioaVmDXx97fJVMZEC1ez7acNv x/NTDWWnDLephlo18SX/K+jk7uF6Ui5lml0hBoE/KqLVYQKV5BTX71KSNxY4z5e7A/KH C/RwuJxwk4D2u1dz0Z3HrXAFhfLWk+HZKXKb5OkiyDFbDKNkB6VHvrvHc0wWtOwroEoU COaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KNciQLgxXJHUBvXK16weR2Wzv1AKn+AF1Fb5rUXeHcM=; b=nf14hGHSMbKhRNB7UVn8Pte1RuCYvn3zzyb/+sv4EGtTHkakGbkMCOD2L/hw7a3Dsb glXLn7XHveZVVTvoObgN98jWsY3iemaj0nl7nn+V2xUG14vEHhWzzrPtlsj+1ai8fbo0 C83BoNK3CKm4r649mSjM6hfriOYI4lndyt0MgWkJN/o4zLb+vHwWy1eUTDEweQ2C5nx1 8r6iGXTzOceLFJ3wtH0H2vxEawQlj+g+KE030b25X3pKJpyKZQhIHNCt5GszGGQHGBDz WyFwiViIx5WTIA2cH4fzEezSj4LSDkoPNO/PFR9afSi8M5TVQhfB48OD/fH0epnbz5BB yVoA== X-Gm-Message-State: AAQBX9cI5hRozhsexnf5UIv/x5x99lVnxGq9igIbkQf1iCOmVJeXBmlW OGBiCHWu6jODd8SLV2llGPIqwsSzwNI= X-Google-Smtp-Source: AKy350aQHPtL4B4mb+xd9GOzI0i+JqSiOVH3kZKqtGdmYlhHHLmgm5YCwxWTSMmi03tgK/9fBKF7Qg== X-Received: by 2002:a05:6808:f8d:b0:389:50f2:4ac0 with SMTP id o13-20020a0568080f8d00b0038950f24ac0mr9313885oiw.33.1680338818359; Sat, 01 Apr 2023 01:46:58 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id s189-20020acadbc6000000b003874e6dfeefsm1860897oig.37.2023.04.01.01.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:57 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 22/49] completion: zsh: fix for undefined completions Date: Sat, 1 Apr 2023 02:45:59 -0600 Message-Id: <20230401084626.304356-23-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The parseopt helper can generate the completions even if the function is unspecified. git version -- Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 3 +++ t/t9904-completion-zsh.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 9e821eab9a..88157b0867 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -136,6 +136,9 @@ __git_complete_command () if (( $+functions[$completion_func] )); then emulate ksh -c $completion_func return 0 + elif emulate ksh -c "__git_support_parseopt_helper $command"; then + emulate ksh -c "__git_complete_common $command" + return 0 else return 1 fi diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 27f5b42318..472b02d3e6 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -1034,7 +1034,7 @@ test_expect_success 'completion used completion for alias: !f() { : git X-Patchwork-Id: 13196792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BB48C6FD1D for ; Sat, 1 Apr 2023 08:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbjDAIsQ (ORCPT ); Sat, 1 Apr 2023 04:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbjDAIr3 (ORCPT ); Sat, 1 Apr 2023 04:47:29 -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 B6A8CFF1A for ; Sat, 1 Apr 2023 01:47:00 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id r16so18347126oij.5 for ; Sat, 01 Apr 2023 01:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=McaFQALs4PpVc83rGiMAdmY7uQ+bWdI+3Lqnbd3QDyc=; b=YDHr1xoqw+0LdUnTqAXDNOpZs153aO/3uMbWmcZKooIyMD+LeI+OErLOKyjDUL6Bt8 k5i7/P48plWQCWaKRmMSQKvVtT2RT6hvIOc2dzpH1+IWCrLPYgLA3Zw/5zlcqCdSbWw/ uNZByj9JuDZbOR+hqkiuldP7zYoEQJR2Hq/cL8RanS5oSijaMYokv0xdVzcmgytmdnaY DyrhP4gR4rE2SH+/9HVPBAx2MjX6ChdN5FbHiQPOZMBmSZoc8/MnOo6jMerikrMN6XyO klYm2xHtjMWjZ0XAAfayF0P29OwIujRK8Ff1E/dDi/XqIdG6Dy+qI4ffE/EPbLkCfxCF MLcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=McaFQALs4PpVc83rGiMAdmY7uQ+bWdI+3Lqnbd3QDyc=; b=Yjxm6DdstUcglAS7mrN8AbZNuI22JbSxKCIhu/QllXUhKr6QhdV14wiPOUeiIBbnBf sSjXmGjzx/llEe1PFLNtnGdpaM0ykrGYUm0KdAK70sMDFAbBiPwjvQo4cP+mAafKO1fN b5qBkhWAGj2Ez4CPluwPJ6/Xoi8JRdD0i2GTuMyTKRiLZ8SREgo92/A5Nv4A94UQqCIW S1kxFEs1JeRmJu7n0LIBidVt0erwbD9yFomw1wO8Eq6Nq5RX74S8yLGTrQmpDNYBmu0V 3GuMjn5KTl1ju8dp+yu5WJav+zhvu8XtGPkBzuAatBCVdl6UvPkys9lMq9hNdsikdcSU bl+Q== X-Gm-Message-State: AAQBX9fgWogkqd7Ovai31zSo6QVRJpOEXAMGoTsM4fPOJTxH/2O37Cpq gddicu3HLx2WNPJkwBR4FElTIGF4NUU= X-Google-Smtp-Source: AKy350bMZJXq4cKz05dUyswIVv7946NB+PO5ps6fjQ6vbYyKpK1zseWT40stXplYvc4yYrsVWqnLcw== X-Received: by 2002:a54:4701:0:b0:389:70b5:abf6 with SMTP id k1-20020a544701000000b0038970b5abf6mr4113362oik.19.1680338819794; Sat, 01 Apr 2023 01:46:59 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id r84-20020acac157000000b003845f4991c7sm1846402oif.11.2023.04.01.01.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:46:59 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 23/49] completion: zsh: add support for general -c opts Date: Sat, 1 Apr 2023 02:46:00 -0600 Message-Id: <20230401084626.304356-24-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org So we can specify configurations. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 5 +++++ t/t9904-completion-zsh.sh | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 88157b0867..a7a5efbd13 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -226,6 +226,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 @@ -239,6 +240,10 @@ __git_zsh_main () let _ret || break done ;; + (config) + compset -P '*[=:]' + emulate ksh -c __git_complete_config_variable_name_and_value + ;; (arg) local command="${words[1]}" __git_dir __git_cmd_idx=1 diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 472b02d3e6..1b18bf5363 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -1090,7 +1090,7 @@ test_expect_success 'git config - value' ' EOF ' -test_expect_failure 'git -c - section' ' +test_expect_success 'git -c - section' ' test_completion "git -c br" <<-\EOF branch.Z browser.Z @@ -1105,7 +1105,7 @@ test_expect_failure 'git -c - variable name' ' EOF ' -test_expect_failure 'git -c - value' ' +test_expect_success 'git -c - value' ' test_completion "git -c color.pager=" <<-\EOF false Z true Z From patchwork Sat Apr 1 08:46:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F69C76196 for ; Sat, 1 Apr 2023 08:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229548AbjDAIsR (ORCPT ); Sat, 1 Apr 2023 04:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjDAIra (ORCPT ); Sat, 1 Apr 2023 04:47:30 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E21271D87A for ; Sat, 1 Apr 2023 01:47:01 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-17fcc07d6c4so11578876fac.8 for ; Sat, 01 Apr 2023 01:47:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nN6l6aoWwNZ205R8J1LlSn2kSK2ZuQL7AA/f5iPR8j4=; b=BqlyiipGw5yJsIwf6G2KKSStP3QDFVr1APvLYfvOUN7PcrWoHyliwBPhYEGN+g0MJV gCBMObibiyNznpRWSF+aV8Vy/K37Spz3GtFTJUaKCenYe4rbsAt3UYQId9LTuzPm61rD 5LieyrVVY2xMULIfU9yYN9hcxAh/4adnsPg0jUd4OR33wMgXhkImVnatIqFiQKvBY3Ks Oe09g7i6FZzFWWWD4YraNruBvfiEgZhJ0WFkgIItfGHXvtjGnAwI2yDcvMkN+fOhWby3 atLcbT64Uox2qgOrkPYmxeTGnOSnrQGs5jPLBH6k8uQRsCj7rkK0e6Zb+oVHpOKLvYSu S/QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nN6l6aoWwNZ205R8J1LlSn2kSK2ZuQL7AA/f5iPR8j4=; b=rLPrVgDERxsjUZGV+7VlwC/eXUYNZakHxNQg2GcYvwZFuYNvbeQF69EPrLDEWwNj/1 AvzChdLhmmwsw0AQcZUXSzYbs/tiGPjjSSYpuBgZtURaSgzi3+dFx7OdOMSTUVVtKhwJ kD1+m4Pw3pzXsQfpiub1DuIN+WOIGPpp/Ar3Vf4Manwl6IVlMeL17voNRNTfUJT1/Umr Qx8ta/FKKDwdhU7LWHyI4WXgvJkO/G3bS7ZOtDUMGejMRDWwUspm4lxeka9TSD1ZFqeS +mtZwMOoZ00qpDhfqpmoTXXbo7opZCMhCczVgujUbxxP7UF0mQkblsy1rbuA6ChpMzzw LPLA== X-Gm-Message-State: AO0yUKWCMLb7unCNAHFB45f7nJcPVVERxHpQsDXYDg2Upq+T7bJzTuJ7 hc8oUczMeQaB4cCCx9I79GfHXDoo/WI= X-Google-Smtp-Source: AKy350bqfJmo6BlgdYrCnol+t20h21FEkGV4zWgrtN+PlwKst4OrVG5K6NMLSQWthDXQ6Wlsd9pr4w== X-Received: by 2002:a05:6870:c6a4:b0:16e:8edf:42be with SMTP id cv36-20020a056870c6a400b0016e8edf42bemr19837845oab.50.1680338821162; Sat, 01 Apr 2023 01:47:01 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id zq42-20020a0568718eaa00b0016b0369f08fsm1736454oab.15.2023.04.01.01.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:00 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 24/49] completion: zsh: fix extra space on foo= Date: Sat, 1 Apr 2023 02:46:01 -0600 Message-Id: <20230401084626.304356-25-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Upstream commit e1e00089da fixed the issue for Bash, but not for Zsh. When we are typing configurations an = at the end signifies we still want to type the value. Can be tested with: git -c log.d Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 2 +- t/t9904-completion-zsh.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index a7a5efbd13..038ab30869 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -87,7 +87,7 @@ __gitcomp () fi c="$c${4-}" case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac array+=("$c") diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 1b18bf5363..4355552434 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -1097,7 +1097,7 @@ test_expect_success 'git -c - section' ' EOF ' -test_expect_failure 'git -c - variable name' ' +test_expect_success 'git -c - variable name' ' test_completion "git -c log.d" <<-\EOF log.date=Z log.decorate=Z @@ -1119,7 +1119,7 @@ test_expect_success 'git clone --config= - section' ' EOF ' -test_expect_failure 'git clone --config= - variable name' ' +test_expect_success 'git clone --config= - variable name' ' test_completion "git clone --config=log.d" <<-\EOF log.date=Z log.decorate=Z From patchwork Sat Apr 1 08:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DED8BC6FD1D for ; Sat, 1 Apr 2023 08:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229529AbjDAIsT (ORCPT ); Sat, 1 Apr 2023 04:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjDAIrc (ORCPT ); Sat, 1 Apr 2023 04:47:32 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A7B5F74C for ; Sat, 1 Apr 2023 01:47:03 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-177b78067ffso25638157fac.7 for ; Sat, 01 Apr 2023 01:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dwSB1xBD/+SYbKX15/UH6WwLA+mR6uX0LqTI2v5JKmo=; b=ZDOllOhusZ9gCKAWWPpfW5VlIKfvydCT3osHKfnnwHG42022lDSvgafG4idzNdrsRu 2ySeQ612R6pr1Paru3wlsDnuyXY83yCAWa3Nql8BsjprhiKZIZxZyb/YCdhp1qO3iNJP ca1pRNBq/UM/6Wp90EQWATSS7T8b7PcuedEmmvzec1tlccpFh5VEViUzttq/Gm+7kCn/ wQVeKtL3H1TMpJ+dt+OqFLTd3lJHczzQA3eOTpsEuVFoGzMIlbPrXnPFDNVT0XBzhUb3 5pSOkqhO9iI40hwm3+m+ouiuXyGtdVnzT0AFtxNFru2uY2ca/I1MY2cpWlfiR1P0OhvZ ETGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dwSB1xBD/+SYbKX15/UH6WwLA+mR6uX0LqTI2v5JKmo=; b=qdRMbBrmuQyBn3+4xn4k/48q0v+U6W1DXvlKKk/5CGhbJtSM2/LAbdVa6shWKRFUdn e2peUxaOmondd1BV9FUPI9C5gAfEFrWgBNtqSTz9aJCZc280iSbnwsa6twU9fMmw2LHQ ZdQIokrZOHAPeIeyvl+sz3vhTqBgDLHvNy/wKAE+f6MClwoyrYZ/vN04KFeq/rroKwl6 18CaY/eCPFmEGv/903nWrFt6YT4UdA0Pzm9IF1X0vYLLwS8Mc6zv6HZSg9F4AAI6V77f ULkTT38629CHhxk/OKNduWo1KwjNhC6vJmhFGsZiq3lzVsaHPai90s2q9cF/V1gpr8b4 MqbQ== X-Gm-Message-State: AAQBX9eJUuRBAvq2nzGi8CDc6nnqcyXXTnInApoDnfPBCkvhNmSMmW3V kAz50WIrY1RP5tzq1YvzkjnXXOKPslo= X-Google-Smtp-Source: AK7set+NBzBuq44EuIpKnv8htdwW3TzhxjccMIEA2+kj78m/8vtnfREPkGmCgy+1yWZXGV4JdJubdA== X-Received: by 2002:a05:6870:580e:b0:177:9b40:97b6 with SMTP id r14-20020a056870580e00b001779b4097b6mr17178811oap.24.1680338822456; Sat, 01 Apr 2023 01:47:02 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id j19-20020a9d7f13000000b006a13dd5c8a2sm2095107otq.5.2023.04.01.01.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:02 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 25/49] completion: zsh: add excluded options Date: Sat, 1 Apr 2023 02:46:02 -0600 Message-Id: <20230401084626.304356-26-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add more excluded options, for example: --bare excludes --git-dir. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 17 +++++++++-------- t/t9904-completion-zsh.sh | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 038ab30869..0c8fdb584f 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -212,15 +212,16 @@ __git_zsh_main () local -a __git_C_args _arguments -C \ - '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ - '(-p --paginate)--no-pager[do not pipe git output into a pager]' \ - '--git-dir=[set the path to the repository]: :_directories' \ - '--bare[treat the repository as a bare repository]' \ + '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ + '(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \ + '(--bare)--git-dir=[set the path to the repository]: :_directories' \ + '(--git-dir)--bare[treat the repository as a bare repository]' \ '(- :)--version[prints the git suite version]' \ - '--exec-path=[path to where your core git programs are installed]:: :_directories' \ - '--html-path[print the path where git''s HTML documentation is installed]' \ - '--info-path[print the path where the Info files are installed]' \ - '--man-path[print the manpath (see `man(1)`) for the man pages]' \ + '--exec-path=[path to where your core git programs are installed]: :_directories' \ + '(- :)--exec-path[print the path where your core git programs are installed]' \ + '(- :)--html-path[print the path where git''s HTML documentation is installed]' \ + '(- :)--info-path[print the path where the Info files are installed]' \ + '(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \ '--work-tree=[set the path to the working tree]: :_directories' \ '--namespace=[set the git namespace]:' \ '--no-replace-objects[do not use replacement refs to replace git objects]' \ diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 4355552434..c0be5573ee 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -821,7 +821,7 @@ test_expect_success 'general options' ' test_completion "git --no-r" "--no-replace-objects" ' -test_expect_failure 'general options plus command' ' +test_expect_success 'general options plus command' ' test_completion "git --version check" "" && test_completion "git --paginate check" "checkout" && test_completion "git --git-dir=foo check" "checkout" && From patchwork Sat Apr 1 08:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CEFFC76196 for ; Sat, 1 Apr 2023 08:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbjDAIs1 (ORCPT ); Sat, 1 Apr 2023 04:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjDAIrc (ORCPT ); Sat, 1 Apr 2023 04:47:32 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6449A1D84C for ; Sat, 1 Apr 2023 01:47:04 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id r14so12747930oiw.12 for ; Sat, 01 Apr 2023 01:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XkUCxkN52MVFgiIV5B43A/xv6Tj+wASaJp8aZitiZr8=; b=T/IwyDul8B/meos0dUTXYmTuLjefLmolaZrOu/R/+RFXX8gJu6uebE/xpqbjiauX+W UFCa91v8hxGanNc5r+b2pOjMJDn7pQiYtFEO8JQPzViTIxQ1TIWEe06bLxOKNCNgCLRk tCyZ5igbU7NmJucs9t0RT4rxjkEfuCsFFyplexRqPk+V0rXgIbIP8kUTRn8scNWFdOni WSjqSZjzysJ46AeQ2eE+jKCdcrMT5wpHKEp83hScQShlJO58c8Auhv7l7A9XA51ZNZqO lIZbPANBYAgYd/BcKVawZ5Ye9H/0NwrjH+LRBZEZyU+2NG+d55p7mcXTqCfeduWcNHLN 0KCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XkUCxkN52MVFgiIV5B43A/xv6Tj+wASaJp8aZitiZr8=; b=dXc+yHnZGN1Fz+j9pO03mQ/Hrbaznu8e0hCbBwv99mCXva9//V6T9rqP6PxobJZszc Yr8Z/RUIlOL1J6ftazmuqVAS8Z72HmpkLlPh3fMtH8pwS8m8HwiH6nwvh+nDWohZOIsI +vLfS7uxMTIYFmmrcdUgwc1VYtzFmmeHF0ngnUtviBCVnm4Bp6yLzHB5w42NsUK6I2BP j2cYkeFCJRNjhO0awsjq9O98O2YoFoPL9KNQc2iXMjKxGdcniBPd468++yY31wnAwFuO irZkodX2dfiz/pLo85tMzn/ELi1PaC1K6iMUcg+PhtjcSXJmdSXQBqj4Vssifh/BP9OW 2hfw== X-Gm-Message-State: AAQBX9eP2CLBh77geHa4q9Bywqvnlax55YMeiokW+m85umHIyRYw4Zkq QPnStSEoqDNAs7hBlC60I+vTfzW0U2g= X-Google-Smtp-Source: AKy350bZI/J0b4hS2Qc65SOAj122z0wTQYuIfpqxzyTcoaJxJHhjP1pks1jrX+baKwWwYQL2bctAhw== X-Received: by 2002:a05:6808:181d:b0:389:4bee:a525 with SMTP id bh29-20020a056808181d00b003894beea525mr10339953oib.45.1680338823835; Sat, 01 Apr 2023 01:47:03 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id s12-20020a4a968c000000b0052a32a952e9sm1735306ooi.48.2023.04.01.01.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:03 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 26/49] completion: zsh: always set compset Date: Sat, 1 Apr 2023 02:46:03 -0600 Message-Id: <20230401084626.304356-27-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 0c8fdb584f..0b6289af0a 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -73,7 +73,6 @@ __gitcomp () esac array+=("$c") done - compset -P '*[=:]' compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 ;; *) @@ -92,7 +91,6 @@ __gitcomp () esac array+=("$c") done - compset -P '*[=:]' compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 ;; esac @@ -102,7 +100,6 @@ __gitcomp_direct () { emulate -L zsh - compset -P '*[=:]' compadd -Q -S '' -- ${(f)1} && _ret=0 } @@ -110,7 +107,6 @@ __gitcomp_nl () { emulate -L zsh - compset -P '*[=:]' compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 } @@ -118,7 +114,6 @@ __gitcomp_file () { emulate -L zsh - compset -P '*[=:]' compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } @@ -131,6 +126,8 @@ __git_complete_command () { emulate -L zsh + compset -P '*[=:]' + local command="$1" local completion_func="_git_${command//-/_}" if (( $+functions[$completion_func] )); then From patchwork Sat Apr 1 08:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F2B4C77B60 for ; Sat, 1 Apr 2023 08:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjDAIs2 (ORCPT ); Sat, 1 Apr 2023 04:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbjDAIrg (ORCPT ); Sat, 1 Apr 2023 04:47:36 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 212AC1F7B2 for ; Sat, 1 Apr 2023 01:47:06 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id bm2so18436520oib.4 for ; Sat, 01 Apr 2023 01:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/qMa84DTLjCFOmzY8TX2jiYBtujJG/I7SzbUh5JQTPg=; b=ko+/SwbxuwEpUJAAvhepzUiZUanLKMu4AEh8MDdeZM48FAL89Ntky1D+Jfd4W9EcJM s45EPPt5nLZzBr/5eyENf4I+pI40aS/F922irK0SEVzvHzdk2vRQjpEq6P9eAHxAAaHu nxf/pWXDcWo8+yoyu9XiEh2P3HMdA6mVwpDnyBfBi1eonlh7dpnXc4smeoLxqljli51M 7x1JPsWbbamP+qRLHH4aYFpZYEyGdx5LZJExbjzDIO4agBHjxBlsjHEFmYd1Zzbs5rsA cs16wD9PWBnZ+l4uP2zqX6aQ298bGhvT+xHmK/6Yk3CoxhqrF+E+dGyiVs47UwIoEx2r OKFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/qMa84DTLjCFOmzY8TX2jiYBtujJG/I7SzbUh5JQTPg=; b=407GjNEAzAI/4tB879vo5U7fkxkHpvFc3fS1e0Mfau6u6R0YtO19G0q7rugClUllSB 6OuqV1b/YZ3+CAeEudg4VyDA0dCry4popqKjvr4lKdOGDRQc68H0r94eyCnWmBt+dBwW zhE1Dgp8i4A5lz18zvBjjuFB1rqOcwQQNo7NlqG9rZYeYo2Cg0cg4U6cEgv6tfeAAsWd IQwCA2z+v2rJMc+G3Etyf4fhXhgaev/ImbQ1sq/JTmNmle25ngL8tm2AmKd2qv0bcj8N W7YiuZ50bCuy/hevIAJnmisG+4gvxmQ4wmZggL4tiMGqn2n+0FJw/xcMv8C0+3TjuHeM iaSQ== X-Gm-Message-State: AO0yUKWe8yd6S8EjR9xwkuUglFfio1WuT1B00HawX6QOnxFO4jL2Uzwk NFeWOBEelQwxoJJJtQ/gwHSxqSCNTjo= X-Google-Smtp-Source: AK7set/Dtm28pySAxIIQlryL8zShD3Q8z17OvvWba4X6PPTGKGzqpLwDLQLGr2LMHw9kOrjEuC3t0A== X-Received: by 2002:a54:4491:0:b0:387:12e5:543a with SMTP id v17-20020a544491000000b0038712e5543amr12573178oiv.29.1680338825254; Sat, 01 Apr 2023 01:47:05 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id j129-20020acab987000000b00383ece4c29bsm1865317oif.6.2023.04.01.01.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:04 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 27/49] completion: factor out check in __gitcomp Date: Sat, 1 Apr 2023 02:46:04 -0600 Message-Id: <20230401084626.304356-28-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 98eb7c9604..e07d5054cb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -341,9 +341,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 0b6289af0a..202f66a4f7 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -56,9 +56,9 @@ __gitcomp () local cur_="${3-$cur}" + [[ "$cur_" == *= ]] && return + case "$cur_" in - *=) - ;; --no-*) local c IFS=$' \t\n' local -a array From patchwork Sat Apr 1 08:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20B67C77B6C for ; Sat, 1 Apr 2023 08:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbjDAIs3 (ORCPT ); Sat, 1 Apr 2023 04:48:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjDAIrg (ORCPT ); Sat, 1 Apr 2023 04:47:36 -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 099C823B77 for ; Sat, 1 Apr 2023 01:47:07 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id bj20so18419446oib.3 for ; Sat, 01 Apr 2023 01:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JbqCxcsV102S514Il6sHip0tz9GKcS3iM8S2LS0CY7Q=; b=kS6gHNGoZcAh89wVxJ75aeutPVvalyGrg1WHGz4wt17G+whpG6CCDwM4b27bxC9aHc HTG/Cn40mJMDj1iDoXn0xkGCElJ0G+iqy1J4b3LK71fzwgc+WoEaxFfDSWuqTjfIYaXh KKMf/8SYLN9NugyQ7XYQ3XmcUq8liQF6Lt/w7iVm1hO0qGbcjUXz8xllIVu8jx6Zzy9c /i6AYjCk0u72AZhjwhNBKkMcHPw1rj8mgkng3N+lXhcgByyjK6PnpK42JZ2d9gNEfvJ0 U7HgRhaiib7+l2UHSeeKd92rX94OTQgIlhNT0CZykhdE66tne/uOLTscx9Wd4hNnkwK6 KGLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JbqCxcsV102S514Il6sHip0tz9GKcS3iM8S2LS0CY7Q=; b=lXzanDUaGMyzRqQgvSEMdEpSPioSJEHtN4ZBNYGWnOGYbmMc1RTdFFBFI8m6d3/e7S LMMWcTwyklHWNafFzuyXwt25bNse7wNUBFVZWwecRjCQDVg8LNq+hmJDPoLtLxci4JIR SRbLkVe7nfqZyU05zr1yvKvYzC7a1z8KhEL68PwnFohU3/0X/KzW1SOrMW72CI+7g4xv JbA78Vl5S2wKr+sotJe54fqEjbOf6oM4KLF2NwiFzVJlx7I/aMgZ+6d4G/3KqYCFz7uG 61+u9WD7kRFTPs0FDtgd9KqA6SgM1lc6yO1FX/IR4wkfIzQtsTBUUynOdPHY/CFU9dT8 PITQ== X-Gm-Message-State: AO0yUKVkUSg0d23/iICFNucbnBEIXCiIjE0ecjKbZrBGITf8u5/IIfqg 2l/qjRFehrBoxVmLv9BkmuLmzSsxZHM= X-Google-Smtp-Source: AK7set+NGfXltvJ4tqoSCUs65pLixcnsw1Fp974hey6Cvn6aaZDOS60OYVfGSkug06fWz1hP0Ji3pQ== X-Received: by 2002:a05:6808:4ca:b0:387:85fc:f912 with SMTP id a10-20020a05680804ca00b0038785fcf912mr12766251oie.57.1680338826452; Sat, 01 Apr 2023 01:47:06 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id l2-20020acabb02000000b003896df086b0sm1864707oif.15.2023.04.01.01.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:06 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 28/49] completion: simplify equal suffix check Date: Sat, 1 Apr 2023 02:46:05 -0600 Message-Id: <20230401084626.304356-29-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 e07d5054cb..187350dbfc 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -355,7 +355,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 202f66a4f7..c9520589db 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -68,7 +68,7 @@ __gitcomp () fi c="$c${4-}" case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac array+=("$c") From patchwork Sat Apr 1 08:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F57BC6FD1D for ; Sat, 1 Apr 2023 08:48:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjDAIsb (ORCPT ); Sat, 1 Apr 2023 04:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjDAIrm (ORCPT ); Sat, 1 Apr 2023 04:47:42 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF4072293C for ; Sat, 1 Apr 2023 01:47:08 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id bl22so4432006oib.11 for ; Sat, 01 Apr 2023 01:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338827; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JSkIhf4M60HT4kf3h+QXf1EV4yyjB8kukzag9Y7TKO0=; b=lzGD5X1WBAu43kfWhpNOjlWQ6ROGdI/Vb+cFMg6zrOL0rWdeBE8oYsWLNKHOk+Tv3g 2V7NuwdIiKARe+TgBFB4Bz7gFKw4T3W/adsvUB0sjOl5aj1ZOBk1vcjsNv7lamDq+aE1 VsH5LJfts0CUS2FGuQ/2Q8tzbgCLXcD5mpLw6DV8e2DrcMrXYHewfrH7h1Di9oMrZk2t YllSE/zaHKejymz/BtebI9G/t8XilRyD2YSlj3zYLAcTRKWoCDqvjisKiWChO1vp7gob JmIGnxtzYQoCP4SaBMXzZoeKytdXisyfBFWO3vIapOyo6TgtKU6HXAcxENu9B0e4e6nJ kQDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338827; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JSkIhf4M60HT4kf3h+QXf1EV4yyjB8kukzag9Y7TKO0=; b=e+nVnffqkjlJC+TQAcwEkxSaVTmMgJCshGozUw5eTMm7wSU2ngY9J2lcapmvirOKae Bh/hs7uNMWYw47nJLINqzmt7eL+Lodr+V4sIjR3dhKjz/24VuV3+7Ffb+cDnFIiesljp sLJepsw4E9dq1gy4e638V3KHfatsqYzRQ7LrXlgcjB45ogw2Wz69OiRqaKHHhuZrJLzW dXqWOH+5fjmRtO7Dp7rwpwR7mUITkUzytbFflpc4MfbKiTe60ogPF7mtDW29H+a7tiL/ Q6Q/LrJUEagSluXCtw0+R5TDD9lh5kobelA92Z9gwpcRjxhUYtG8FvkRmUQynGDZlEEM kZXQ== X-Gm-Message-State: AO0yUKUXiqYNQwEyQ16tmqhHRnYTH61gLP/9oCNJO/4KpmwwnKcc/5UO AN4tjbPwSX8AOYZSkBU5KI1cWEY52DE= X-Google-Smtp-Source: AK7set8yg/dZvunIKOx7wxiGdmUFotCOOzz1NJKKiQKphYDRKCXV0KR2f+k2V592F01ro4xbu9UC+g== X-Received: by 2002:a05:6808:2345:b0:378:9c51:3ed6 with SMTP id ef5-20020a056808234500b003789c513ed6mr13598724oib.20.1680338827692; Sat, 01 Apr 2023 01:47:07 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id d22-20020a4a5216000000b0053b56462336sm1783129oob.21.2023.04.01.01.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:07 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 29/49] completion: refactor __gitcomp Date: Sat, 1 Apr 2023 02:46:06 -0600 Message-Id: <20230401084626.304356-30-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We have two chunks of code doing exactly the same, there's no need for that. No functional changes. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 52 +++++++++----------------- contrib/completion/git-completion.zsh | 52 ++++++++------------------ 2 files changed, 34 insertions(+), 70 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 187350dbfc..9de394b223 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -345,44 +345,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-}" + + c="--no-...${4-}" if [[ $c == "$cur_"* ]]; then - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" + 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-}" - if [[ $c == "$cur_"* ]]; then - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - 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 c9520589db..029ca23e50 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -58,42 +58,22 @@ __gitcomp () [[ "$cur_" == *= ]] && return - case "$cur_" in - --no-*) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - if [[ $c == "--" ]]; then - continue - fi - c="$c${4-}" - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") - done - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - *) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - array+=("$c ") - break - fi - c="$c${4-}" - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") - done - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - esac + local c IFS=$' \t\n' + local -a array + for c in ${=1}; do + if [[ $c == "--" ]]; then + [[ "$cur_" == --no-* ]] && continue + array+=("--no-...${4-} ") + break + fi + c="$c${4-}" + case $c in + *=|*.) ;; + *) c="$c " ;; + esac + array+=("$c") + done + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 } __gitcomp_direct () From patchwork Sat Apr 1 08:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 697A6C76196 for ; Sat, 1 Apr 2023 08:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjDAIsd (ORCPT ); Sat, 1 Apr 2023 04:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjDAIrn (ORCPT ); Sat, 1 Apr 2023 04:47:43 -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 621E422928 for ; Sat, 1 Apr 2023 01:47:09 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id f19-20020a9d5f13000000b00693ce5a2f3eso13139857oti.8 for ; Sat, 01 Apr 2023 01:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OXjHHK/LBHkZDi7Sw4UnHfuXPId30xB8hrZ9iOTLeg4=; b=XNa2CgzsQU9IIfwVaZZhBh4Iugzz2/1vGebnAhKeQa9JkSP2muzF0uKeEnUkICzOYe f/aS5koert0ldkWjbuwgK8kAruZAPVcAdRt0vhf1poKE2cQSz2SVnt/7cZpHZavFPonL j5v76jurhOOIkTpokEeaI26gHkuGW3Y8jNzpayVNQhWJq4pS3UsIv0YRTZ4/5P+45XKv ZWjCI47Cxi1pwNKqVrSdOK3pJh6RPSsYZFR6V+EOuKzjyQ+qGDyMeFmA+a+PFPxLm7zn 2xOlsycEzOsQKN1ncxxbPnx0APu6xOlRLBSlEKG6S5TrSYfDZVsgtRKz+gzQS/sWEoUt LZag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OXjHHK/LBHkZDi7Sw4UnHfuXPId30xB8hrZ9iOTLeg4=; b=fTL2WLoek35nExuw7Y8MxB8aV8FAlpTZZ8NmngTcRx7fHfSrsW/V2nUxWfYhwyffJx wSYdf5V4mQqptjxb6RGLdGhQq2kaQ33foKJBSczIcapWEMqxDAOd9XTZOZP9FeT95KSG f5LkVY0cDIU0/RQs3HJI/WbHpiHJmWKIc7ElQoWrmd+xHSmtZ1mHorQoriU9+iXpNFOX wKTNrKLLPjueYr+M4NIkVowkgaiReviQ52JipuouGsEsWZU2cA5DPhfjQN2b9aZh2Mrs 588m+vdmIUsh91qg4KRLWh7MkBv/hO2V++mmUuRsFjjap9htWybFE3VeK7Ja1h4vjulM l8Bg== X-Gm-Message-State: AO0yUKVebOkO0RUzL1iwF8RuGO4x2jZX/bC6SOfKwVlKRT0IhxTzeG9n IF/pHXs3lnpSrRRIYJnqBtzwZ/ETv0c= X-Google-Smtp-Source: AK7set+snAyq0UFNkzbIAXMbIM6SoTxnA0byaLyl8l7rcJHRZxHe2G2cXiVOnXt49w+wVeKH3OzZ7Q== X-Received: by 2002:a9d:7514:0:b0:69f:cb63:2f18 with SMTP id r20-20020a9d7514000000b0069fcb632f18mr14094181otk.15.1680338828905; Sat, 01 Apr 2023 01:47:08 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id u1-20020a056830118100b0069fb749271bsm2065193otq.15.2023.04.01.01.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:08 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 30/49] completion: simplify __gitcomp Date: Sat, 1 Apr 2023 02:46:07 -0600 Message-Id: <20230401084626.304356-31-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 9de394b223..502a1657a1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -352,9 +352,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 029ca23e50..04265bcb22 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -63,7 +63,7 @@ __gitcomp () for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - array+=("--no-...${4-} ") + array+=("--no-... ") break fi c="$c${4-}" From patchwork Sat Apr 1 08:46:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6101C77B60 for ; Sat, 1 Apr 2023 08:48:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbjDAIse (ORCPT ); Sat, 1 Apr 2023 04:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjDAIrr (ORCPT ); Sat, 1 Apr 2023 04:47:47 -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 B91D424404 for ; Sat, 1 Apr 2023 01:47:10 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id bj20so18419484oib.3 for ; Sat, 01 Apr 2023 01:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UzqmybBX95MVdFpAJq2z+6HnpV5kueywFAb0W9v8gq8=; b=MceHyc6Q2JZ5h07vCquJyyZt6dfXndwyRbczFb685sbuFnK6PfL9t6IBT4cvXpFxFb Q9CZK6Ta8O+ovC8Yn5jfQD7/MVSKHTc5ukXNd/bzr7e+n4iCthf16nVTpV8Av1O9fnTe Vs4OT2Lcj6mq7ewpjqY44mlO2rbwW7Ad7fV/88YjzvoOG7Jlj27GVQo7ocBF4iLX4KV8 WRZE59whm89T+CgvpBQCOagTjaqWwXu0RnYnrnIrxhoXHHY5k8IHfgRKirdA04119WUf HeFdCoJJWi3juaR/3RbajhIskb67YFgSAGEhVEMV4bHH9iXnlZt/+qL1Bv4q3Km2Uqim Do0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UzqmybBX95MVdFpAJq2z+6HnpV5kueywFAb0W9v8gq8=; b=bFbHGp4sAiIi6exteC9vFxBXZInqhCLCYf1bWwXI6S8hiqe1KlX+VY2w/piBxS8BrL BXO8G3Q8WTIHo6U6gBxtKCpdgAAkNf64kyb4ER3bPCQBzMRdFxgUe522szy0QZztMEbL lIdM7WMFJ7V9psclXHyDEgBQRvvbawEbVXE/j3caTNtWrQvuCE2Ui6gr2+91IQfbRdaO rMrZWsfJOAAtJ3ckqg+SFxHw1WWFVc6Y+iISC79lKo9t1A6sUJ7rfCLpthScOXy3b+xh lss5TvZSTcDgEgeMXQNv8vq10vG9fXTCAl2F1kDq6OUHbqtPGhvtangAGjmlZ6w4N6Q5 5gpw== X-Gm-Message-State: AAQBX9fX3Sj9ZOG4yvGNiy25QLXhDrYJHzGMIJxtNJhK7d4ZKP0NdNTS 0LNQutnDHZ3Sc+dOZjjYDQ/GEi9RC+U= X-Google-Smtp-Source: AKy350akdwiGQS+vnTidftNvFlqI/DU7hmCXlEgKkmanmTmONWYI05UOT/QeRQLlg8GlQyDVDpxNzw== X-Received: by 2002:a05:6808:2b0e:b0:389:15a5:179e with SMTP id fe14-20020a0568082b0e00b0038915a5179emr9476165oib.20.1680338830198; Sat, 01 Apr 2023 01:47:10 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id u13-20020a056808150d00b0038413a012dasm1855392oiw.4.2023.04.01.01.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:09 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 31/49] completion: bash: change suffix check in __gitcomp Date: Sat, 1 Apr 2023 02:46:08 -0600 Message-Id: <20230401084626.304356-32-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 502a1657a1..63a3235544 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -357,8 +357,8 @@ __gitcomp () fi break fi - c="$c${4-}" if [[ $c == "$cur_"* ]]; then + c="$c${4-}" case $c in *=|*.) ;; *) c="$c " ;; From patchwork Sat Apr 1 08:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38547C76196 for ; Sat, 1 Apr 2023 08:48:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbjDAIsu (ORCPT ); Sat, 1 Apr 2023 04:48:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjDAIrz (ORCPT ); Sat, 1 Apr 2023 04:47:55 -0400 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22EE024429 for ; Sat, 1 Apr 2023 01:47:13 -0700 (PDT) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-17683b570b8so25596382fac.13 for ; Sat, 01 Apr 2023 01:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gfwFwIXhHJkS69rkFWNJpSdHzFJ7j31eL9ZWSP2lRqQ=; b=e+zYIBQR8/nBGz9EplweRSUAF1kMfChsVEjZX9e2W1FZWfyHHjtooIiTcL3I4dbMT4 thv3BcHsJCc63bhW98KJpaPVLjbKiscFdbVuzjFu1mo/QE4CQ1DZtl5icefLzGZ8c5G9 vdDVaqsQvOIbW+JdZd+BSj4LLfa+3pXUmEEr4tvtWr5FQLlEk/whhHP8sXDwD6doziMR zHhIjpu3+MF8jDmRGmEBo6FLxULRGHp9YuvC+SjWEVfVgjmuFMttn7KivNV41+Zp8tM6 rD+FnfdOF8rZbr4rI1dJSTW4wLINzH4sLmtNI2ygN9oS8r3USICDoATnPbrXN2P2ly4x rALQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gfwFwIXhHJkS69rkFWNJpSdHzFJ7j31eL9ZWSP2lRqQ=; b=kKMoKRWJWIjwDa8UxD2zJYxJ3iuYfY+dpbdNE3xMpghmTXcEC93YkKtFDw4PsZxeDw +kv1b/kK3QCkvo9GdTtBC/0WktdabQCrnIh0CqMA+OxATp9IPexSqk4nIGmol4a9d6pE tmiWNNhSZHJInjwkkgeHaFLJAmw0cBipbGpX2vqJbcjOVwmjbwv9KeLrxSi2vfhHHsAe xrDxXnyBJmu+A0wcwSFEops6JD6VPz3o6GNDotfWOE/XeGfm63shW0dxlIqb3x4LdZuZ KO/jloDQQZZYhmWH+owg5/+Wwj6CeslQkZ/4MhBBg9nEkZcnT/jsprivPj/P5HSgHdXp uGSw== X-Gm-Message-State: AAQBX9fCTH8BJeJ4Q8/xISclqExkpj82SwkRSuOgqfwL0C0jPDVvk6SW cFiEcOayyJF9YfiydaGjS1edIm3/u7E= X-Google-Smtp-Source: AKy350bcXUd5cqznhbvGk5uNIS5L+SFgTkaot9UGW7eMkw9TknAZnhl+rYUgzNlWFlwu/Zig9E2RzQ== X-Received: by 2002:a05:6870:b506:b0:178:4453:8020 with SMTP id v6-20020a056870b50600b0017844538020mr17757890oap.19.1680338831529; Sat, 01 Apr 2023 01:47:11 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id g22-20020a9d6b16000000b006884c42a38asm2136095otp.41.2023.04.01.01.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:11 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 32/49] completion: improve __gitcomp suffix code Date: Sat, 1 Apr 2023 02:46:09 -0600 Message-Id: <20230401084626.304356-33-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no point in adding a suffix after a suffix. If a suffix is provided: we add it, if not: then the default heuristic is used. There's no functional change since most callers don't specify a suffix, and the ones that do, use an =, which by default doesn't add an additional suffix. The only exception is __git_complete_config_variable_name, so make sure we pass the correct suffix. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 19 +++++++++++-------- contrib/completion/git-completion.zsh | 18 +++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 63a3235544..eb7be6aa6c 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -345,7 +345,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 @@ -358,12 +358,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 } @@ -2606,7 +2609,7 @@ __git_complete_config_variable_value () # subsections) instead of the default space. __git_complete_config_variable_name () { - local cur_="$cur" sfx + local cur_="$cur" sfx=" " while test $# != 0; do case "$1" in diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 04265bcb22..290fd0252d 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -58,7 +58,7 @@ __gitcomp () [[ "$cur_" == *= ]] && return - local c IFS=$' \t\n' + local c IFS=$' \t\n' sfx local -a array for c in ${=1}; do if [[ $c == "--" ]]; then @@ -66,12 +66,16 @@ __gitcomp () array+=("--no-... ") break fi - c="$c${4-}" - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - array+=("$c") + + if [[ -z "${4+set}" ]]; then + case $c in + *=|*.) sfx="" ;; + *) sfx=" " ;; + esac + else + sfx="$4" + fi + array+=("$c$sfx") done compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 } From patchwork Sat Apr 1 08:46:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ECBCC76196 for ; Sat, 1 Apr 2023 08:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjDAItA (ORCPT ); Sat, 1 Apr 2023 04:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229724AbjDAIrz (ORCPT ); Sat, 1 Apr 2023 04:47:55 -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 93DFD1D85C for ; Sat, 1 Apr 2023 01:47:13 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id ca2-20020a056830610200b006a11ab58c3fso12467296otb.4 for ; Sat, 01 Apr 2023 01:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LkAmfMDU8Qe90ICH0GTdtFE0TPrhBa7Yz3X5N8UNz3Q=; b=MH8m08y5RaQd98R/ETbnzScdq9DLFLREqmVVmi5J4bgLX78cK96hmMx0Pp1zAzWT6E sELdYVQ8Jpe1u5K8gRyH0fGlEgo6/wofat49nKUdB4ENnzlW+4nrFwo97UmxluHnYrzc 9F7za5IGn6daDf6J2CqJhnmc00WcfnyNo+NjNFkrF+H/TiucZ+wBqAnVbOwAsok35nz3 /v3l7fgS88lnCJCw5jCF27ZN3DEfQmRIH3qMBRI+u/Da68k355JDzg9nAW9iGsVwvcjk 2hEPx4PtneROFsgiIVQMPGkPKSqmxxItfcOa5jfN6SyHKOexfXjlgaHmNFRhtZk5KjGO WClA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LkAmfMDU8Qe90ICH0GTdtFE0TPrhBa7Yz3X5N8UNz3Q=; b=CgIDHlsQ8/F2BXs7dmdyFEJtJ/GkiD8IpVZsRrZEIMzMWvNDMUas0usGfq3F5jzAzH utCWiBreDJOT7mIYPnHkgxr5xst3oRW+6bRUqK9sW6MXrV9WwGlH6zIbf9EICHpO1P68 c5ClxKsb/4usxoNhYvCnBF7sgDDs0Hd+0mPmZWnKHXtdhrsG1P4wbzfhEGmkErMKFOPr tWeYi7BSY3Hj+0UfjhbgBK1qhmG4GsIUxBRh9RUj1ewCJf868tW+G8/jQiFxUwEbrypz EtmDBpmgXAeL5SwI11jxQMl40dP4lqXx1XJ+0ILDQQC5HitNI48a6IcqyAct8BOjNhsU pKdA== X-Gm-Message-State: AO0yUKWTwWR59+oJ7BzZiBdY8truV3dGkFsXZAwAa54/xrPUo+J2qKpS gNyDT8DqCqIhYcsuoc6k8Ie7N9e58WU= X-Google-Smtp-Source: AK7set9ee5eKIe1v4uHUazIiy2RDLRYwDI1zu98Hs3o2RUOac96l4ickmNWucfkmwLdVNhivB2E8cQ== X-Received: by 2002:a05:6830:12d6:b0:68b:dd8b:6cd with SMTP id a22-20020a05683012d600b0068bdd8b06cdmr14403311otq.7.1680338833009; Sat, 01 Apr 2023 01:47:13 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id b22-20020a9d7556000000b006a305c68617sm733378otl.53.2023.04.01.01.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:12 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 33/49] test: completion: add missing test Date: Sat, 1 Apr 2023 02:46:10 -0600 Message-Id: <20230401084626.304356-34-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Once the correct suffix in __git_complete_config_variable_name() is set, we can add the test again. Now it should work even in bash < 4.0. Signed-off-by: Felipe Contreras --- t/t9902-completion.sh | 7 +++++++ t/t9904-completion-zsh.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index a2f2f9dc09..c33543191f 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -2533,6 +2533,13 @@ test_expect_success 'git config - value' ' EOF ' +test_expect_success 'git config - direct completions' ' + test_completion "git config branch.autoSetup" <<-\EOF + branch.autoSetupMerge Z + branch.autoSetupRebase Z + EOF +' + test_expect_success 'git -c - section' ' test_completion "git -c br" <<-\EOF branch.Z diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index c0be5573ee..1c694bec0d 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -1090,6 +1090,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 Sat Apr 1 08:46:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2878C6FD1D for ; Sat, 1 Apr 2023 08:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbjDAItD (ORCPT ); Sat, 1 Apr 2023 04:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjDAIr4 (ORCPT ); Sat, 1 Apr 2023 04:47:56 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD5B12369A for ; Sat, 1 Apr 2023 01:47:14 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-177b78067ffso25638443fac.7 for ; Sat, 01 Apr 2023 01:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eJDprGFN/4Jgr5Wmnt4L/FLmivfW1CJhGkGffWQBysk=; b=MenNraJ8En5XuXgxjd63RpSZfvez/ik37BvWRpu/z/Qa9BcdxGHVS6IiOMKIQG8GL6 5RZyj9BAvRNu5ojlrv11wC6BnChkX/xST51khlTP/mWMmFZAZWUomx3DYZlKUdad7XZU fJ9fyQ0G2bCNtO4hR7aYy9ye7lkxNUYGtZms78WVPUF/1HMXG0G/3AbCiE2+r77CRg3g D2Ia5btgehy8S3NSkN9E9Ugv1aE+2FFvQ/JyXhR9ngWAqT+xzKS0mnmmhZJ86XUAlrMy TpbufE0eaonmiZVPvMlRckqW2NcYa0lCd2IEN5IvWDz+juGIya+5ntYqDODGccUvxvnq rf8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eJDprGFN/4Jgr5Wmnt4L/FLmivfW1CJhGkGffWQBysk=; b=U+YKCx46DjwF4takGshNjavO2fo8ApOcxv6vEYDC/oEfcSvoZilJQoFZi5zrwqUQF+ Qw4XvFRNVDgjGmIqIneHZfPa2PwA+FZfspt2OEh22vZNhJ1cpiapIngxzmdsKeuVHhg2 4GHp9scTFvnG7WfQPB7A27kGJqU0PLbZuS2m9L8W+17kg1XD0QbIwRr/ye+nI+K8eX8+ 78HJRl4j1ncrzsUPm80YXA+3apIklfMrwjn/9EFZ06Rex8BeI/cb8cS3OJ6/Mgx8p5kJ YFWTsiRODINQmgvg+UOJUDxDsh6j5q8q+77kFyQ++Bm6MIICVElzGLBc/m0k1TxuUPkl Rjpg== X-Gm-Message-State: AAQBX9fbJZVP9fVYVlmWOhkSywMps0KwTKb+vLz1gZtr8UUlrh+NlJK8 dkOJBslNWDsRSy1XeikFhNw7YZPyHoc= X-Google-Smtp-Source: AKy350Zhh1UM4qaGEGKCuVJ/ARuDcN/K72ST8jdz+0Ajezq6AYKbqEUwCPxrxMZtcNrukTa6dShMtw== X-Received: by 2002:a05:6870:d212:b0:172:a59c:7fcd with SMTP id g18-20020a056870d21200b00172a59c7fcdmr16981393oac.31.1680338834320; Sat, 01 Apr 2023 01:47:14 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id bf10-20020a0568700a0a00b0017264f96879sm1726015oac.17.2023.04.01.01.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:13 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 34/49] completion: bash: simplify config_variable_name Date: Sat, 1 Apr 2023 02:46:11 -0600 Message-Id: <20230401084626.304356-35-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now sfx is never null. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index eb7be6aa6c..2974604e99 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2631,7 +2631,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.*.*) @@ -2665,7 +2665,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.*.*) @@ -2681,7 +2681,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 Sat Apr 1 08:46:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 493E2C76196 for ; Sat, 1 Apr 2023 08:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbjDAItF (ORCPT ); Sat, 1 Apr 2023 04:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229672AbjDAIr4 (ORCPT ); Sat, 1 Apr 2023 04:47:56 -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 0973A2031D for ; Sat, 1 Apr 2023 01:47:16 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id x8-20020a9d3788000000b0069f922cd5ceso13144388otb.12 for ; Sat, 01 Apr 2023 01:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iNtSxVFKcFSDbmdmdXhd5KktbMiysATgKQlv/7eNp+k=; b=OXyIVinKPgbVxh74RMTfvCmYl3XbYXzWOc283P6iQ6dTgHPJZEinOggX9DzUVUqkDo kvHMEI3M26WfJzL84FY7k27RwUZALV5hMKp0RlTFWAZvZZFb9ed8HkI0f8ljMDD6mYg+ 8ezpKOB/p4PQEGoEw/i8U+mB75+wMBEeLoXl3bS65FbDLTLhkTrANyzzDy6T9dfVi2mj X5RwAK94wvf8MEpXhnzmPIC5MY35ylLzf/HXpsVOsJd6Mn33f5bSzAOyHuL5wqIge3NU XAxYPrj5wBWL5PjrzmckS3IujXtKE6ap9afRM/VBcUTk4W38kQrwG5TqSgZM+F7pYLn0 L/lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iNtSxVFKcFSDbmdmdXhd5KktbMiysATgKQlv/7eNp+k=; b=O4pL5GGcbn7FAW4NytpsxOv/TM28bDchRmyMvvxRaSSyhx8/h4AcoXdLqY3QcWwzVK 1FnnzZ2SZrKWNEbvgrdjEMVu+z1kFfL36njla48wtJCRUQ4i3Cm2vaNDa//y0jC+z4Mm 3zLKMeleiUnZ/DCwYpNixTtD/Dodu36guqNt/4UHE42LavJZAP7aqEcYNVnYaiwmUBxO WNDgb2rmOhA+p2oZo9L9S79wDi6NrfsBUfHh5fAV+We+JlXeOT3XHR1D8ZVm58NvCTTo utIxuWpNgnZ4gSlxD4YVChLLY+NxHZAAKXmhnrX62ljUJHaMsXNKLLQFGBqXBzaM+wd/ 9B0Q== X-Gm-Message-State: AAQBX9fa7fcFRk4TCgHAfEg+TeZ96YlQkw44A2HTB8w5rMPfp79nm9eK dgRSSNYWnW8GzKjPOg0oGvIpWHuWrQ0= X-Google-Smtp-Source: AKy350Zrf+AzQmW0Ol2UZQ/VpTYohzKZ+ZcgwG/dKQgPxOftivWnc/lngIJCTGhaHy4ZbH68OiofGQ== X-Received: by 2002:a9d:4d84:0:b0:6a1:1ed4:bc50 with SMTP id u4-20020a9d4d84000000b006a11ed4bc50mr12996088otk.20.1680338835536; Sat, 01 Apr 2023 01:47:15 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id r4-20020a056830134400b00697be532609sm1029933otq.73.2023.04.01.01.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:15 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 35/49] completion: bash: improve __gitcomp description Date: Sat, 1 Apr 2023 02:46:12 -0600 Message-Id: <20230401084626.304356-36-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 2974604e99..6633b866fb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -330,8 +330,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 Sat Apr 1 08:46:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20895C6FD1D for ; Sat, 1 Apr 2023 08:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbjDAItH (ORCPT ); Sat, 1 Apr 2023 04:49:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjDAIsB (ORCPT ); Sat, 1 Apr 2023 04:48:01 -0400 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1E06EB61 for ; Sat, 1 Apr 2023 01:47:17 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id f19-20020a9d5f13000000b00693ce5a2f3eso13139956oti.8 for ; Sat, 01 Apr 2023 01:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6scGDqXIpkGRgR79bdzO7vdcDY017YN4o3WcPHVLM4k=; b=l4S2WGXDX5Gke/NnuXs/9ndvNugQufmot1wu/pm8aObS+4/pUNcB7caO4WD0KfzIWO lNyXaDKAg5xUNV8l1MxIPX0dO5JIWpjNnPmPvp9cXOHOue1baixnXkuzsE/oMvHhF2c9 ECWwLEvrO8unSQkj8x+WY4avNC7D/dwt24hbU5oUDolgBfICNEdOBh61cwzcEiB7GO2R 5dKb3B6Ei2bStwp9q2RTV9a+ImEbS2ZStmj5w9MdAhdLAo6KdXQJ/xcQjLK6jjgCQe7c EtGwbfV6p063ga42sD43Pf/NtY6I7R+oT/2heG/qcT3B4JAuPVN8IjL4xFflLhkCmXE2 u+zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6scGDqXIpkGRgR79bdzO7vdcDY017YN4o3WcPHVLM4k=; b=3zpnaPyF4KhGygjGfSZ1Kg0pX6evSOKSEaV2QeoJBY2SXMiW8yRhmeK0vH0/D7AuSf +rZDdKQ4ADdHEP74ccLw3OsjInz+xxfu9zAPgVwIgilJoOaC1MY3Mqp+1sd6nz9k41X2 ZyzQWQFur0TYM8rL9dlmDq4P+J5pUoodd1w0OWtO2LPE59ma8K0rrGiyMN2fior5Ay22 PtPlRn2xVSJL2H2SQwlBSPJr78PTUgmHAV3t5j+Uatc1dTUSVXgWs+WbChOgrX96k1ca 1moKKcX/U1P4e1fKMI+6g9Tl950tlmO2O/Z3nCzkNQ6m2uS9Vkxfuuc9I5XGitAPpux8 v65g== X-Gm-Message-State: AO0yUKUwg9BsVDZSGuKg5vxlip766Wvi4L6aQ8y//MxAK2EzgjAAjVlh sZExO0ROfeBRHL5bUPbyfjM3VKkDWTA= X-Google-Smtp-Source: AK7set+2WupZN0fUARnHCx8z5HUtD0/jyN6PUr9sgUbhZZah7GzXjJlWtTHQvnJLAFkesBn4DNOhjQ== X-Received: by 2002:a9d:68ce:0:b0:699:45ab:5303 with SMTP id i14-20020a9d68ce000000b0069945ab5303mr15313341oto.37.1680338837011; Sat, 01 Apr 2023 01:47:17 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id tb5-20020a05687186c500b0017255c79736sm1701776oab.43.2023.04.01.01.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:16 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 36/49] completion: add __gitcomp_opts Date: Sat, 1 Apr 2023 02:46:13 -0600 Message-Id: <20230401084626.304356-37-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Create a new simplified version of __gitcomp for most callers, and __gitcomp_opts for the ones that need reorganizing all the options. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 94 +++++++++++++++----------- contrib/completion/git-completion.zsh | 8 +++ t/t9902-completion.sh | 58 ++++++++-------- t/t9904-completion-zsh.sh | 54 +++++++-------- 4 files changed, 117 insertions(+), 97 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 6633b866fb..ba225e999a 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -330,13 +330,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}" @@ -380,7 +392,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 @@ -415,7 +427,7 @@ __gitcomp_builtin () eval "$var=\"$options\"" fi - __gitcomp "$options" + __gitcomp_opts "$options" } # Generates completion reply from newline-separated possible completion words @@ -1066,7 +1078,7 @@ __git_complete_strategy () return 0 ;; -X) - __gitcomp "$__git_merge_strategy_options" + __gitcomp_opts "$__git_merge_strategy_options" return 0 ;; esac @@ -1076,7 +1088,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 @@ -1318,7 +1330,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 @@ -1578,7 +1590,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 @@ -1737,7 +1749,7 @@ _git_diff () return ;; --*) - __gitcomp "$__git_diff_difftool_options" + __gitcomp_opts "$__git_diff_difftool_options" return ;; esac @@ -2031,7 +2043,7 @@ _git_log () return ;; --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options @@ -2094,7 +2106,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" + __gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui" return ;; esac @@ -2242,7 +2254,7 @@ _git_range_diff () { case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --creation-factor= --no-dual-color $__git_diff_common_options " @@ -2259,11 +2271,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 @@ -2877,7 +2889,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 @@ -2909,7 +2921,7 @@ _git_shortlog () case "$cur" in --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options --numbered --summary --email @@ -2947,7 +2959,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 @@ -3073,7 +3085,7 @@ _git_submodule () if [ -z "$subcommand" ]; then case "$cur" in --*) - __gitcomp "--quiet" + __gitcomp_opts "--quiet" ;; *) __gitcomp "$subcommands" @@ -3084,29 +3096,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" ;; *) ;; @@ -3147,64 +3159,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" ;; *) ;; @@ -3444,7 +3456,7 @@ __git_main () esac case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --paginate --no-pager --git-dir= @@ -3501,7 +3513,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 290fd0252d..83d2bc99a1 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -54,6 +54,14 @@ __gitcomp () { emulate -L zsh + local IFS=$' \t\n' + compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 +} + +__gitcomp_opts () +{ + emulate -L zsh + local cur_="${3-$cur}" [[ "$cur_" == *= ]] && return diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index c33543191f..b4ed415245 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -98,17 +98,17 @@ test_completion () test_cmp expected out_sorted } -# Test __gitcomp. +# Test __gitcomp_opts. # The first argument is the typed text so far (cur); the rest are -# passed to __gitcomp. Expected output comes is read from the +# passed to __gitcomp_opts. Expected output comes is read from the # standard input, like test_completion(). -test_gitcomp () +test_gitcomp_opts () { local -a COMPREPLY && sed -e 's/Z$//' >expected && local cur="$1" && shift && - __gitcomp "$@" && + __gitcomp_opts "$@" && print_comp && test_cmp expected out } @@ -463,8 +463,8 @@ test_expect_success '__gitcomp_direct - puts everything into COMPREPLY as-is' ' test_cmp expected out ' -test_expect_success '__gitcomp - trailing space - options' ' - test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message= +test_expect_success '__gitcomp_opts - trailing space - options' ' + test_gitcomp_opts "--re" "--dry-run --reuse-message= --reedit-message= --reset-author" <<-EOF --reuse-message=Z --reedit-message=Z @@ -472,8 +472,8 @@ test_expect_success '__gitcomp - trailing space - options' ' EOF ' -test_expect_success '__gitcomp - trailing space - config keys' ' - test_gitcomp "br" "branch. branch.autosetupmerge +test_expect_success '__gitcomp_opts - trailing space - config keys' ' + test_gitcomp_opts "br" "branch. branch.autosetupmerge branch.autosetuprebase browser." <<-\EOF branch.Z branch.autosetupmerge Z @@ -482,32 +482,32 @@ test_expect_success '__gitcomp - trailing space - config keys' ' EOF ' -test_expect_success '__gitcomp - option parameter' ' - test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \ +test_expect_success '__gitcomp_opts - option parameter' ' + test_gitcomp_opts "--strategy=re" "octopus ours recursive resolve subtree" \ "" "re" <<-\EOF recursive Z resolve Z EOF ' -test_expect_success '__gitcomp - prefix' ' - test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ +test_expect_success '__gitcomp_opts - prefix' ' + test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z EOF ' -test_expect_success '__gitcomp - suffix' ' - test_gitcomp "branch.ma" "master maint next seen" "branch." \ +test_expect_success '__gitcomp_opts - suffix' ' + test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z EOF ' -test_expect_success '__gitcomp - ignore optional negative options' ' - test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore optional negative options' ' + test_gitcomp_opts "--" "--abc --def --no-one -- --no-two" <<-\EOF --abc Z --def Z --no-one Z @@ -515,44 +515,44 @@ test_expect_success '__gitcomp - ignore optional negative options' ' EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF --abc Z --abcdef Z EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--n" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-... Z EOF ' -test_expect_success '__gitcomp - expand all negative options' ' - test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand all negative options' ' + test_gitcomp_opts "--no-" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-two Z EOF ' -test_expect_success '__gitcomp - expand/narrow all negative options' ' - test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand/narrow all negative options' ' + test_gitcomp_opts "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z EOF ' -test_expect_success '__gitcomp - equal skip' ' - test_gitcomp "--option=" "--option=" <<-\EOF && +test_expect_success '__gitcomp_opts - equal skip' ' + test_gitcomp_opts "--option=" "--option=" <<-\EOF && EOF - test_gitcomp "option=" "option=" <<-\EOF + test_gitcomp_opts "option=" "option=" <<-\EOF EOF ' -test_expect_success '__gitcomp - doesnt fail because of invalid variable name' ' - run_func __gitcomp "$invalid_variable_name" +test_expect_success '__gitcomp_opts - doesnt fail because of invalid variable name' ' + run_func __gitcomp_opts "$invalid_variable_name" ' read -r -d "" refs <<-\EOF diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 1c694bec0d..79c1368769 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -56,16 +56,16 @@ test_completion () test_cmp expected out_sorted } -# Test __gitcomp. +# Test __gitcomp_opts. # The first argument is the typed text so far (cur); the rest are -# passed to __gitcomp. Expected output comes is read from the +# passed to __gitcomp_opts. Expected output comes is read from the # standard input, like test_completion(). -test_gitcomp () +test_gitcomp_opts () { sed -e 's/Z$//' >expected && local cur="$1" && shift && - run_completion "git func __gitcomp $(printf "%q " "$@") $cur" && + run_completion "git func __gitcomp_opts $(printf "%q " "$@") $cur" && test_cmp expected out } @@ -97,8 +97,8 @@ test_expect_success 'setup for __git_find_repo_path/__gitdir tests' ' git init -b main otherrepo ' -test_expect_success '__gitcomp - trailing space - options' ' - test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message= +test_expect_success '__gitcomp_opts - trailing space - options' ' + test_gitcomp_opts "--re" "--dry-run --reuse-message= --reedit-message= --reset-author" <<-EOF --reuse-message=Z --reedit-message=Z @@ -106,8 +106,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 @@ -116,32 +116,32 @@ test_expect_success '__gitcomp - trailing space - config keys' ' EOF ' -test_expect_success '__gitcomp - option parameter' ' - test_gitcomp "--strategy=re" "octopus ours recursive resolve subtree" \ +test_expect_success '__gitcomp_opts - option parameter' ' + test_gitcomp_opts "--strategy=re" "octopus ours recursive resolve subtree" \ "" "re" <<-\EOF recursive Z resolve Z EOF ' -test_expect_failure '__gitcomp - prefix' ' - test_gitcomp "branch.maint.me" "remote merge mergeoptions rebase" \ +test_expect_failure '__gitcomp_opts - prefix' ' + test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z branch.maint.mergeoptions Z EOF ' -test_expect_failure '__gitcomp - suffix' ' - test_gitcomp "branch.ma" "master maint next seen" "branch." \ +test_expect_failure '__gitcomp_opts - suffix' ' + test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z branch.maint.Z EOF ' -test_expect_success '__gitcomp - ignore optional negative options' ' - test_gitcomp "--" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore optional negative options' ' + test_gitcomp_opts "--" "--abc --def --no-one -- --no-two" <<-\EOF --abc Z --def Z --no-one Z @@ -149,38 +149,38 @@ test_expect_success '__gitcomp - ignore optional negative options' ' EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--a" "--abc --abcdef --no-one -- --no-two" <<-\EOF --abc Z --abcdef Z EOF ' -test_expect_success '__gitcomp - ignore/narrow optional negative options' ' - test_gitcomp "--n" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - ignore/narrow optional negative options' ' + test_gitcomp_opts "--n" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-... Z EOF ' -test_expect_success '__gitcomp - expand all negative options' ' - test_gitcomp "--no-" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand all negative options' ' + test_gitcomp_opts "--no-" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z --no-two Z EOF ' -test_expect_success '__gitcomp - expand/narrow all negative options' ' - test_gitcomp "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF +test_expect_success '__gitcomp_opts - expand/narrow all negative options' ' + test_gitcomp_opts "--no-o" "--abc --def --no-one -- --no-two" <<-\EOF --no-one Z EOF ' -test_expect_success '__gitcomp - equal skip' ' - test_gitcomp "--option=" "--option=" <<-\EOF && +test_expect_success '__gitcomp_opts - equal skip' ' + test_gitcomp_opts "--option=" "--option=" <<-\EOF && EOF - test_gitcomp "option=" "option=" <<-\EOF + test_gitcomp_opts "option=" "option=" <<-\EOF EOF ' From patchwork Sat Apr 1 08:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87C3EC76196 for ; Sat, 1 Apr 2023 08:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbjDAItN (ORCPT ); Sat, 1 Apr 2023 04:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjDAIsC (ORCPT ); Sat, 1 Apr 2023 04:48:02 -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 3E0F51D864 for ; Sat, 1 Apr 2023 01:47:19 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id bj20so18419635oib.3 for ; Sat, 01 Apr 2023 01:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ursDb8Z6Vu/2xeLTutiZZ/4vgH4Ns6oQzaNFPy4/Ctc=; b=gtK7Alsrz283zkMkCECqeEzYieX0OPxbvLIjXP2e0ujnRHhdGXu3jC6BC80Xmw7Tz2 j29AfHHR2fuOAjEehlU6jxEoZR2dgrM6pBJwcA0Cjf+EF1t+1bWTkrQp1gTRLeYHaiat JEjQhdOsZv94i1W9BI0MTZC3euUVxpYHHiMLSxG2sFPuFtw0YszH0HVgV6yeSmWb7RnF F700EyqcBbDN2+te9srj4s+1WnOXm5xICM0fP6xBJUJucZAqxN4f2QcJ4tSguilXrnDp l/Xao6NZlOkDd+TWb0DVsOckWLf+aI9Xl+yPfeOLF7FPTRQEhHroqcLaO6Z1LMtwXUsB WcJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ursDb8Z6Vu/2xeLTutiZZ/4vgH4Ns6oQzaNFPy4/Ctc=; b=vQbe9hp1hVLXgbdyayMnz9vxIJulr4ZH2i1FiAHpj48/5iLKCF+O6kRIh7lCRPfC3k 7SHZkvhwQ6fPNoly7R97n5PZnIpZbiFybUauy1AmKUOfowfw3zbSo2gV/6KNnZN7p2Bj hUomMATvLASgk2M0NIcFRCkkd4mJpZ2/MseRKNbbejnCqg0os70vBl0nHd610MR8Fgt0 +TRsY5j4UoHNyvhxvnlWECIVQCrrI7K9cd3plMoZVhqnhJCYzVHWsXdtYKd9C2iPXm1k Oa4GN8Mkf5NPVjMjxceSp1i7d+Na0C+fKio6K+niWBBloIwXvKDplm7bfL78oJKerxiT X0NQ== X-Gm-Message-State: AAQBX9fiQg854k0e5ha5Q4CYM6KZ2bLMGvoowxeobOb1qhfV2g/41F96 3QmVelSL5tkYlr7S+B4mcrIL74pkUNo= X-Google-Smtp-Source: AKy350ZOBN6FnLSaHebyuWoRMSbRTEBL86zrvaosaTOtT7wOzWifNrEUjm23PLTRQO6k5hRxuL8pxw== X-Received: by 2002:a54:478a:0:b0:388:c626:a32c with SMTP id o10-20020a54478a000000b00388c626a32cmr12295188oic.9.1680338838650; Sat, 01 Apr 2023 01:47:18 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id i2-20020a4aab02000000b005251e3f92ecsm1710152oon.47.2023.04.01.01.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:18 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 37/49] completion: bash: cleanup __gitcomp* invocations Date: Sat, 1 Apr 2023 02:46:14 -0600 Message-Id: <20230401084626.304356-38-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 ba225e999a..bc6f83adce 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1394,7 +1394,7 @@ _git_archive () { case "$cur" in --format=*) - __gitcomp "$(git archive --list)" "" "${cur##--format=}" + __gitcomp_nl "$(git archive --list)" "" "${cur##--format=}" return ;; --remote=*) @@ -1808,9 +1808,7 @@ _git_format_patch () { case "$cur" in --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --base=*|--interdiff=*|--range-diff=*) @@ -2316,7 +2314,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 @@ -2340,9 +2338,7 @@ _git_send_email () return ;; --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --to=*|--cc=*|--bcc=*|--from=*) @@ -2642,7 +2638,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.*.*) @@ -2692,7 +2688,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.*.*) @@ -2707,7 +2703,7 @@ __git_complete_config_variable_name () ;; *) __git_compute_config_sections - __gitcomp "$__git_config_sections" "" "$cur_" "." + __gitcomp_nl "$__git_config_sections" "" "$cur_" "." ;; esac } @@ -2801,7 +2797,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 @@ -3484,7 +3480,7 @@ __git_main () then list_cmds=builtins,$list_cmds fi - __gitcomp "$(__git --list-cmds=$list_cmds)" + __gitcomp_nl "$(__git --list-cmds=$list_cmds)" fi ;; esac From patchwork Sat Apr 1 08:46:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1BABC6FD1D for ; Sat, 1 Apr 2023 08:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbjDAItP (ORCPT ); Sat, 1 Apr 2023 04:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbjDAIsH (ORCPT ); Sat, 1 Apr 2023 04:48:07 -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 E956F1D843 for ; Sat, 1 Apr 2023 01:47:20 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id a30-20020a9d3e1e000000b006a13f728172so9960037otd.3 for ; Sat, 01 Apr 2023 01:47:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zfahy3Agolk9OqJbyPKo1v+PYCI3Km/h+s0Z27r2jGY=; b=WbcnwQUT4As2KcpY3nQgdxJrkbfdTq1bu6Yt/5Szsabs24ORcIUvCtPIxwg1voHTCC 4w2UXd9JQJmy1IvkeTkkj8IYDv2c6cpyC0+TSf8uRyQa67y6n9RLsljqxN33RiGhVvhm wOU81v3QgBHit4HQHT/6Wgk8dSffyFAHcqJhFzpFuy2ks7ksGalQnVX9RZPx9jQEU0M7 k4lhTTzTEB40yfiWUE/FVhCX9KECKVHktZrHJwfL00upx8octOnv5HR1AFl/yqg4cNEN SvMk6N6fpDy0IDY3oeVDhlPYb2rWDQy4xI3Jf1K7PCJt+y98soChthG3eOt56F4dHNdO RJ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zfahy3Agolk9OqJbyPKo1v+PYCI3Km/h+s0Z27r2jGY=; b=OjGkiVLw5IorT9Pboc2RWzm/Jv9ufJ1sEtOv2CI6LixQZ0I5zRNwc37ZMw8KnaMgSf 7M0VlK0OX4OKw8zWeh8DOEOST4ZMbUq0duhQeQKnoFf3x+lmVnXqRW4+sD2L8W2ooQec +budLIHWc1KB1NJWwUfgmIhfdD/ahS3PNkvyTA0Z1Sj+McAPTYGpb74JruGTiDe/HtIj /pjguMrGXSodBolSbW+z324zPaAClbf3YiN4wWirtRQNm5MhoIS+xxeyByl9oz14C2s4 O78it2Yk2JQLReW6sM0pKlR6HbVUt91venGnjtTiEi2jEAU5g4AofEY1+ytMmtfaEGPV k7bA== X-Gm-Message-State: AO0yUKVamvGxBz0h0k6PnbgfvMrCtYE8a71INRW5tAQlw4KhdMFMLp4B 9//oa5oclp4GQh0Aq2A29XFivBPRNLs= X-Google-Smtp-Source: AK7set8QA2w72dqPjWzumn6SCLnkxa9rMGIU6Jtvb5mEJ9h7QG2reCjuIzDTzEqRSL6uqfTHhH+u2Q== X-Received: by 2002:a9d:7301:0:b0:69f:a37c:49b0 with SMTP id e1-20020a9d7301000000b0069fa37c49b0mr13818102otk.20.1680338839964; Sat, 01 Apr 2023 01:47:19 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id d11-20020a9d5e0b000000b006a3170fe3efsm322507oti.27.2023.04.01.01.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:19 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 38/49] completion: bash: shuffle __gitcomp functions Date: Sat, 1 Apr 2023 02:46:15 -0600 Message-Id: <20230401084626.304356-39-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 bc6f83adce..3f48b61cbe 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -65,6 +65,145 @@ # case insensitively, even on systems with case sensitive file systems # (e.g., completing tag name "FOO" on "git checkout f"). +# 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. @@ -307,81 +446,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 @@ -430,62 +494,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 Sat Apr 1 08:46:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4C45C77B6C for ; Sat, 1 Apr 2023 08:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbjDAItQ (ORCPT ); Sat, 1 Apr 2023 04:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbjDAIsH (ORCPT ); Sat, 1 Apr 2023 04:48:07 -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 31B9E20D95 for ; Sat, 1 Apr 2023 01:47:22 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id bx42so2867278oib.6 for ; Sat, 01 Apr 2023 01:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NxExUwGAmU+W41qHeQpDY+jxHXuozbBiHk+T3Un1CHg=; b=jg1ijjwUvoa1LCKELk/h7MIVXLmH2uJuzgxv42Ng49QNCF9ghLmzKU+0N0pim78Yvs wXjwTuww2ZLPlSwuIqQqqeWtIPTxQeIlRrqKsff1TnwQ4b6JJ5TflnrshXcV6+bh2IdV 0lIEExAns4RRGBLh21wE77iGdcY0R//JZGX/7lK2RaQmq9Uy8OSm1yjZ5+0UaxEQy6QG otnW8pDFEKezQM+V6uzb9HCYj4WUJnB+Z4/zZC37nPMMRkaQ28UTo6GFb7S1oOR8GJSs QxjIZSa7yjW+vHxaS4kez6WYqsQ50ago/+lP4T3SWXclA3o7aQfiyzC8PcoX2/qZhosS JpnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NxExUwGAmU+W41qHeQpDY+jxHXuozbBiHk+T3Un1CHg=; b=np3Bsh80ihpuHrBcVY06asgphKmUSbqk0CdJqDGrlQUtK0BntVXyOrTd2KRW7LGDgX PWBN/LH2YIdkNj6aa/9VsC8i1UIe6TDvX4xrDIj/NvY80aseONUypsxZEI9rzbsUq5ad WdH8EwEamh42ABCc6vnzSmZY9SUHhDObYUG1kpDl+T/MRz74DkIBLGz3fgHurEQ15OEe aGgjlm7T3+OK19TmEjoVL/O219K5cXx9JmyuMJXxr5kKDLuZ9tEnxrsD6peRImrcjdb4 L8ZbG6NpuG4pCYVmbG7Ugj3MEuTJ2VHrx9dKpaWl/dbawMqEzXIczDZ7MMVCanOOUqE3 bQHQ== X-Gm-Message-State: AO0yUKUHCTTepL0lYTTDt0XNLnntZlxxLZ88I0WS+nzxeFE1eKuBKcn2 SrGPNKJjwQVqApIR4xCmzNg/w0mm5Fo= X-Google-Smtp-Source: AK7set8c+uPtsInPT8NX7ythkLxWAQfLKOT2lNMZQeIFcf1l+inxicZEWpArKlET8HyzWGfWRCKzlQ== X-Received: by 2002:a05:6808:a91:b0:387:3694:d5d6 with SMTP id q17-20020a0568080a9100b003873694d5d6mr13139802oij.25.1680338841247; Sat, 01 Apr 2023 01:47:21 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id m184-20020acabcc1000000b003896f132821sm1836650oif.41.2023.04.01.01.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:20 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 39/49] completion: zsh: simplify __gitcomp_direct Date: Sat, 1 Apr 2023 02:46:16 -0600 Message-Id: <20230401084626.304356-40-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 83d2bc99a1..170f3d7f5e 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -90,9 +90,7 @@ __gitcomp_opts () __gitcomp_direct () { - emulate -L zsh - - compadd -Q -S '' -- ${(f)1} && _ret=0 + __gitcomp_nl "$1" "" "" "" } __gitcomp_nl () From patchwork Sat Apr 1 08:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC1BEC76196 for ; Sat, 1 Apr 2023 08:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbjDAItY (ORCPT ); Sat, 1 Apr 2023 04:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbjDAIsJ (ORCPT ); Sat, 1 Apr 2023 04:48:09 -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 7BED124435 for ; Sat, 1 Apr 2023 01:47:23 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id ca2-20020a056830610200b006a11ab58c3fso12467402otb.4 for ; Sat, 01 Apr 2023 01:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X4DFSXu8Yh6tzVuWv6AAoEDXYX0CgqlwJ2CGJTlsapw=; b=ScKqQy2LPvXUkQTKTNLpami7Ink2esvlZt8cVq8/mLatEwWOhY8P94K+IDmAK6SAci Uf9VlLmRSJkY3myKintsQccd1NSHFmEYpaQ0rUXUjVg7IC6H51R0kf+GW22Dsrr7a2RM XrKj1pCRjS0bDwJ0Tj5zQTwH6BZmG8G0Lj92FGsHz3nHQTYWbl4Ar65ogoBj6hKLgcKA IUNZTbsHeOtZhduWSPs1vmpR9Zq/O5ed1iRt1XqPJLm4os98iSLiDYXvmV6WbZJsfhae fjdBUHN+wtDFF/SSHslYRrO3zaJBZ/TyGS7ch/4a7ih4TAx2CN9bKwQL/a794h1XZyYn eg6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X4DFSXu8Yh6tzVuWv6AAoEDXYX0CgqlwJ2CGJTlsapw=; b=QMnpFfh43a+Jd625th2rhKVM+NUIVpETG6re01gDiaTCCLzfQkkPtutDsMwOkZQ/3s TdVLfIc7fm2SWWic6gZuIVv1TenW7MgnlTKInJaTSjP6Q+0hPnLD5sUkucfASYR1tYnU 2voMqxaOAPUHH/PUAWmjM2d1kh1XoRu4noVq1+Ldw+bUthPFyl7cXNry1/6mwoJNyKMY GEQ7UYgBtvXjjD/uGKs/n/qwpdF7x/gNcEiBKxIeYS4dsPqbRTkFnKvk4vUDwpNQrPuY g+S7jMXln1ZXmSsaaIZYV3H4t6HXTN2rKQOdJ/08Nh0fnRJJu59oPqjpzvSCiqHjEH0i Zcjg== X-Gm-Message-State: AAQBX9fboVbFPNkc7Z4L+oc8ajrOHtHu+hk5hm3BY+9g/QggD4mkK7aR aydtJyyAwdFCrz+GgRflmk67c5g+QPk= X-Google-Smtp-Source: AKy350afxncUTWsy5T7lleFkLMaQwpnXFcIPmigYqatO+wk+5JtLyCBhJ4T2w0LMj3jGVZTdXy9Eyg== X-Received: by 2002:a9d:6206:0:b0:6a1:6eda:53ba with SMTP id g6-20020a9d6206000000b006a16eda53bamr4860609otj.27.1680338842570; Sat, 01 Apr 2023 01:47:22 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id k21-20020a0568301bf500b006a17bffbc61sm2086611otb.38.2023.04.01.01.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:22 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 40/49] completion: zsh: shuffle __gitcomp* functions Date: Sat, 1 Apr 2023 02:46:17 -0600 Message-Id: <20230401084626.304356-41-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 170f3d7f5e..dc04c5b703 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -88,11 +88,6 @@ __gitcomp_opts () compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 } -__gitcomp_direct () -{ - __gitcomp_nl "$1" "" "" "" -} - __gitcomp_nl () { emulate -L zsh @@ -107,6 +102,11 @@ __gitcomp_file () compadd -f -p "${2-}" -- ${(f)1} && _ret=0 } +__gitcomp_direct () +{ + __gitcomp_nl "$1" "" "" "" +} + __gitcomp_file_direct () { __gitcomp_file "$1" "" From patchwork Sat Apr 1 08:46:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20C80C76196 for ; Sat, 1 Apr 2023 08:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjDAIt2 (ORCPT ); Sat, 1 Apr 2023 04:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjDAIsP (ORCPT ); Sat, 1 Apr 2023 04:48:15 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6398024AD1 for ; Sat, 1 Apr 2023 01:47:24 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-17fcc07d6c4so11579394fac.8 for ; Sat, 01 Apr 2023 01:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vka5Rqm5gCIxmGMpmzySz/PgEqPe097/HMTBjmEmj4k=; b=FGkOUeEyVGvGm3HuD/i0syz5uG1CuVuOb/biRzsLfXLFRkVJWMA+tcG5GYYrCDB3l0 z0desIpEBnIZnrw4cAjPDu6memL41UAAuDkpemuaTo9u3acW1erGTgaCgGAORmZ7G4P4 h15Sify3U8q42tL/ZOTGJyADvTPdNoPtx6DPf/Q5LaG/uc0VZ80lQOw52xYFg2PecoY3 2bllr1DC4OUCTSYYp8vXmyQ13se6HuMZzDUMTsZ3OempmYnXjBavhQ0YKhdq815vlgpe v9kB1cE5YRpuDun/1l070BDt5wDwCozL4VVUgjB1bGPQdI9Oru4ldx8eKO/+SiiMsUTo 1Y4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vka5Rqm5gCIxmGMpmzySz/PgEqPe097/HMTBjmEmj4k=; b=Cb7DdHT/gaucVmnSt9gVlFmtAewwGRzmfMJstVbVvkXiIP+v1ps9xJDoo/F8HX2tTC Rm+1fm02zoz+nnMHT83jgJCSRdfFDjqAr2RFtsBrqmQVWaaCFYQ/K0xCNcqjJpfk7JQq FJcf5gm9zRpmEVpAuVGFqmP/5NbyRFCxL7c/u4ehBG55MjnioRMu0gh7YgvMGMewckcV +cdVAZzRBgVTI12/A7yaUrXwdIRZI/Rq6TNGjU88gEK0qkmZZdFLKAMgV9ra92y/1xZt VVXvdOB5FZUNqemQAsajpyy+j1MJGmOUtos2URhusbHzQtl9cWgWIJ1uJnt6jltfAKX9 IjIQ== X-Gm-Message-State: AAQBX9cukGgV6nUoJCzeRC1NqgYhchoCBmHY73HVRr5dpMKrBPk8SWf8 eRSHaCp0AmvSvJKSm3u/n1lWAAm+2dU= X-Google-Smtp-Source: AK7set8ZBA+G0PLv/RXUI6C9ZTlav6IaT9iyHFv3vqkf6ZTa4UsenN+sLEdBxEVRdbIsZysL2fedeg== X-Received: by 2002:a05:6870:47a2:b0:177:97ba:2ec4 with SMTP id c34-20020a05687047a200b0017797ba2ec4mr16760692oaq.3.1680338843872; Sat, 01 Apr 2023 01:47:23 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id zq42-20020a0568718eaa00b0016b0369f08fsm1736611oab.15.2023.04.01.01.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:23 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 41/49] completion: zsh: fix direct quoting Date: Sat, 1 Apr 2023 02:46:18 -0600 Message-Id: <20230401084626.304356-42-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 dc04c5b703..e2a7f55539 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -55,7 +55,7 @@ __gitcomp () emulate -L zsh local IFS=$' \t\n' - compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 } __gitcomp_opts () @@ -85,14 +85,17 @@ __gitcomp_opts () fi array+=("$c$sfx") done - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 + compadd -S '' -p "${2-}" -a -- array && _ret=0 } __gitcomp_nl () { emulate -L zsh - compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 + # words that don't end up in space + compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0 + # words that end in space + compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0 } __gitcomp_file () From patchwork Sat Apr 1 08:46:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB083C6FD1D for ; Sat, 1 Apr 2023 08:49:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229538AbjDAIt3 (ORCPT ); Sat, 1 Apr 2023 04:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjDAIsQ (ORCPT ); Sat, 1 Apr 2023 04:48:16 -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 D487F2220C for ; Sat, 1 Apr 2023 01:47:25 -0700 (PDT) Received: by mail-ot1-x333.google.com with SMTP id f19-20020a9d5f13000000b00693ce5a2f3eso13140038oti.8 for ; Sat, 01 Apr 2023 01:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LPXOEaQgKrS28LoKn/VPll64fi6LtXpVb3r9D5ItD38=; b=iGBsxUj48i9GOLBK8MpPeiQVOpoPgrATY0RjWqg/cRVazbAELvy073gRjzQU8XoC9z oiCAGskhyUownq2Jn4W+YGy+PDRikFAEiXGugiH/9kTORmYaa2imvDXw6fUMIW3t5GS6 3gRfQyy3OkQ/dd2QO9G0qDAuAFU8lQ9mxkTrNWU8U3oCI7YVwux/c8vTpkjW11GtLqCs t3D7CfSBfVOpRstATNCzWDxq4yOuw18PeTP5hQ1K3rdth1WU/zB8HMkEvXCRHK8AjOO2 pLhyQ0SFMcTbuWZUQZ8ds/1yBGfiRqLtntUXotdncO5Kgj2SSfibuHqaWjrsdz1sNNjN aFGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LPXOEaQgKrS28LoKn/VPll64fi6LtXpVb3r9D5ItD38=; b=ufGNOGsjpO4aUoPKmy6xATTCSIRa2IM1MP+zaPPeWpnR4s1jB/rO8mWwJ1+Crrt97X ptqlZBUALy2SxXUU8AzuSin1wIsMrTrXFo4fLx8+OVLO9L0oQwrK7ri9HhjFRGpNZlde oC0xlnLcY95BX/wdE9GMvvbQ4VftaHE5GPpA+S9kvh6o6+eWVdHI2jgAVEQ6dewPoo9u tXvBqiUNFpUDKAVLYeeNfGbLMC5BCt55vs/wFN4C5jDMnltL8jHL2IIg30kGnPIHzUzW tGF0X2YRCsuAohQxvV1dK/V2NkBDvOKveHnNOqBlp2LuWOfOtJIaFokShwTMMeYaSo7S 9Nhg== X-Gm-Message-State: AAQBX9fDWKaEwW2DTsUPusPKVIQO+1UfMi4HlzvzmYq5sp50tRmLzqhE vUCaxfayVkpbh1CnqZNQdjhx98lIn6k= X-Google-Smtp-Source: AKy350YEEeB/DOZlXbmXoNEvUhyRLuOarnmEwkHti0TfncxkxdqDmPpkb8LOJl9u1g2fuG60VYcpaQ== X-Received: by 2002:a05:6830:1e73:b0:6a1:4387:3c65 with SMTP id m19-20020a0568301e7300b006a143873c65mr10142446otr.38.1680338845301; Sat, 01 Apr 2023 01:47:25 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id m1-20020a9d73c1000000b0069fa35f05aesm2116435otk.28.2023.04.01.01.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:24 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 42/49] completion: zsh: add elements individually in __gitcomp_opts Date: Sat, 1 Apr 2023 02:46:19 -0600 Message-Id: <20230401084626.304356-43-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's useful to specify specific suffixes for specific words. This will be useful later on. Additionally two tests now pass because we are not using an array anymore. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.zsh | 6 ++---- t/t9904-completion-zsh.sh | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index e2a7f55539..ba7b0a7dbc 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -67,11 +67,10 @@ __gitcomp_opts () [[ "$cur_" == *= ]] && return local c IFS=$' \t\n' sfx - local -a array for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - array+=("--no-... ") + compadd -S " " -- "--no-..." && _ret=0 break fi @@ -83,9 +82,8 @@ __gitcomp_opts () else sfx="$4" fi - array+=("$c$sfx") + compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0 done - compadd -S '' -p "${2-}" -a -- array && _ret=0 } __gitcomp_nl () diff --git a/t/t9904-completion-zsh.sh b/t/t9904-completion-zsh.sh index 79c1368769..24fb2dda00 100755 --- a/t/t9904-completion-zsh.sh +++ b/t/t9904-completion-zsh.sh @@ -124,7 +124,7 @@ test_expect_success '__gitcomp_opts - option parameter' ' EOF ' -test_expect_failure '__gitcomp_opts - prefix' ' +test_expect_success '__gitcomp_opts - prefix' ' test_gitcomp_opts "branch.maint.me" "remote merge mergeoptions rebase" \ "branch.maint." "me" <<-\EOF branch.maint.merge Z @@ -132,7 +132,7 @@ test_expect_failure '__gitcomp_opts - prefix' ' EOF ' -test_expect_failure '__gitcomp_opts - suffix' ' +test_expect_success '__gitcomp_opts - suffix' ' test_gitcomp_opts "branch.ma" "master maint next seen" "branch." \ "ma" "." <<-\EOF branch.master.Z From patchwork Sat Apr 1 08:46:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1A89C76196 for ; Sat, 1 Apr 2023 08:49:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbjDAIth (ORCPT ); Sat, 1 Apr 2023 04:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjDAIs0 (ORCPT ); Sat, 1 Apr 2023 04:48:26 -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 4606B1EA27 for ; Sat, 1 Apr 2023 01:47:27 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id x8-20020a9d3788000000b0069f922cd5ceso13144516otb.12 for ; Sat, 01 Apr 2023 01:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7AvC3KavAHRh1VoplO51Hhsj9alfG8K6BA/hYxExGNE=; b=AUZvnlPpD6370N7e9LLEEgfJlIb5vl48R4mb+RhaofK6ApqiJlJy88oFZfEVoyspgJ KZGKVaf9yUNIfLWEXWwFw/3qk7kSj24oXR6SFJLd49P2zUeW09nPrP1JNdVRc3/6V2wQ jBfjhoD6qJiGhh5eeLvpPcGnDL/jv4P5HHSJffY9N8LJLtr1otauQCH1SZJZY+TOSRfi yyzNoA5vosvm+QllbEZbKT+ss/mK8JGxlYfKuE8bq/Ntlu6drHJU9NHFg/Y0dLYyx7F8 Rs+IfUExVmwRY0qSJw++TMemRHxdoQmmB8S5yYGuFoHvMOHsMS9fLADdTlzphQJS771i NRFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7AvC3KavAHRh1VoplO51Hhsj9alfG8K6BA/hYxExGNE=; b=1pucm+NS342ARdxJVFFgPSxA5DU3yp1Q742lwKIFZSpQnWQJkga+ro0uZhwPJNyV39 qQAHJ9PzlmKCKG4Al2ZIf7iDaQi/Q2OviKBjdm0nNUJfCn2ciVOn46KtZef3Aif3BZbf sWI/IsPqLzcB1BScwrcYt/3831N2I+DkdD4b7fQM/GM6cOB+avpaI7JuCoQsoL28W6ga XpVXIjl+41FCsgO32wq+qGSZHjMhnXBKOsm7bnHVspzcPh6Ofjv/DAJDuRnXB8aG4mr9 Tgm6wPHVvO5jnB77q5Xo6jbXa3lxPc2NZmD7y3x9Wyn7sY3lrjxKkCqd2r5uQGhojZfM my2w== X-Gm-Message-State: AAQBX9eTohGzdV/D9KKqd93ZghiVPC1RPJXBs8l7ihg7tCEPsRDN3+1Q Rs3vhzQqgfVMDqHc79n8bNCr+QjwhaA= X-Google-Smtp-Source: AKy350Z9yFXPM1gyjbUcllNMeSSJX+ysBK9A1tfnImSgm1Dmdlv0xF0s+DjoM8oFjUOSpQwV28h8pg== X-Received: by 2002:a9d:6ca:0:b0:69d:1f1d:4629 with SMTP id 68-20020a9d06ca000000b0069d1f1d4629mr6078492otx.6.1680338846756; Sat, 01 Apr 2023 01:47:26 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id xy9-20020a05687123c900b001718e65a5d0sm1187738oab.57.2023.04.01.01.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:26 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 43/49] completion: zsh: add __gitcompadd helper Date: Sat, 1 Apr 2023 02:46:20 -0600 Message-Id: <20230401084626.304356-44-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 ba7b0a7dbc..522b59cf5b 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -50,12 +50,16 @@ COMP_WORDBREAKS=':' GIT_SOURCING_ZSH_COMPLETION=y . "$script" functions[complete]="$old_complete" +__gitcompadd () +{ + compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0 +} + __gitcomp () { emulate -L zsh - local IFS=$' \t\n' - compadd -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }" } __gitcomp_opts () @@ -70,7 +74,7 @@ __gitcomp_opts () for c in ${=1}; do if [[ $c == "--" ]]; then [[ "$cur_" == --no-* ]] && continue - compadd -S " " -- "--no-..." && _ret=0 + __gitcompadd "--no-..." break fi @@ -82,7 +86,7 @@ __gitcomp_opts () else sfx="$4" fi - compadd -S "$sfx" -p "${2-}" -- "$c" && _ret=0 + __gitcompadd "$c" "${2-}" "$sfx" done } From patchwork Sat Apr 1 08:46:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEC6DC6FD1D for ; Sat, 1 Apr 2023 08:49:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbjDAItj (ORCPT ); Sat, 1 Apr 2023 04:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjDAIs2 (ORCPT ); Sat, 1 Apr 2023 04:48:28 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C7020C08 for ; Sat, 1 Apr 2023 01:47:28 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-177b78067ffso25638795fac.7 for ; Sat, 01 Apr 2023 01:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uTDY6nWzZarXMnwKTTTfGUvU5eJA3nBZvLkl9EYJQ4s=; b=CsnJ9KJ0Pm0Jz6kaCsp3wRtRLTfYINkJWLRu5DRUOu4g8ZDOE9AXvM0/LWZ7dDNSzx /AaQdTbt3vEpKyiY/zPGo7XrMvhJF945eywW+OiBIqrr1MxCCkGHZW46/qXQ9YyZGu5W zHg5ABD6jUFOeTad27qf2YYe4e6FEhcUK19pHhVsoZSJ4k9Ae7D1nYNreDI57Trmc8ju R9itiCb2yewQnRG2M1hAAicuVdL6t0lFhEA+Lu9DYA50s+tBpNNXoiS0Hophp2hpLpV9 1gtBibc5mUqTlUEwculk0a+enF4hPSqCociKs6HYKDC72en6XibUtN5Mu2jBgND7QsnQ 5DhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uTDY6nWzZarXMnwKTTTfGUvU5eJA3nBZvLkl9EYJQ4s=; b=gX0sAuPT5eKqpMX/xeiWkLA0OKCSryNIF7BZlDt+WeEUjd5GczljiKHuxnBd4lDNqr zwxfZFVJIv+fHWHcUEPFppPzSqUbZJ4aL6Duw+qf50nw4RwHL5q61UgySHb1hkzpknMI sTC4Rj5oJj/OZnukLfNfzzLMJE6dLKRfZ4oqr74zX2JlRys3uJTwt1m3ucA29fHlm5FH fA588SZYb8IGdIgkF7BkXSvHFsth3/u5Ks5YM7eaf3k8iwEQMDHNwcIELb3vxbN4wBxy 9KaGzvM0AYKYUrOo5Bw5ahOi597VBB/yAh6tE3VJQMHqxI+9ETqes5QWRwBc4Oyi5kIo L1vA== X-Gm-Message-State: AO0yUKU4TW/cF/vUM7Nyz5VN3ZjaK0brN31xsKU18u972VUEmW4m9pP3 taT47x7jR7bd5q3ClgRS9noBVvN5jaU= X-Google-Smtp-Source: AKy350ZGu73u3z1s/CcTR2TdFQqNBaEKifm5/JzsacZKRYqXZ4dmwcuMeRWMCgtNrndo5Q/XyM7Bmg== X-Received: by 2002:a05:6870:b512:b0:177:c4bc:c1c8 with SMTP id v18-20020a056870b51200b00177c4bcc1c8mr18938699oap.0.1680338848148; Sat, 01 Apr 2023 01:47:28 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id zh20-20020a0568716b9400b0017281100b75sm1710032oab.42.2023.04.01.01.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:27 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 44/49] completion: zsh: add correct removable suffix Date: Sat, 1 Apr 2023 02:46:21 -0600 Message-Id: <20230401084626.304356-45-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 522b59cf5b..31bf88c1c5 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -52,7 +52,7 @@ functions[complete]="$old_complete" __gitcompadd () { - compadd -p "${2-}" -S "${3- }" -- ${=1} && _ret=0 + compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0 } __gitcomp () @@ -80,7 +80,8 @@ __gitcomp_opts () if [[ -z "${4+set}" ]]; then case $c in - *=|*.) sfx="" ;; + *=) c="${c%=}"; sfx="=" ;; + *.) sfx="" ;; *) sfx=" " ;; esac else From patchwork Sat Apr 1 08:46:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87DB9C77B60 for ; Sat, 1 Apr 2023 08:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229584AbjDAItl (ORCPT ); Sat, 1 Apr 2023 04:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjDAIs2 (ORCPT ); Sat, 1 Apr 2023 04:48:28 -0400 Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71B93EC70 for ; Sat, 1 Apr 2023 01:47:30 -0700 (PDT) Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-177ca271cb8so25651815fac.2 for ; Sat, 01 Apr 2023 01:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5ClP4+G8EANBxoQLN9k+EL8E7lZ3C8NNyuypldIXcOQ=; b=X6HCtTRJNrkRrvHnPx80YJD5E0BT8PyqYL6M32SSGOVT7s6/zKFd+1ucARNd+ZJ2XE 3lfG5Hq9wB3O6ZC7XWhhmHPAPfVy1YwODAFOk2QLCbdrufT22tPVqFhypj99EkMU6SNC LEeQ8R9mdr6IIeJ0S2QLNeu8wXvViCQvTt68C/p9WVcn3moWCRe0/xcYlUXMiIOL8srZ 9HO7KaDPEav+wvNRwZd0cJyeshyRNpFFOmFcwarlwwZMOVPhmpTQc00zC4G4Tj7D4NqC 0f9ENtmhTU3h4zDC+8gMVbPDsjZqibHRqZb9w23bTmJg7AKiB3qOipox4YY3EfuT7xMC iXVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5ClP4+G8EANBxoQLN9k+EL8E7lZ3C8NNyuypldIXcOQ=; b=ToWPVbQlQSW4FZt6yXVEMoEtD1ksCVV1IITU92aOkdK1iQa2iKY3GbYjbwD7caRPQu ba0ex7lmkCurjz5+xM/PLbXePvjWY/CyV6WTUADIGDYUGwXYATSTTO/FIg2x1BLcyC3j X7iP088CEAtQ9Nsw1dr6o4LNpH+gKIM2F45i/ql9cT0vR6aK8j54Pum6Wd0XcogiMcEe NzvMKOsSEBCAtr4utiA5p1tXhsN6mxMzI5ty9icLrP4kD1kVCZakU9KvQ1MPz0Nt2Rly BwAfPWhim9HMGS5aAG97q7YIr2DtGdIWTGTx9RJHyo2BDNNBx8wf9rI39Psl/HrHGS7a XPmg== X-Gm-Message-State: AAQBX9dLU3kFl6DcGlYkiS0d2Dm7vmfCHsGKqDaWPVXNBMwS4rhBnEnv vpLb7u62fTnGiIPIOM1IFbfRswAC8gg= X-Google-Smtp-Source: AKy350YdICyeE7dYJP7BKyXYLgLrd9GvD2q5uRwjgqDPiblW56O1/rVnHVIp27VU+WPHSCMcYc+NHQ== X-Received: by 2002:a05:6870:2046:b0:172:48e:b8c4 with SMTP id l6-20020a056870204600b00172048eb8c4mr5620760oad.17.1680338849438; Sat, 01 Apr 2023 01:47:29 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id k21-20020a0568301bf500b006a17bffbc61sm2086689otb.38.2023.04.01.01.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:29 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 45/49] completion: bash: simplify _get_comp_words_by_ref() Date: Sat, 1 Apr 2023 02:46:22 -0600 Message-Id: <20230401084626.304356-46-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 3f48b61cbe..7b46ce503d 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -419,30 +419,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 b4ed415245..fdc81d5d3f 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -40,23 +40,10 @@ GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase' # So let's override it with a minimal version for testing purposes. _get_comp_words_by_ref () { - while [ $# -gt 0 ]; do - case "$1" in - cur) - cur=${_words[_cword]} - ;; - prev) - prev=${_words[_cword-1]} - ;; - words) - words=("${_words[@]}") - ;; - cword) - cword=$_cword - ;; - esac - shift - done + cword=$_cword + cur=${_words[cword]} + prev=${_words[cword-1]} + words=("${_words[@]}") } print_comp () From patchwork Sat Apr 1 08:46:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BB1AC6FD1D for ; Sat, 1 Apr 2023 08:49:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbjDAItn (ORCPT ); Sat, 1 Apr 2023 04:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbjDAIs3 (ORCPT ); Sat, 1 Apr 2023 04:48:29 -0400 Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B1AC24ADB for ; Sat, 1 Apr 2023 01:47:31 -0700 (PDT) Received: by mail-oo1-xc36.google.com with SMTP id i4-20020a056820138400b0053e3ccf739cso2991061oow.10 for ; Sat, 01 Apr 2023 01:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7zDVUklVnqdCHHIueKcYsEjxBEjEGyahRgIWWt6aQ0Q=; b=NtSRF5k96hsLQp3Bpj4+3gZq+/8ApjHsffWXYZ1L9PEngE1HNIv3O60Scj1p0phNF+ vM3wLEKoZyOT6gQOiU28uCvPJf9NLXkfkADxfKTdCPdx+/7fZjnuCVFuLicwwTpQOA3O 5tJ/kgH3yYUzTmJMGN+b4NDoYmKkxocZC4W9GSq+3lBJdgxo3/XftEjlixwOCM8CgpWO j9e0wL93ebgM/f+uC4ZJMZZr+RhjH2RtrWEVY0it7jsPxDhbPULXERXxqhhx8/X+ozIA wWcJClESx+GC2KaHQqN3ng3LQGwT7b/6hoCNaajOKdOEJYAM2Zby+2ee5u8bXPOcLlpQ FUkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7zDVUklVnqdCHHIueKcYsEjxBEjEGyahRgIWWt6aQ0Q=; b=AZBA2JRSIqfolB7WxhQtQBmeLzVTaxgZFgEEwwxTcOFfdyilbAyNdVCpILKze7duPR afQg9vfMHk94JcDcdCegwAiiRA3ULfYCRDG8DoMvWriA1CGZ0Bt2uaqv5tDUenQ0VFN5 wLBUT6dlWwlUjscrVTjbY598xWM4z+pfJo5xxZQod3L5KHulQ6PdESiz5f6oxAseg+XU Bw2Jzuzhmr7yROPNvbzG/xpDQS9hx/Etu7d0lSCUTe+v/beQ9iJN4hrLVmQTqsoevX+9 QICO+2Hd0nTaqwDdR83y/WV+LSNbYxaYkHq4Twej8mvhIlqE9z88JT4e0mC3+Q+M5+B+ pa6Q== X-Gm-Message-State: AO0yUKUcpnx3MUS/9SqiH3rjFH/j1h1huXnPnFPZ2DaqNRHZZdNW3iqE 20gipMKNRoF1fMSMwAP8NQOV4PqJrns= X-Google-Smtp-Source: AK7set+LmS0QKfjY47vnIYCuynZWWhlLSDqeGbSphQRxaCOXwlyiDoctRnd0fMR1zIfvL+iqivSQYA== X-Received: by 2002:a4a:5515:0:b0:53b:6112:3b16 with SMTP id e21-20020a4a5515000000b0053b61123b16mr14929188oob.9.1680338850955; Sat, 01 Apr 2023 01:47:30 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id x80-20020a4a4153000000b0053d9be4be68sm1791768ooa.19.2023.04.01.01.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:30 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 46/49] completion: bash: refactor _get_comp_words_by_ref() Date: Sat, 1 Apr 2023 02:46:23 -0600 Message-Id: <20230401084626.304356-47-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 | 109 +++++++++++-------------- 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 7b46ce503d..63a9409b0e 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -345,21 +345,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. # @@ -367,60 +357,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() -{ - local exclude i j first - # Which word separators to exclude? - exclude="${1//[^$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= - 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 -} 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 "=:" + local exclude i j first + + # Which word separators to exclude? + exclude="${COMP_WORDBREAKS//[^=:]}" + cword_=$COMP_CWORD + if [ -z "$exclude" ]; then + words_=("${COMP_WORDS[@]}") + 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 + done + fi + cword=$cword_ cur=${words_[cword]} prev=${words_[cword-1]} From patchwork Sat Apr 1 08:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EF20C6FD1D for ; Sat, 1 Apr 2023 08:49:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbjDAItv (ORCPT ); Sat, 1 Apr 2023 04:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbjDAIsc (ORCPT ); Sat, 1 Apr 2023 04:48:32 -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 303F525444 for ; Sat, 1 Apr 2023 01:47:33 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id r17-20020a05683002f100b006a131458abfso10560201ote.2 for ; Sat, 01 Apr 2023 01:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5THhBzqZa9EofGWOAyZV8jWlNg5vf4MHIUNurWOd0JQ=; b=GG+uooKBEhthhB+uT1IYBzzbESihZhmglIeal9XU8u6X30wba1RGOHGzavKNcCWTw5 m+taT8ShadKWBAVSMBuCQTjeFkLQITscz3RBEl2acV1hFwjrYMM5L+uLj6N8W/ax8H6/ lhuN8fQcc/mfHWFXEBWlij9myrmQjGqLkFZjvVS1WJn+pZewyS6N1U2Zq/8Ez2f2ybX6 NHR9jnlsBvmmb7QYYv+Buvjbx8A2+NvjBZU28UQRj0PQEUdgnvXcBUncm8QjLG/fFz1R 6xk/Jt5doR6qT2EP/PMIYyHdR5DzYg70iexwkzwYt8o9FdwK8FU4lbIcTui8amVoQSHq tVDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5THhBzqZa9EofGWOAyZV8jWlNg5vf4MHIUNurWOd0JQ=; b=gWLJxIwQLP3D/2m57TncRYIMROfHrVNj+5q2fAo9v3A0PaI71A3gZpSwExyehadqME /2KtnNXd+yFlIoDgtEijJPPmQY1ZelITluYfoMtaQzclZwLNvPas4FTUmFAfvRBrDZUC 7au+zHQFsl321kHNgmT707Tks7f5du3e/FYq9O1WZHmfDlzDK+7D+RtVmvhtrBnzuU0d p7N1TbLgdw29Cb9D+Nt+taw4vTdx2BknXIa++8PiVK95Ah4709BWVbjRuAH0RoVKi13s 7qjWd+JzMd0AJvceGzYMYBRLv8shZZop4u871bfIfjYiT/Iot44nEvCP4kT6UyScfUkD VeYQ== X-Gm-Message-State: AO0yUKVwAUtF397vr7RuFdJRmJIQbnRaXzHew9QGyhtklep3A3SJ48bE RE48xdO+bVWmrjeAWokM7p+YuQqQzm4= X-Google-Smtp-Source: AK7set/CarITfiahfdgQkPZYPf7veF2ySus4XPeF24sYq86kqTXD72b9OK+QJdpMLhDLyIVyf9850w== X-Received: by 2002:a05:6830:1659:b0:69f:b247:6da5 with SMTP id h25-20020a056830165900b0069fb2476da5mr14078982otr.4.1680338852244; Sat, 01 Apr 2023 01:47:32 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id e2-20020a0568301e4200b0069dc250cb24sm2074087otj.3.2023.04.01.01.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:31 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 47/49] completion: bash: cleanup _get_comp_words_by_ref() Date: Sat, 1 Apr 2023 02:46:24 -0600 Message-Id: <20230401084626.304356-48-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 63a9409b0e..1b594f01cb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -361,14 +361,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. @@ -388,9 +387,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++)) @@ -399,17 +398,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 Sat Apr 1 08:46:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7C8DC76196 for ; Sat, 1 Apr 2023 08:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjDAIt5 (ORCPT ); Sat, 1 Apr 2023 04:49:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjDAIs6 (ORCPT ); Sat, 1 Apr 2023 04:48:58 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ACA42544D for ; Sat, 1 Apr 2023 01:47:34 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-17ac5ee3f9cso25620378fac.12 for ; Sat, 01 Apr 2023 01:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gT1CU6EZWwx8W3GKw+UVigE449TynC1T+rJxjyNa0zM=; b=dSmsSFaueI3zsIWFvLuCduCXyBDxPbJ3u0X17/3o8QZzEW8WPTqYGpe5oPAXcIYBRw BSTanbkclY8RaGpaqO7QdT940gQBb3VufTpquHHTbx7ZSZPfyWZobq56r4EpQoDiOuGH qwMt3ZMdieM+Uf4oqfbQ+0zpRdmSNeT69lgxpxUgnwMgwIJR0Q9WOnqw62jY1Sxx2/jd cocDIZ0gL4+Z3UbFJsigi08Ls3XIwuOvn/qZ/Y16p0B473OLvLaXq29PeiXDbeD1al86 d0dgDHt12DxsekL6ab30P+1fvS09NCS5ObZzhVxxXrNI7sRNssDo96Fgk0KfsDwLFXGH aJlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gT1CU6EZWwx8W3GKw+UVigE449TynC1T+rJxjyNa0zM=; b=F/iImDC11UCzZlG52+B+aaBMXC53dySJptXqDjgtpuTRusOr3D/0ENGsgcds56ho+q PLsMSc6/T1SGIcKdx0PPu8tkcJIkjxmD3TpYtmLh/37IrnPDQaOR+pvMdP2BBAopVgr5 dOZOeriMmiupcTf+HMVKmQ3lG3BcFZgi5z/vhGNzp0Utvr1pPDGXegLQVOuy+a6Aol4u fUOIMkrVltHbYFWA8nHXl5omvQuga+6ux9sPBaULDBhFrhVoBFM5Z2E7V8s7nvBdNqLp 2udrXuhOCbIFG4he69kqcHtb+KI+3Ea+2Yhzsk+2g3M4a2Scu3G2UUbuz1wFsng6DYPo fhAQ== X-Gm-Message-State: AAQBX9dXjC66d+6QjhDhYeiwhx8G/5W2s7xjPPiKwprNyLoSEjY2Kr3E H6SXCV8zFLXNikNEwBLoFev2hgC6hPg= X-Google-Smtp-Source: AKy350bPlN0MqKA5J+tsq0R2XCI+TYXe9un9/AYFWQ8+AmVRpMjXEamXh0p/Aqypjrm3xUTUQUzjHg== X-Received: by 2002:a05:6870:1fcd:b0:172:5de5:785 with SMTP id gp13-20020a0568701fcd00b001725de50785mr19854004oac.6.1680338853515; Sat, 01 Apr 2023 01:47:33 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id vj12-20020a0568710e0c00b001762ce27f9asm1743123oab.23.2023.04.01.01.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:33 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 48/49] completion: bash: trivial cleanup Date: Sat, 1 Apr 2023 02:46:25 -0600 Message-Id: <20230401084626.304356-49-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-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 1b594f01cb..912e9bace0 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -366,9 +366,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 @@ -403,6 +401,8 @@ _get_comp_words_by_ref () cword=$j fi done + else + words=("${COMP_WORDS[@]}") fi cur=${words[cword]} From patchwork Sat Apr 1 08:46:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 13196819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12842C76196 for ; Sat, 1 Apr 2023 08:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229847AbjDAIt7 (ORCPT ); Sat, 1 Apr 2023 04:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjDAItM (ORCPT ); Sat, 1 Apr 2023 04:49:12 -0400 Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DE9E24AC9 for ; Sat, 1 Apr 2023 01:47:36 -0700 (PDT) Received: by mail-oo1-xc30.google.com with SMTP id n6-20020a4abd06000000b0053b59893660so3893004oop.0 for ; Sat, 01 Apr 2023 01:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680338855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FboxFHXAvuHAXLLLcpnPIgT5TfNRdtF5ghQt1JU/Hsk=; b=JHEbmOlKahCbZcSXY8pZR1PWyX9k5tVxTehHJrl+fdMJE5aUqKqY8bvtHjYA7RmskK Bfb5gmoU6vEskANodcJgPJNkEtvKhJ2mMTltSvXbh+jtJQY41jtrgvz4HfULkCNUBWGO N9XJhMxN9fD1MM+E1y7/rdfcq9z6HLdCR1UL9cNPkU13cZ49Fdcyn/PC/vPza/4/po8P a4Ny6VRWBvJyclvjrN8f2enhhbH9hytZgf6aEjAvJsBjin87b9MGACYIaI60Jdrgl8FF ax5Q8cS0n+vI40vge3u/EcD5RxL61g2/k3JL2iEEBcQ2uQdfiAxXqhvzKK09DP4RMejX qHMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680338855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FboxFHXAvuHAXLLLcpnPIgT5TfNRdtF5ghQt1JU/Hsk=; b=CgPpRk3ssD1txrFRN40LUfZJHTwxBRihYg1lRx9qEsbiDk2DNtUWVThNElYkJtKppn nARqt02OWi3Rz2t3DEAORqUcxO/cfxxfhXYCXhh9SwyJnV4IDnrtmPXJTtzOc/TzgPUY VpT6rMsZC0tgXMnLi7QzkEemttUdeEkO4b0+D3Q/L4ThEb4eMtDL0YLlxzzU6K5w/rfS nRCdII0EhyFBOUfB0wXA17yLNV6VB4oUyuYEqqmuvMSjrBQfRgFvqnBEYHGrPy1PxANH eHj7Dvu8dyQ6EfmZwJ2GQc6qpaM9OoHKe4E6ASu7bRhhKBUAJ+sDEB1+SCZnfFXwjntx CSHg== X-Gm-Message-State: AAQBX9fVY93A0oPV+E0IGalYesbjjNRTYgGHkkoc+gD/xEmKFpiVt64g hQJmlLOol8IcUjUDS1HJQ6GxEgkM1Mo= X-Google-Smtp-Source: AKy350beyBr9EdJRPvLlQlyU8m3ufz2SR8AIhfxJ1hhX6nfqKpJKgObJ/fejSpIzranqS5xX2aThSQ== X-Received: by 2002:a4a:e591:0:b0:53e:1b5f:1b63 with SMTP id o17-20020a4ae591000000b0053e1b5f1b63mr5469074oov.0.1680338855026; Sat, 01 Apr 2023 01:47:35 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id k125-20020acaba83000000b003876369bd0asm1867296oif.19.2023.04.01.01.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 01:47:34 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Felipe Contreras Subject: [PATCH v7 49/49] completion: bash: rename _get_comp_words_by_ref() Date: Sat, 1 Apr 2023 02:46:26 -0600 Message-Id: <20230401084626.304356-50-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230401084626.304356-1-felipe.contreras@gmail.com> References: <20230401084626.304356-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's only used in one place, rename it, and use it even if bash-completion's more inefficient version of _get_comp_words_by_ref() is available. Signed-off-by: Felipe Contreras --- contrib/completion/git-completion.bash | 186 ++++++++++++------------- t/t9902-completion.sh | 2 +- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 912e9bace0..b36db3f845 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -318,98 +318,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 @@ -3497,10 +3405,102 @@ if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then return fi +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald +# © 2009-2010, Bash Completion Maintainers +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function reorganizes the words on the command line to be processed by +# the rest of the script. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude '=' and ':'. The intent is to +# make option types like --date= and : easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. + +if ! type __git_get_comp_words_by_ref >/dev/null 2>&1; then +__git_get_comp_words_by_ref () +{ + local exclude i j first + + # Which word separators to exclude? + exclude="${COMP_WORDBREAKS//[^=:]}" + cword=$COMP_CWORD + if [ -n "$exclude" ]; then + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words[$j]=${words[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + break 2 + fi + done + words[$j]=${words[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword=$j + fi + done + else + words=("${COMP_WORDS[@]}") + fi + + cur=${words[cword]} + prev=${words[cword-1]} +} +fi + __git_func_wrap () { local cur words cword prev __git_cmd_idx=0 - _get_comp_words_by_ref -n =: cur words cword prev + __git_get_comp_words_by_ref $1 } diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index fdc81d5d3f..18f88133de 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -38,7 +38,7 @@ GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase' # We don't need this function to actually join words or do anything special. # Also, it's cleaner to avoid touching bash's internal completion variables. # So let's override it with a minimal version for testing purposes. -_get_comp_words_by_ref () +__git_get_comp_words_by_ref () { cword=$_cword cur=${_words[cword]}