aboutsummaryrefslogtreecommitdiffstats
path: root/src/_git-revise
diff options
context:
space:
mode:
authorShohei YOSHIDA <syohex@gmail.com>2022-03-03 11:49:03 +0900
committerShohei YOSHIDA <syohex@gmail.com>2022-03-03 23:50:33 +0900
commite17d424462b7a4ed420f809e7fde909f19d98255 (patch)
tree17da6cde0875b7ced0ffea9bc30522ccfb253c6d /src/_git-revise
parentMerge pull request #850 from syohex/pr-849 (diff)
downloadzsh-completions-e17d424462b7a4ed420f809e7fde909f19d98255.tar
zsh-completions-e17d424462b7a4ed420f809e7fde909f19d98255.tar.gz
zsh-completions-e17d424462b7a4ed420f809e7fde909f19d98255.tar.bz2
zsh-completions-e17d424462b7a4ed420f809e7fde909f19d98255.tar.lz
zsh-completions-e17d424462b7a4ed420f809e7fde909f19d98255.tar.xz
zsh-completions-e17d424462b7a4ed420f809e7fde909f19d98255.tar.zst
zsh-completions-e17d424462b7a4ed420f809e7fde909f19d98255.zip
Don't complete if here is not git repository
Diffstat (limited to 'src/_git-revise')
-rw-r--r--src/_git-revise23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/_git-revise b/src/_git-revise
index 7e7c1f0..b1fec0e 100644
--- a/src/_git-revise
+++ b/src/_git-revise
@@ -17,14 +17,22 @@
__git-revise_commits() {
local -a commits
- commits=(${(f)"$(git log -20 --pretty=format:'%h:%d %s' | sed 's/: /:/')"})
- _describe -V 'commit' commits
+ if git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null; then
+ commits=(${(f)"$(git log -20 --pretty=format:'%h:%d %s' | sed 's/: /:/')"})
+ _describe -V 'commit' commits
+ else
+ _message 'not a git repository'
+ fi
}
__git-revise_branches() {
local -a branches
- branches=(${(f)"$(git for-each-ref --format='%(refname:short)' refs/heads/)"})
- _describe 'branch' branches
+ if git rev-parse --is-inside-work-tree 1>/dev/null 2>/dev/null; then
+ branches=(${(f)"$(git for-each-ref --format='%(refname:short)' refs/heads/)"})
+ _describe 'branch' branches
+ else
+ _message 'not a git repository'
+ fi
}
_git-revise() {
@@ -50,3 +58,10 @@ _git-revise() {
_git-revise "$@"
+# Local Variables:
+# mode: Shell-Script
+# sh-indentation: 2
+# indent-tabs-mode: nil
+# sh-basic-offset: 2
+# End:
+# vim: ft=zsh sw=2 ts=2 et