From patchwork Thu Sep 12 19:43:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11143691 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E11314E5 for ; Thu, 12 Sep 2019 19:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DB6A208C2 for ; Thu, 12 Sep 2019 19:43:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gOBaUnl9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726270AbfILTn6 (ORCPT ); Thu, 12 Sep 2019 15:43:58 -0400 Received: from mail-pf1-f175.google.com ([209.85.210.175]:41819 "EHLO mail-pf1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbfILTn6 (ORCPT ); Thu, 12 Sep 2019 15:43:58 -0400 Received: by mail-pf1-f175.google.com with SMTP id b13so16600547pfo.8 for ; Thu, 12 Sep 2019 12:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JMFyGPaW8u0D+73VKD7Y+f05/5ugjxDsVNTdQrXP2EM=; b=gOBaUnl9BayIjoJGHKPj+rzxS42v3DKt033KBPxQGjLTfdqnF4jWpw+/y3nJErLxDK tRJX+7Juwy0NQJ8nQMEz9BMs1T2icGLwEnYCsElsJ9JbiqSj36HKQb84kVza/VhJYB7r nw9Q+kXgqpWM6rdkJRf7o1AGHR5jqXJZGD4DvLHhADPQscOBecBaTG+T86sKSHB2QQ0C Ik5qOikCOlKqGdLQ4Ss6ZmRt4ChFoKDu1YG+to15kRIYAiR0L2TdEJ+kPuR7mw1XlV0b GS8evsLYs7S0WhNeC1j/YLqDloE91O4XAWi/qzRJrh2wXgeYsyWpQSOlgKqfGA+YKtUU QNzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JMFyGPaW8u0D+73VKD7Y+f05/5ugjxDsVNTdQrXP2EM=; b=XMpxVCjw7V/JRSbgpstpb1Aq/LhqFhYQ8whtfOtSu3RYu0ZOsWEFshDCCXtI2mKrme XWE+5AoOqtOeGDrMm3suKWrM5ejXN9TGRMd4OD5wkNoqUuLZ2zYTrzmdrDIWNLKnrvML C6yOlFnawG8X9ctRdb9gEGKwBUBQaBbMwYymPErjRV+2OY5o1DpnZus6A1+U1SP74k4X Rmhphwsd8+MKGggeJwFvw+qKlgibeieoeKQw9VvcV3gyrygWJ62n2aq4VW5/n16jsUU7 kHst1wKkyZpSW64kiNsds8w3XfBfpe0fG9T1S6JgRuDm7BfW79V1zX7T5yrLRm8lscVr Fh4Q== X-Gm-Message-State: APjAAAXleFnvsVkXmDldYUVOHjnB8uKFkDAMoQ+i0ouCgcJE8E+ffjQX FTl8YL5pYyDlrhL1QO5OQB0m6DAJVqk= X-Google-Smtp-Source: APXvYqy+x8a56iViFrK/DlCoSP/7na1YG8zvbYylvAkOeVVRSwhEauzBCXdHSRVUjAF555EBlF/uKg== X-Received: by 2002:a17:90a:f993:: with SMTP id cq19mr385434pjb.51.1568317437067; Thu, 12 Sep 2019 12:43:57 -0700 (PDT) Received: from dentonliu-ltm.internal.salesforce.com ([204.14.239.55]) by smtp.gmail.com with ESMTPSA id q186sm36279001pfb.47.2019.09.12.12.43.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 12:43:56 -0700 (PDT) Date: Thu, 12 Sep 2019 12:43:55 -0700 From: Denton Liu To: Git Mailing List Subject: [PATCH 1/2] completion: teach rebase to use __gitcomp_builtin Message-ID: <7c4f2361842f5a9cbaf6130cafe1dd77f75e19e0.1568317093.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, _git_rebase() uses a hardcoded list of options for its completion. However, we can use __gitcomp_builtin() to get a dynamically generated list of completions instead. Teach _git_rebase() to use __gitcomp_builtin() so that newly implemented options in rebase will be automatically completed without any mucking around in git-completion.bash. Signed-off-by: Denton Liu --- contrib/completion/git-completion.bash | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index e087c4bf00..365edff639 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2004,15 +2004,18 @@ _git_range_diff () __git_complete_revlist } +__git_rebase_inprogress_options="--continue --skip --abort --quit --show-current-patch" +__git_rebase_interactive_inprogress_options="$__git_rebase_inprogress_options --edit-todo" + _git_rebase () { __git_find_repo_path if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then - __gitcomp "--continue --skip --abort --quit --edit-todo --show-current-patch" + __gitcomp "$__git_rebase_interactive_inprogress_options" return elif [ -d "$__git_repo_path"/rebase-apply ] || \ [ -d "$__git_repo_path"/rebase-merge ]; then - __gitcomp "--continue --skip --abort --quit --show-current-patch" + __gitcomp "$__git_rebase_inprogress_options" return fi __git_complete_strategy && return @@ -2022,19 +2025,8 @@ _git_rebase () return ;; --*) - __gitcomp " - --onto --merge --strategy --interactive - --rebase-merges --preserve-merges --stat --no-stat - --committer-date-is-author-date --ignore-date - --ignore-whitespace --whitespace= - --autosquash --no-autosquash - --fork-point --no-fork-point - --autostash --no-autostash - --verify --no-verify - --keep-empty --root --force-rebase --no-ff - --rerere-autoupdate - --exec - " + __gitcomp_builtin rebase "" \ + "$__git_rebase_interactive_inprogress_options" return esac From patchwork Thu Sep 12 19:43:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11143693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA28E14E5 for ; Thu, 12 Sep 2019 19:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 995CD20856 for ; Thu, 12 Sep 2019 19:44:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="REu8acFC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726313AbfILToA (ORCPT ); Thu, 12 Sep 2019 15:44:00 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40101 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbfILToA (ORCPT ); Thu, 12 Sep 2019 15:44:00 -0400 Received: by mail-pf1-f194.google.com with SMTP id x127so16608587pfb.7 for ; Thu, 12 Sep 2019 12:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PuxrZCshsJn0K4a8+y9RZiLsGUxqZYYjB/oMeXHB74g=; b=REu8acFCRoQTiblG0ngK2VCCFLN1VpsdPDtfbKoLoIvirWB9EpV8YSW98sVWisko6X qL+n18eb5XrxOy7sxK5iGmVnQ3R5JSv8udFNa4liOptwWiUdc4NE1BGsDQCNQW34VlwL Oa3Dd+y1FbGSg4N+MaGzPrvEQKfXWBaj3qbdunuJ25VVgLZ1EB/c5VPm8mWI4OOvYyPa Nb+0UTIMvDBwwkq8McND4c3IEYonb8WJlam9UANrPhhsDcW0YXyPQxQ+IePUS7+W1uCL LrI9DDo0P+iqWOD0XrfNO0oURO2u6kIQDmVNwKuOROyKrQXTgjJdFkWsqaPTPTxDcpUy OBpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PuxrZCshsJn0K4a8+y9RZiLsGUxqZYYjB/oMeXHB74g=; b=osmET/Dx+aAS2GzaZvWSJHP9kQO1Z/bAw0R7if30hzrcbGWVcqTUzJF9LPhx2LjGm6 ct7zj18MLA7U5nOgxRaRJt/Sns0unRTXMmo5ttprimijMF6W0Z75o8pGiurKVYayaqkh mLR9+FzF1Dg3bGsEdSjsjV4LNY7onbENdhCdjfvcMwARqXuk8VISOocUH8ej+Ls2CXU6 WpCaRHCdkiCaPdPU7aSYn1H3qRWSHKSG1v/KR8OB7zwfDKt30c5VK+t0IftcBI9f996y x6hrnTFK/m5EChRrOxr2cmhUSjs4P+MvE4xVRn7nMRAiotB6rpndaS2a2r+qKlicvuJL aKVQ== X-Gm-Message-State: APjAAAVKG6JVFtmB5DIrf5/8MktH97nVoKXlUyrb1ZByL8zpidWX1YDa Lkz+AeHr0czcf2sfudYtMMbAEpGyQm0= X-Google-Smtp-Source: APXvYqw7eZC0TKTqLsXXUCo50DJgeFen1WgXnYMe3B7cAShc6uS6TyE9xJKeNLX3Mphc/1+TZxO02Q== X-Received: by 2002:a17:90a:e57:: with SMTP id p23mr392510pja.126.1568317439300; Thu, 12 Sep 2019 12:43:59 -0700 (PDT) Received: from dentonliu-ltm.internal.salesforce.com ([204.14.239.55]) by smtp.gmail.com with ESMTPSA id s1sm95867pjs.31.2019.09.12.12.43.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 12:43:58 -0700 (PDT) Date: Thu, 12 Sep 2019 12:43:57 -0700 From: Denton Liu To: Git Mailing List Subject: [PATCH 2/2] completion: teach archive to use __gitcomp_builtin Message-ID: <39d6091ce636b2d732d589b55e7686796694e994.1568317093.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, _git_archive() uses a hardcoded list of options for its completion. However, we can use __gitcomp_builtin() to get a dynamically generated list of completions instead. Teach _git_archive() to use __gitcomp_builtin() so that newly implemented options in archive will be automatically completed without any mucking around in git-completion.bash. While we're at it, teach it to complete the missing `--worktree-attributes` option as well. Unfortunately, since some args are passed through from cmd_archive() to write_archive() (which calls parse_archive_args()), there's no way that a `--git-completion-helper` arg can end up reaching parse_archive_args() since the first call to parse_options() will end up calling exit(0). As a result, we have to carry the options supported by write_archive() in the hardcoded string. Signed-off-by: Denton Liu --- contrib/completion/git-completion.bash | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 365edff639..7b1ab46f0b 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1250,10 +1250,7 @@ _git_archive () return ;; --*) - __gitcomp " - --format= --list --verbose - --prefix= --remote= --exec= --output - " + __gitcomp_builtin archive "--format= --list --verbose --prefix= --worktree-attributes" return ;; esac