From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Felipe Contreras" <felipe.contreras@gmail.com>
Subject: [PATCH 22/47] completion: refactor __gitcomp
Date: Thu, 31 Dec 2020 20:15:57 -0600 [thread overview]
Message-ID: <20210101021622.798041-23-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20210101021622.798041-1-felipe.contreras@gmail.com>
We have to chunks of code doing exactly the same. There's no need for
that.
No functional changes.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
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 0522750b9f..b356e3c86f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -325,44 +325,28 @@ __gitcomp ()
return
fi
- case "$cur_" in
- --no-*)
- local c i=0 IFS=$' \t\n'
- for c in $1; do
- if [[ $c == "--" ]]; then
+ local c i=0 IFS=$' \t\n'
+ for c in $1; do
+ if [[ $c == "--" ]]; then
+ if [[ "$cur_" == --no-* ]]; then
continue
fi
- c="$c${4-}"
- if [[ $c == "$cur_"* ]]; then
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- COMPREPLY[i++]="${2-}$c"
- fi
- done
- ;;
- *)
- local c i=0 IFS=$' \t\n'
- for c in $1; do
- if [[ $c == "--" ]]; then
- c="--no-...${4-}"
- if [[ $c == "$cur_"* ]]; then
- COMPREPLY[i++]="${2-}$c "
- fi
- break
- fi
- c="$c${4-}"
+
+ c="--no-...${4-}"
if [[ $c == "$cur_"* ]]; then
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- COMPREPLY[i++]="${2-}$c"
+ COMPREPLY[i++]="${2-}$c "
fi
- done
- ;;
- esac
+ break
+ fi
+ c="$c${4-}"
+ if [[ $c == "$cur_"* ]]; then
+ case $c in
+ *=|*.) ;;
+ *) c="$c " ;;
+ esac
+ COMPREPLY[i++]="${2-}$c"
+ fi
+ done
}
# Clear the variables caching builtins' options when (re-)sourcing
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 8db7d0693d..fbd03a0180 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -57,42 +57,22 @@ __gitcomp ()
[[ "$cur_" == *= ]] && return
- case "$cur_" in
- --no-*)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- if [[ $c == "--" ]]; then
- continue
- fi
- c="$c${4-}"
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- array+=("$c")
- done
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- if [[ $c == "--" ]]; then
- c="--no-...${4-}"
- array+=("$c ")
- break
- fi
- c="$c${4-}"
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- array+=("$c")
- done
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
+ local c IFS=$' \t\n'
+ local -a array
+ for c in ${=1}; do
+ if [[ $c == "--" ]]; then
+ [[ "$cur_" == --no-* ]] && continue
+ array+=("--no-...${4-} ")
+ break
+ fi
+ c="$c${4-}"
+ case $c in
+ *=|*.) ;;
+ *) c="$c " ;;
+ esac
+ array+=("$c")
+ done
+ compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
}
__gitcomp_direct ()
--
2.30.0
next prev parent reply other threads:[~2021-01-01 2:18 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-01 2:15 [PATCH 00/47] completion: git-completion 1.3 patches Felipe Contreras
2021-01-01 2:15 ` [PATCH 01/47] completion: bash: fix prefix detection in branch.* Felipe Contreras
2021-01-01 2:15 ` [PATCH 02/47] completion: fix for suboptions with value Felipe Contreras
2021-01-01 2:15 ` [PATCH 03/47] completion: bash: fix for multiple dash commands Felipe Contreras
2021-01-01 2:15 ` [PATCH 04/47] completion: bash: add correct suffix in variables Felipe Contreras
2021-01-01 2:15 ` [PATCH 05/47] completion: bash: do not modify COMP_WORDBREAKS Felipe Contreras
2021-01-01 2:15 ` [PATCH 06/47] test: completion: fix currently typed words Felipe Contreras
2021-01-01 2:15 ` [PATCH 07/47] test: completion: switch __gitcomp_nl prefix test Felipe Contreras
2021-01-01 2:15 ` [PATCH 08/47] test: completion: add run_func() helper Felipe Contreras
2021-01-01 2:15 ` [PATCH 09/47] completion: bash: remove non-append functionality Felipe Contreras
2021-01-01 2:15 ` [PATCH 10/47] completion: bash: get rid of _append() functions Felipe Contreras
2021-01-01 2:15 ` [PATCH 11/47] completion: bash: get rid of any non-append code Felipe Contreras
2021-01-01 2:15 ` [PATCH 12/47] completion: zsh: fix options with arguments Felipe Contreras
2021-01-01 2:15 ` [PATCH 13/47] completion: zsh: expand --git-dir file argument Felipe Contreras
2021-01-01 2:15 ` [PATCH 14/47] completion: zsh: add support for general -C opts Felipe Contreras
2021-01-01 2:15 ` [PATCH 15/47] completion: zsh: fix for undefined completions Felipe Contreras
2021-01-01 2:15 ` [PATCH 16/47] completion: zsh: add support for general -c opts Felipe Contreras
2021-01-01 2:15 ` [PATCH 17/47] completion: zsh: fix extra space on foo= Felipe Contreras
2021-01-01 2:15 ` [PATCH 18/47] completion: zsh: add excluded options Felipe Contreras
2021-01-01 2:15 ` [PATCH 19/47] completion: zsh: always set compset Felipe Contreras
2021-01-01 2:15 ` [PATCH 20/47] completion: factor out check in __gitcomp Felipe Contreras
2021-01-01 2:15 ` [PATCH 21/47] completion: simplify equal suffix check Felipe Contreras
2021-01-01 2:15 ` Felipe Contreras [this message]
2021-01-01 2:15 ` [PATCH 23/47] completion: simplify __gitcomp Felipe Contreras
2021-01-01 2:15 ` [PATCH 24/47] completion: bash: change suffix check in __gitcomp Felipe Contreras
2021-01-01 2:16 ` [PATCH 25/47] completion: improve __gitcomp suffix code Felipe Contreras
2021-01-01 2:16 ` [PATCH 26/47] completion: bash: simplify config_variable_name Felipe Contreras
2021-01-01 2:16 ` [PATCH 27/47] test: completion: add missing test Felipe Contreras
2021-01-01 2:16 ` [PATCH 28/47] completion: bash: improve __gitcomp description Felipe Contreras
2021-01-01 2:16 ` [PATCH 29/47] completion: add __gitcomp_opts Felipe Contreras
2021-01-01 2:16 ` [PATCH 30/47] completion: bash: cleanup __gitcomp* invocations Felipe Contreras
2021-01-01 2:16 ` [PATCH 31/47] completion: bash: shuffle __gitcomp functions Felipe Contreras
2021-01-01 2:16 ` [PATCH 32/47] completion: zsh: simplify __gitcomp_direct Felipe Contreras
2021-01-01 2:16 ` [PATCH 33/47] completion: zsh: shuffle __gitcomp* functions Felipe Contreras
2021-01-01 2:16 ` [PATCH 34/47] completion: zsh: fix direct quoting Felipe Contreras
2021-01-01 2:16 ` [PATCH 35/47] completion: zsh: add elements individually in __gitcomp_opts Felipe Contreras
2021-01-01 2:16 ` [PATCH 36/47] completion: zsh: add __gitcompadd helper Felipe Contreras
2021-01-01 2:16 ` [PATCH 37/47] completion: zsh: add correct removable suffix Felipe Contreras
2021-01-01 2:16 ` [PATCH 38/47] completion: bash: simplify _get_comp_words_by_ref() Felipe Contreras
2021-01-01 2:16 ` [PATCH 39/47] completion: bash: refactor _get_comp_words_by_ref() Felipe Contreras
2021-01-01 2:16 ` [PATCH 40/47] completion: bash: cleanup _get_comp_words_by_ref() Felipe Contreras
2021-01-01 2:16 ` [PATCH 41/47] completion: bash: trivial cleanup Felipe Contreras
2021-01-01 2:16 ` [PATCH 42/47] completion: bash: rename _get_comp_words_by_ref() Felipe Contreras
2021-01-01 2:16 ` [PATCH 43/47] completion: bash: add __git_have_func helper Felipe Contreras
2021-01-01 2:16 ` [PATCH 44/47] completion: bash: improve function detection Felipe Contreras
2021-01-01 2:16 ` [PATCH 45/47] test: completion: add tests for __git_complete Felipe Contreras
2021-01-01 2:16 ` [PATCH 46/47] completion: add proper public __git_complete Felipe Contreras
2021-01-01 2:16 ` [PATCH 47/47] completion: zsh: add higher-priority location Felipe Contreras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210101021622.798041-23-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).