From patchwork Wed Aug 19 23:06:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Zoeller X-Patchwork-Id: 11725187 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 51F71109B for ; Wed, 19 Aug 2020 23:06:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AE6B20758 for ; Wed, 19 Aug 2020 23:06:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=rtzoeller.com header.i=@rtzoeller.com header.b="AJk+EUdV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgHSXGY (ORCPT ); Wed, 19 Aug 2020 19:06:24 -0400 Received: from mail2.protonmail.ch ([185.70.40.22]:33941 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726209AbgHSXGX (ORCPT ); Wed, 19 Aug 2020 19:06:23 -0400 Date: Wed, 19 Aug 2020 23:06:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rtzoeller.com; s=protonmail; t=1597878380; bh=olbI1EAyvdKbBD1foJYoCGD2Dt/yIeiSdxqSTKX8XAg=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=AJk+EUdV022tBIC4fwwIMhBD1JTD6hrsZDMplgj8GpTG4myz/MObgRX7M8OsAojAs MsK/Obj9EoS0rDMBJzDT9Ud+b7QBaGdtRRnWJ62cugTkfYreSM23tpSqbN49ICGn1s FygW8iDM//XCH/Gk/m/sjgsjbfgJG68KJayw9Fcw= To: git@vger.kernel.org From: Ryan Zoeller Cc: Ryan Zoeller , Junio C Hamano Reply-To: Ryan Zoeller Subject: [PATCH v2 2/2] completion: add GIT_COMPLETION_SHOW_ALL env var Message-ID: <20200819230523.773348-3-rtzoeller@rtzoeller.com> In-Reply-To: <20200819175047.692962-1-rtzoeller@rtzoeller.com> References: <20200819175047.692962-1-rtzoeller@rtzoeller.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mail.protonmail.ch Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When set to 1, GIT_COMPLETION_SHOW_ALL causes --git-completion-helper-all to be passed instead of --git-completion-helper. Signed-off-by: Ryan Zoeller --- contrib/completion/git-completion.bash | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 700d44af5b..9147fba3d5 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -39,6 +39,11 @@ # When set to "1", do not include "DWIM" suggestions in git-checkout # and git-switch completion (e.g., completing "foo" when "origin/foo" # exists). +# +# GIT_COMPLETION_SHOW_ALL +# +# When set to "1" suggest all options, including options which are +# typically hidden (e.g. '--allow-empty' for 'git commit'). case "$COMP_WORDBREAKS" in *:*) : great ;; @@ -411,10 +416,17 @@ __gitcomp_builtin () local options eval "options=\${$var-}" + local completion_helper + if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then + completion_helper="--git-completion-helper-all" + else + completion_helper="--git-completion-helper" + fi + if [ -z "$options" ]; then # leading and trailing spaces are significant to make # option removal work correctly. - options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return + options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return for i in $excl; do options="${options/ $i / }"