From patchwork Tue Aug 13 12:26:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F23F14D5 for ; Tue, 13 Aug 2019 12:27:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6076627F90 for ; Tue, 13 Aug 2019 12:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5495027FA1; Tue, 13 Aug 2019 12:27:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D0B127F90 for ; Tue, 13 Aug 2019 12:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbfHMM1J (ORCPT ); Tue, 13 Aug 2019 08:27:09 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45382 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbfHMM1H (ORCPT ); Tue, 13 Aug 2019 08:27:07 -0400 Received: by mail-wr1-f66.google.com with SMTP id q12so17304096wrj.12 for ; Tue, 13 Aug 2019 05:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kI9kicHyvLzAfgSyFlOaXyAL+U2oZ/ak5cHcnwhKiRU=; b=ll7RwVCY3ao+bP2ISjQTK3ActTJv5+HKi0wyV0l3lPEKrYFn3UgNeehF0+N3YZpW0b jznXfjF/3n0VbE6F0/zjGDLjezU/hqSom/BX4nIMw1P4Qd5F4vTKm/nSbMh/TFD9xCcy YQKOwavoZhSkhankRN7JYYvXd1U0rtlgmLLRssT9++sjnWJzRX738uIsEb2DbP0xFBQ5 E1n+uBui7QGWX5DVaNOBQ8WtvFXvclBZnLUcKzOh6c9vCKgveHVN3yMux5MfWZ85sAFs l021LgiEFE9z2+PuuQwFlrx0k7ighDLw8Izsnelkxv9QfSXj5qS59RU0wPN40q6jEOMb a5Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kI9kicHyvLzAfgSyFlOaXyAL+U2oZ/ak5cHcnwhKiRU=; b=VXnac/iLBsrQRbCI4suDufcDe4Fvd8B+kKOM5bX3aCJhpMDCV8m0TEGC9nZSYtsbuv q8Jfqa0xPYX/hH2Xt24miULwwNOOegFUt26ZaQfk1SdQqjksBcQgXBdV3w5AZx1aPAZp P5g6oHp5PU8MFQsyI3WVWmJai4LlEO3HykjPWJzzGm8juXjRAmw0laCIpnmnJAZOSn1Q 4nU5Cp7X5asDAY+fmTJJkC8/hF4Ujo7OAKCwtmot+TARHKPc3C98BlQHasLMMuwdLEME x79MYyH2ln8ys7yE5nA3RYu1FHoePGsvxG9Jo3+baeSIgHeAopB1a9szNvqVH8pf8Grc 4nUg== X-Gm-Message-State: APjAAAVLE+Y0p+KPTsqDwBOnyLetjACz9NGWDXiyJF39Uf0bhKmowXQa XjlgB0n0oDNG8+cc/zSjduE= X-Google-Smtp-Source: APXvYqwLsRTBrqWzrXPnFDpHESaZ/wLubbQZpapIxRtHV8RD8QjYJR1wI1DsCnf9DdT7p7uyb0KJHA== X-Received: by 2002:a5d:534f:: with SMTP id t15mr37683866wrv.239.1565699225215; Tue, 13 Aug 2019 05:27:05 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:04 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 01/11] completion: fix a typo in a comment Date: Tue, 13 Aug 2019 14:26:42 +0200 Message-Id: <20190813122652.16468-2-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: SZEDER Gábor --- 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 e087c4bf00..cd9d8e1940 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -524,7 +524,7 @@ __git_index_files () # Even when a directory name itself does not contain # any special characters, it will still be quoted if # any of its (stripped) trailing path components do. - # Because of this we may have seen the same direcory + # Because of this we may have seen the same directory # both quoted and unquoted. if (p in paths) # We have seen the same directory unquoted, From patchwork Tue Aug 13 12:26:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE4CB14DB for ; Tue, 13 Aug 2019 12:27:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD4A27F90 for ; Tue, 13 Aug 2019 12:27:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A22B927FA1; Tue, 13 Aug 2019 12:27:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48F0527F90 for ; Tue, 13 Aug 2019 12:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727297AbfHMM1J (ORCPT ); Tue, 13 Aug 2019 08:27:09 -0400 Received: from mail-wr1-f51.google.com ([209.85.221.51]:33594 "EHLO mail-wr1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbfHMM1I (ORCPT ); Tue, 13 Aug 2019 08:27:08 -0400 Received: by mail-wr1-f51.google.com with SMTP id n9so107685363wru.0 for ; Tue, 13 Aug 2019 05:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Lf73a4k5qNaZ0MsWkZqS8r3G+DF6g1OFUgOp7gFTHK8=; b=pm5D3toCn8dGpWKnz+8mAoOikRiRE04cW8GpAJvueUGEXC5wEJ2u0LunDW1RHjTgwl Uo5KnffDEbAXU1xqkIuT9WS2ctLCongqA8mj+fqkQ6BakULOtFkQPXLIniTdJLOiZ4e7 I1dWeOXsJeQv205TGKl9eKDOC11wF/z/oj8gU4rW3tkwN12l/xC/KVxunBPRMqRUyDqe HFMi5IkshqUxBm5aJsLwpyCn3MXEgibZOqZZ1sef453U4CMKnOvkOhNzZtMKMAfVdRsd teuepPqUQrI+XdMJNdNwrCzo/blCHRGkkChdRgyB0lxGFn06nltyNFL/LMxmHu1YIadQ Tiow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Lf73a4k5qNaZ0MsWkZqS8r3G+DF6g1OFUgOp7gFTHK8=; b=WT4a8JgKfMScfjVAANfDS26KtCgst9XJNhYMqxSlrX8coGawI33qM0ZrWc2RAWzThW 1Zci3rBsGwU0cahiQEghuVGuOsBT3eEDLvJFYw05fe0ZXmniV+Dmxtk4BJxnRgBEkX4A yDxAINrsEtGcXJwEtHkYFwTiiyVHq0fBIfuRvbw3lHO8/oJg7FTSQ6Etp5DnewqAgqsn uYhokiUHihway0M3cx85hiDnzHVkkOUd5yPhG+1HtPhqmEUhEWKObIketjTDRKZups5U DE8CuMzFdV0hbfuhBNYaQAPqY3ScbGAU9ITT2XHfuxyllzojRm2Focg/2BeZ59P4ufFW cK4Q== X-Gm-Message-State: APjAAAV07bteIKKOXiHe5y9/hdwDM6eTiFAtKK8DnJxTD2UmP50kS0PY B11lvxfAdTMJ90FCjshS9gM= X-Google-Smtp-Source: APXvYqwvDmWI1WWhlF9e8LkfPXxNxLV906M4Cgd5GR792CBRYzJ4wIUv1MUqu2mOmLz1wifLIhKIIg== X-Received: by 2002:adf:e710:: with SMTP id c16mr37588747wrm.292.1565699226271; Tue, 13 Aug 2019 05:27:06 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:05 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 02/11] completion: complete more values of more 'color.*' configuration variables Date: Tue, 13 Aug 2019 14:26:43 +0200 Message-Id: <20190813122652.16468-3-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Most 'color.*' configuration variables, with the sole exception of 'color.pager', accept the same set of values, but our completion script recognizes only about half of them. We could explicitly add all those missing variables, but let's try to reduce future maintenance burden, and use the catch-all 'color.*' pattern instead, so this list won't get out of sync when a similar new configuration variable accepting the same values is introduced [1]. Furthermore, their documentation explicitly mentions that they all accept the standard boolean values 'false' and 'true' as well, so list these, too, among the possible values. [1] OTOH, there will be a maintenance burden if ever a new 'color.something' is introduced which doesn't accept the same set of values. We'll see which one happens first... Signed-off-by: SZEDER Gábor --- Notes: I find the documentation of these configuration variables confusing. A so-called "boolean" (quoting the docs), that besides 'false' and 'true' (and their standard 0,no,1,yes and non-standard 'never'/'auto' synonyms) can have a third possible value 'always', too, is, well, not a boolean. contrib/completion/git-completion.bash | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index cd9d8e1940..c59347daee 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2277,11 +2277,6 @@ _git_config () __gitcomp "$__git_merge_strategies" return ;; - color.branch|color.diff|color.interactive|\ - color.showbranch|color.status|color.ui) - __gitcomp "always never auto" - return - ;; color.pager) __gitcomp "false true" return @@ -2293,6 +2288,10 @@ _git_config () " return ;; + color.*) + __gitcomp "false true always never auto" + return + ;; diff.submodule) __gitcomp "$__git_diff_submodule_formats" return From patchwork Tue Aug 13 12:26:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 669D314D5 for ; Tue, 13 Aug 2019 12:27:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53B9827F90 for ; Tue, 13 Aug 2019 12:27:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4817D27FA1; Tue, 13 Aug 2019 12:27:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4A1927F90 for ; Tue, 13 Aug 2019 12:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727805AbfHMM1M (ORCPT ); Tue, 13 Aug 2019 08:27:12 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:42891 "EHLO mail-wr1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727441AbfHMM1L (ORCPT ); Tue, 13 Aug 2019 08:27:11 -0400 Received: by mail-wr1-f42.google.com with SMTP id b16so10862399wrq.9 for ; Tue, 13 Aug 2019 05:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rpg6miNQgY/QZ2BwmfrL7B5ff9+w0baFgPS1fYfNOqU=; b=EzqAndQdl7RwVN/jidX5/c3sZaLTblx4fGu7G/+7DRuK3KJcKTg0mt/UKl/5UqW8O9 arfwxcAk/MtQfgUpytMAZ6fTAZPe0HJugyEEmVMERqPiwcI0Fq/g/WIe5R9rA5QhtgEH P+7Krbc7m+IYId9aDbOMJ65JN0c/giALc7yr3W544Cx9ytBUl+dAO/zFKc/FCQthms3f Z2TSDIkqzJsno6U/lQ7FpZbTkPDn2rtPzO+vjY1wzzQVdZu5fckjTKiUIfN2rQmUidKW D7vhLSgg78hUj8pUzglqOn3m0yz13GclZPXS2ZZursjT0JUqDsw8dAHRYCBUaV8UU805 bA/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rpg6miNQgY/QZ2BwmfrL7B5ff9+w0baFgPS1fYfNOqU=; b=X591g2YUrpsBF3ensaa1VIw3yorIz0q1na35OPERB/oGthQijCTvvlPrdpg5pUMxMQ BIA52eR50toV/M0Y7s5LoI11NOzB0kxMTNpJjCfwvbHX2kRNOXHdh8EqMxcAU10Ptbi0 49n3MaYREngORgbl8zO0H6PFsvSv8WWZPGeYEOjD0V64frYh+Aac9X5IQIBouJO32bos oI5fnNKWMOtM/0k0lbmBks7xdGrQ3Bho8c0Jwc3PkVlKHARFfZWa1/5uuMozSrp7E4/z YAtVS4CkL/1nK5oNtr/yhVTdfidhXacmZnCPLTNqJKatC2V7zMhe7ztCvV8UghMAnPy6 jgYQ== X-Gm-Message-State: APjAAAUwB0hVaOkbELYP7L9g4W4k0kZR/osPISvLTG+tWCSqu0MQRfO+ FwqZPol/8q3B8plLA+KaRMY= X-Google-Smtp-Source: APXvYqw3S0fSB0VfaD3cwAJl3h263j6UkGvzfJujNONYtOp21U4dw25em64qJSsHeYcVKgec5jEtlg== X-Received: by 2002:a5d:460e:: with SMTP id t14mr23402220wrq.171.1565699227407; Tue, 13 Aug 2019 05:27:07 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:06 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 03/11] completion: add tests for 'git config' completion Date: Tue, 13 Aug 2019 14:26:44 +0200 Message-Id: <20190813122652.16468-4-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The next patches will change/refactor the way we complete configuration variable names and values, so add a few tests to cover the basics, namely the completion of matching configuration sections, full variable names, and their values. Note that the test checking the completion of configuration sections is currently failing, though it's not a sign of an actual bug. If a section contains multiple variables, then that section is currently repeated as many times as the number of variables in there. This is not a correctness issue in practice, because Bash's completion facilities remove all repetitions anyway. Consequently, we could list all those repeated sections in the expected output of this test as well, but then it would have to be updated whenever a new configuration variable is added to those sections. Instead, list each matching configuration section only once, mark the test as failing for now, and the next patch will update the completion script to avoid those repetitions. Signed-off-by: SZEDER Gábor --- t/t9902-completion.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 75512c3403..e15be1164d 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1698,6 +1698,27 @@ do ' done +test_expect_failure 'git config - section' ' + test_completion "git config br" <<-\EOF + branch.Z + browser.Z + EOF +' + +test_expect_success 'git config - variable name' ' + test_completion "git config log.d" <<-\EOF + log.date Z + log.decorate Z + EOF +' + +test_expect_success 'git config - value' ' + test_completion "git config color.pager " <<-\EOF + false Z + true Z + EOF +' + test_expect_success 'sourcing the completion script clears cached commands' ' __git_compute_all_commands && verbose test -n "$__git_all_commands" && From patchwork Tue Aug 13 12:26:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF36314DB for ; Tue, 13 Aug 2019 12:27:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D043527F90 for ; Tue, 13 Aug 2019 12:27:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C469527FA1; Tue, 13 Aug 2019 12:27:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61EA427F90 for ; Tue, 13 Aug 2019 12:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727735AbfHMM1L (ORCPT ); Tue, 13 Aug 2019 08:27:11 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]:37547 "EHLO mail-wm1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbfHMM1J (ORCPT ); Tue, 13 Aug 2019 08:27:09 -0400 Received: by mail-wm1-f47.google.com with SMTP id z23so1284395wmf.2 for ; Tue, 13 Aug 2019 05:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9sVFiPRYTiEpvaDUvRdNMe1WTbGPvV2CpZYi/D0PW+Q=; b=LBM4x/dy1ZrqTdKHsRbur9ef695a2ri0W6z6GSRpfQKsAGvPAudxIqeO4S0A1oeD+k bTP5db2AL6QF7akQwhy/jAq/PQ/bJnL/BxR3cYijggmYdoxDiMHKncT5Dy//iTxcLXZT TMBvqqzsO4Uf3nwkJCncJC2HPOfyV1snwXS3Flt+ZYsOWTdqAWFTlCHnKDDoI0TP74DR XLHbrFNnNAptWl8gAEm7MGoXyWaOWoE3I0jBfqrYvTdpdD+Vxd2tjW8eYAdciU/Tb/7R unr198BHsWzBmQqMJdhI/fAnFP3iYNx4Wk5t38recrRmkQV3Hf0M/moQnHjUOKswp1Uh /mMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9sVFiPRYTiEpvaDUvRdNMe1WTbGPvV2CpZYi/D0PW+Q=; b=kZMLJKzLKOKTsfLEyKqg25fqbA3nhwWyFle2Fur5THbDwgvxx1NF2akRAf2Y8ShOE3 Zcc5eWtZNx6I9BRfRg/x9M9TllPk8m6+XhipxdWyRWcPydzF4YDcB+dIWNSruKHwQMBa Srwje1ghcwbYferrTlrs+0pgZaLaViiEKjcFaJJIqAygCCKF9JkXzIFiqB9mnP7+o6UI x8A0EGN9PTbF63DhbChqX1P9FieSywRoIQT3SymJmmpyMOzsnB2kHo0ZlpbhI4ubghNw AGEXnFBx7z3JiYdzNMfdtJhtP+rNCI95gfCicxsTzdEX/bxmGOrWfwZaQBYQeEJBvrui 1QbA== X-Gm-Message-State: APjAAAXuxFnq5LIAHdUB8mwAI4L2s6Nw3Hdx5H0saiHJNTTAZB9RFN4H y6XC530pIu4K3+VL39iUrso= X-Google-Smtp-Source: APXvYqz7mtOnariMzXFw9urxOUWujichAKk/ICymjR0XWOLLb2hVztBYp+uVkAGU44rlAk8VeTd5gQ== X-Received: by 2002:a1c:f101:: with SMTP id p1mr2860196wmh.151.1565699228472; Tue, 13 Aug 2019 05:27:08 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:07 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 04/11] completion: deduplicate configuration sections Date: Tue, 13 Aug 2019 14:26:45 +0200 Message-Id: <20190813122652.16468-5-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The number of configuration variables listed by the completion script grew quite when we started to auto-generate it from the documentation [1], so we now complete them in two steps: first we list only the section names, then the rest [2]. To get the section names we simply strip everything following the first dot in each variable name, resulting in a lot of repeated section names, because most sections contain more than one configuration variable. This is not a correctness issue in practice, because Bash's completion facilities remove all repetitions anyway, but these repetitions make testing a bit harder. Replace the small 'sed' script removing subsections and variable names with an 'awk' script that does the same, and in addition removes any repeated configuration sections as well (by first creating and filling an associative array indexed by all encountered configuration sections, and then iterating over this array and printing the indices, i.e. the unique section names). This change makes the failing 'git config - section' test in 't9902-completion.sh' pass. Note that this changes the order of section names in the output, and makes it downright undeterministic, but this is not an issue, because Bash sorts them before presenting them to the user, and our completion tests sort them as well before comparing with the expected output. Yeah, it would be simpler and shorter to just append '| sort -u' to that command, but that would incur the overhead of one more external process and pipeline stage every time a user completes configuration sections. [1] e17ca92637 (completion: drop the hard coded list of config vars, 2018-05-26) [2] f22f682695 (completion: complete general config vars in two steps, 2018-05-27) Signed-off-by: SZEDER Gábor --- contrib/completion/git-completion.bash | 10 +++++++++- t/t9902-completion.sh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index c59347daee..f89324d84f 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2398,7 +2398,15 @@ _git_config () ;; *) __git_compute_config_vars - __gitcomp "$(echo "$__git_config_vars" | sed 's/\.[^ ]*/./g')" + __gitcomp "$(echo "$__git_config_vars" | + awk -F . '{ + sections[$1] = 1 + } + END { + for (s in sections) + print s "." + } + ')" esac } diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index e15be1164d..008fba7c89 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -1698,7 +1698,7 @@ do ' done -test_expect_failure 'git config - section' ' +test_expect_success 'git config - section' ' test_completion "git config br" <<-\EOF branch.Z browser.Z From patchwork Tue Aug 13 12:26:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0365E14DB for ; Tue, 13 Aug 2019 12:27:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9A4427F90 for ; Tue, 13 Aug 2019 12:27:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDECD27FA1; Tue, 13 Aug 2019 12:27:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9351B27F90 for ; Tue, 13 Aug 2019 12:27:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727936AbfHMM1O (ORCPT ); Tue, 13 Aug 2019 08:27:14 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:56294 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbfHMM1L (ORCPT ); Tue, 13 Aug 2019 08:27:11 -0400 Received: by mail-wm1-f66.google.com with SMTP id f72so1320431wmf.5 for ; Tue, 13 Aug 2019 05:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qEEc/uPwXOZ/C7M3KgAp6PY7nx3k9Bx5aSlvMLcRh8o=; b=Junvw+256qA7JtaiPNLz8qmIYV9BdIa93YdrCqJL+9oCuSHKNbRdPON/oKff9698qk rEj3KBkTnfJG1M5XhLv/HrUJ6N447LH2mp6IMD8m+q146nXGVybr6P8WqmMHnCXFqSMU NxSijySb1+LWoQnaHplQXWN7fE9aClXIThJNk5qtgViQ58xUyZRuzSIQROMl6nLqkgBn 7NgoYLHpK6OZVgoVBfa/kJXo4QMMo6T+gc2kpLI9U/JB6hp49jz2TXCpUNDemnvfWOi3 Hdc40SJoq6nmmO52z9RR0Ve49V3Bf3Fm51dk+au4FpBnkdsWGPm7WhY2iePnZomC0Ne2 gKMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qEEc/uPwXOZ/C7M3KgAp6PY7nx3k9Bx5aSlvMLcRh8o=; b=WDfCN09kLpDetOp1av8jwnirF/kqIGNEAUPHlHz8OwKzz9FVXgMRl/3UvJiMv+ZCFD MpDVmSSbBScV064wFDf+ZeQpv3hJMHMUqB7sCeQ/R8sLXg9NPddcd8ocp+FvGCA3i8js pWeakFUyus3VWG3LyD3WSNm9m7RBFCGARwyuv6LLOWxXep8WjlVeIYvtS1e4f0cS+5eT 6fR3HJLuqOFemRo+mvr7YRlrxSZSu5+62eDZtExE5yEemQoyvl7SPe79SICdMqhhdmi+ laPO2tEb0YqZDP0f+rKmdenlf7IM/CdXBzg9I8NTADjrLgmb/PSzyqaEbnkdOdCfPWEQ wHEA== X-Gm-Message-State: APjAAAVQj2yYDB6IYd6xMoTNs47LGNbtamnptdf9mdL+HBY6/pCKw0Gc XUhr8iNIAazurGP5kafKDBXTGBuV X-Google-Smtp-Source: APXvYqwUJSBnFlVhKHyNbDXpBD5gv+wuUsmOGuep7P4BOLw8NafVcUAD2GL1vneyy8LujoiQFiHb4w== X-Received: by 2002:a1c:1bd7:: with SMTP id b206mr2797481wmb.85.1565699229534; Tue, 13 Aug 2019 05:27:09 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:08 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 05/11] completion: use 'sort -u' to deduplicate config variable names Date: Tue, 13 Aug 2019 14:26:46 +0200 Message-Id: <20190813122652.16468-6-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The completion script runs the classic '| sort | uniq' pipeline to deduplicate the output of 'git help --config-for-completion'. 'sort -u' does the same, but uses one less external process and pipeline stage. Not a bit win, as it's only run once as the list of supported configuration variables is initialized, but at least it sets a better example for others to follow. Signed-off-by: SZEDER Gábor --- 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 f89324d84f..b51cb31ea1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2225,7 +2225,7 @@ __git_config_vars= __git_compute_config_vars () { test -n "$__git_config_vars" || - __git_config_vars="$(git help --config-for-completion | sort | uniq)" + __git_config_vars="$(git help --config-for-completion | sort -u)" } _git_config () From patchwork Tue Aug 13 12:26:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 240DE14D5 for ; Tue, 13 Aug 2019 12:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 161F427F90 for ; Tue, 13 Aug 2019 12:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AE0A28384; Tue, 13 Aug 2019 12:27:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABA3827F90 for ; Tue, 13 Aug 2019 12:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727979AbfHMM1R (ORCPT ); Tue, 13 Aug 2019 08:27:17 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52862 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727763AbfHMM1M (ORCPT ); Tue, 13 Aug 2019 08:27:12 -0400 Received: by mail-wm1-f67.google.com with SMTP id o4so1193377wmh.2 for ; Tue, 13 Aug 2019 05:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7cMLCe7Tn9V2Rz3rzEmefYJxohZzhmWgiLfDv0VcZ2w=; b=W+3GN+2Ls3pIjmw5RcGhsJdyRPsXVBV+Fk+dlJnBHsTe4GsBkIfoxirXfBrlNFIJTX jf9FQl23hVkc8AtXaN6j6hVdJoV27oTITxrbPKOxN9hGhBJT0We7/pI1cuHoND3qEZNB DrGQYKCCyxsawJoXpNEE1zwgH1xhHWLcRUv5Iq6QDPgf8IAX+i9GaY4rt6G/yD3fyLsZ BLadleKwtEGF58wXazycOQoOQdw1EGpreEDWGqsmLsZn5HaCWAIzDf2L/8k4/TfqoPBw 5lVp614FUPkB9K3IEEjzOVbX1/53dVnf5njKwdF3wbqVS27moWBJYJLjzPby6PJVbBcs f41A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7cMLCe7Tn9V2Rz3rzEmefYJxohZzhmWgiLfDv0VcZ2w=; b=qTKxhUanYQt76zAKUmrMLS+jU5EVWYdLDq2GBTjMJvau5ndjnohPObQyGg5pJJOQqi pIL8xOKqzKV6RjvhObiz6VDT1fRkOSLH1tNRf5OrhQNBiyVnV78qjNrTvbotOUb7onL2 SmmtxNSHSwBmw+UjqU41yx4Yq2pqusaNPJAvzPml9jJJm4+fk9pf5BAjOeSvJ4d4i24D 18wZ6LTWGIGxT7jZODRFXmRLmXaA6jAAYvb7ei7azcfsNRqvKUJjeKmnkPiQamNgz6Qi U7TSH7v6SJjtDmCaua3AB7386ij5o5f30aN5gYfjycQpkhs2tVVmVxx+e3DEQYcpjB2V ohXg== X-Gm-Message-State: APjAAAWtxF6o4qDVQiqoZc8B+3lIbX5gI1TtVBpZOAM60/yEX7tHni83 yHzwyUUDfaoTltV5wkNEF+E= X-Google-Smtp-Source: APXvYqw7qHQKk1TPik/jkmSfWUJ48v+peu19BEEBVuuBss2Ty8sdZy+DVrlv/8Gl+ogvCxLE/nTa0Q== X-Received: by 2002:a7b:c04f:: with SMTP id u15mr2887142wmc.106.1565699230655; Tue, 13 Aug 2019 05:27:10 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:10 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 06/11] completion: simplify inner 'case' pattern in __gitcomp() Date: Tue, 13 Aug 2019 14:26:47 +0200 Message-Id: <20190813122652.16468-7-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The second '*' in the '--*=*' pattern of the inner 'case' statement of the __gitcomp() helper function never matches anything, so let's use '--*=' instead. The purpose of that inner case statement is to decide when to append a trailing space to the listed options and when not. When an option requires a stuck argument, i.e. '--option=', then the trailing space should not be added, so the user can continue typing the required argument right away. That '--*=*' pattern is supposed to match these options, but for this purpose that second '*' is unnecessary, a '--*=' pattern works just as well. That second '*' would only make a difference in case of a possible completion word like '--option=value', but our completion script never passes such a word to __gitcomp(), because the '--option=' and its 'value' must be completed separately. Signed-off-by: SZEDER Gábor --- contrib/completion/git-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b51cb31ea1..fc437bf3eb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -340,7 +340,7 @@ __gitcomp () c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in - --*=*|*.) ;; + --*=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" @@ -360,7 +360,7 @@ __gitcomp () c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in - --*=*|*.) ;; + --*=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" From patchwork Tue Aug 13 12:26:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1F6114DB for ; Tue, 13 Aug 2019 12:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2F1D27F90 for ; Tue, 13 Aug 2019 12:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C743527FA1; Tue, 13 Aug 2019 12:27:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F46F27F90 for ; Tue, 13 Aug 2019 12:27:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727962AbfHMM1Q (ORCPT ); Tue, 13 Aug 2019 08:27:16 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36250 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727441AbfHMM1N (ORCPT ); Tue, 13 Aug 2019 08:27:13 -0400 Received: by mail-wr1-f68.google.com with SMTP id r3so13836329wrt.3 for ; Tue, 13 Aug 2019 05:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q5GAZQfyOKiZ5snJgFv3wwkBIVmAMGvSCBoSJ4Dpkxk=; b=eBMrgbIXp/qLS+bphcNlSmtQlV6ARvDsHct4smkMwXHXRPVQb1GsrLlQoOlJzF14XS dg1EJTW0+ou9baokRjaiTLABkY5XCNwmAWAWddM0vkuun4NY6aTEgvwj1+PwKB3nfXhj Kb7AvpgjMDb3itgi96IaRTFJxT82PJwXqAdnES8H/xBlKCErnW5GgAQp11T2NlHcnJWi OSvmqnsT9a+Sare/tx56wnbfSDYBz+wm4jmFp1af2LDmRhlgJEOciaePuMzhCTGGAlcs 8hCrQeYLSENox+kCIzz8K2cHLW87zx+kWap/iSXDMqimrXiIFIZAVrLuoFTiwYGggQV3 +0Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q5GAZQfyOKiZ5snJgFv3wwkBIVmAMGvSCBoSJ4Dpkxk=; b=McY+ndVFx/IXh4tMN7sRk+H5pJLj4uvUAdQR4MMBcjH97yEo7S7ry94rKz9GTy2oid LpaSwIz8TO/ej8z2rbta8cNqgdvycrvfdQdGQbKmO6seWhQemoPLpjzny1lL1gLZJeRW RPCfbNvd28/xMhj/ps0dgXCMmQSoPiMA/2UkFwE8RICVKZjcvjGO2LtkfQz3I4GeP081 GQvdkC8Y4xbIIlZ4UMgVC+pHYURcl5PAkQ6XoRs2mdQ5KH9pHkJ5Tye8XdccD1NFbv92 CbhWWShrmBRLHC35Bv2FFAyq2PWfcjC1PDmmaR9Cb84+gDGlp+fCnUm9jn6Ph8MjHbzC N5Pg== X-Gm-Message-State: APjAAAUH1f5fi8kI5Hz3E3DQIWXRllhjKF3WfPew6YKvLz/aZMlX3M78 sSb3tL8ffQaQW/j3vskBZOWUbK5s X-Google-Smtp-Source: APXvYqx4Hlk4Qag6boeUjiYBMFpFCADZ+RdvIDdD8CQAIgZ8EVFcKYN9hxspi6JmOdX2uJkvNRFRoQ== X-Received: by 2002:adf:ca0f:: with SMTP id o15mr46165022wrh.135.1565699231724; Tue, 13 Aug 2019 05:27:11 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:11 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 07/11] completion: split _git_config() Date: Tue, 13 Aug 2019 14:26:48 +0200 Message-Id: <20190813122652.16468-8-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP _git_config() contains two enormous case statements, one to complete configuration sections and variable names, and the other to complete their values. Split these out into two separate helper functions, so in the next patches we can use them to implement completion for 'git -c '. Signed-off-by: SZEDER Gábor --- contrib/completion/git-completion.bash | 39 ++++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index fc437bf3eb..3e9c5b6b71 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2228,7 +2228,8 @@ __git_compute_config_vars () __git_config_vars="$(git help --config-for-completion | sort -u)" } -_git_config () +# Completes possible values of various configuration variables. +__git_complete_config_variable_value () { local varname @@ -2320,19 +2321,16 @@ _git_config () __gitcomp "7bit 8bit quoted-printable base64" return ;; - --get|--get-all|--unset|--unset-all) - __gitcomp_nl "$(__git_config_get_set_variables)" - return - ;; *.*) return ;; esac +} + +# Completes configuration sections, subsections, variable names. +__git_complete_config_variable_name () +{ case "$cur" in - --*) - __gitcomp_builtin config - return - ;; branch.*.*) local pfx="${cur%.*}." cur_="${cur##*.}" __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" @@ -2407,6 +2405,29 @@ _git_config () print s "." } ')" + ;; + esac +} + +_git_config () +{ + case "$prev" in + --get|--get-all|--unset|--unset-all) + __gitcomp_nl "$(__git_config_get_set_variables)" + return + ;; + *.*) + __git_complete_config_variable_value + return + ;; + esac + case "$cur" in + --*) + __gitcomp_builtin config + ;; + *) + __git_complete_config_variable_name + ;; esac } From patchwork Tue Aug 13 12:26:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11092113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7481F1823 for ; Tue, 13 Aug 2019 12:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 655BA27F90 for ; Tue, 13 Aug 2019 12:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5985A27FA1; Tue, 13 Aug 2019 12:27:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA4C27F97 for ; Tue, 13 Aug 2019 12:27:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727972AbfHMM1R (ORCPT ); Tue, 13 Aug 2019 08:27:17 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:42905 "EHLO mail-wr1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727933AbfHMM1O (ORCPT ); Tue, 13 Aug 2019 08:27:14 -0400 Received: by mail-wr1-f44.google.com with SMTP id b16so10862669wrq.9 for ; Tue, 13 Aug 2019 05:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rEPmkj+POqXtHaTq12MU/27C0/Y21KxJ2xUmkHNWaL0=; b=mSfG1QsUyUwkN7txdHI/bznEEz17livqsLdH2wmdUNoZ2IMhqFaIXGQ8KM/jW+l6wp Jon7IwiWEVwA347fd4a7LBSGf26LXZDXHqGb6zpevaXNakYx6IhSldEJFw5HBG8sAO/n Su8BgZwqT/2sTWd8yo4WxHJcmenbzccHLZ9zPw0d65pZlCeFRwjq66X93wH3PFeKMqds XAitcTWg6y+1Z/3gRPFTOkQFE1M4pD1+4nV2OFk7V0EZBIadcjyyLVBT7wmzYxlOzm+b x+SVdXhlYdn7ePVdV5BSTKDmWAn4eVfysV2xGefLYHENGxuKnzFY7GWbNeBjE1DeV9z+ PxdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rEPmkj+POqXtHaTq12MU/27C0/Y21KxJ2xUmkHNWaL0=; b=HorM61IqyYhqewnZsvXJY5Xo71sWOqmttYUHOdYoOn9pCqHuUgBigD/onktLjy6ghA mXJDcpGF/H/86CubC0bBVF4kCdALePNX4dMl2IIKztPM8dg7LCvtexMlFHdMtBha9gqn 4bZOciyZrnLBhwwl7W1ZiZeAlemyzXy2eFZ45W1XOKiTSGcSCck8a+O1ZrF1BtaPFFMG 6JD0nc31tK1spStrtQZe3ejIBwM3muS+xb+M7LzGiSTTVxdncp1IJjOvqLUQNt/G+3uG OpcnotH1hHEwjvbQlDk5JGsno58O3xMcUR8Mg2yWz55g1/fgO9S7YU+B7OJK5zo0iQ2B rd8g== X-Gm-Message-State: APjAAAW8LFhsaQVsm46kxDqUfbNtvf8JVh0B+EjRw55qLoCbXKUB3kyR 6dGNeOrixuwco3Ms+L/4KKU= X-Google-Smtp-Source: APXvYqzuCF4+36xqEkeRFJbQp/8gLBhP3lNmWZ/sae68mU1avZPH/Vg1K1Q/gWMOMYWvFiXmzo8HhA== X-Received: by 2002:adf:d182:: with SMTP id v2mr18121521wrc.49.1565699232819; Tue, 13 Aug 2019 05:27:12 -0700 (PDT) Received: from localhost.localdomain (x4db44abf.dyn.telefonica.de. [77.180.74.191]) by smtp.gmail.com with ESMTPSA id r5sm1978069wmh.35.2019.08.13.05.27.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Aug 2019 05:27:12 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 08/11] completion: complete configuration sections and variable names for 'git -c' Date: Tue, 13 Aug 2019 14:26:49 +0200 Message-Id: <20190813122652.16468-9-szeder.dev@gmail.com> X-Mailer: git-send-email 2.23.0.rc2.350.gf4fdc32db7 In-Reply-To: <20190813122652.16468-1-szeder.dev@gmail.com> References: <20190813122652.16468-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 'git config' expects a configuration variable's name and value in separate arguments, so we let the __gitcomp() helper append a space character to each variable name by default, like we do for most other things (--options, refs, paths, etc.). 'git -c', however, expects them in a single option joined by a '=' character, i.e. 'section.name=value', so we should append a '=' character to each fully completed variable name, but no space, so the user can continue typing the value right away. Add an option to the __git_complete_config_variable_name() function to allow callers to specify an alternate suffix to add, and use it to append that '=' character to configuration variables. Update the __gitcomp() helper function to not append a trailing space to any completion words ending with a '=', not just to those option with a stuck argument. Signed-off-by: SZEDER Gábor --- contrib/completion/git-completion.bash | 59 ++++++++++++++++++++------ t/t9902-completion.sh | 14 ++++++ 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 3e9c5b6b71..367b1c50f4 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -360,7 +360,7 @@ __gitcomp () c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in - --*=|*.) ;; + *=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" @@ -2328,18 +2328,33 @@ __git_complete_config_variable_value () } # Completes configuration sections, subsections, variable names. +# +# Usage: __git_complete_config_variable_name [