Skip to content

Commit

Permalink
Prevent "not a git repository" warning
Browse files Browse the repository at this point in the history
"not a git repository" warning appears when a git command is executed
in a non-repository directory. But the error should not be present if
either completion or workflows are working. That's the error is
suppressed for such cases.
  • Loading branch information
extsoft committed Feb 9, 2020
1 parent 3424fa7 commit 6e2ec1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions completions/_git-elegant
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ __ge_complete_commands () {
__ge_remotes() {
# completes first position with remote branches
local remotes=(
$(git for-each-ref --format='%(refname:short)' refs/remotes 2>/dev/null || echo )
$(git for-each-ref --format '%(refname:short)' refs/remotes 2>/dev/null)
)
_arguments '--help' \
'--no-workflows' \
Expand All @@ -85,7 +85,7 @@ __ge_show_release_notes_modes(){

__ge_show_release_notes() {
local all=(
$(git for-each-ref --format '%(refname:short)' refs 2>/dev/null || echo )
$(git for-each-ref --sort '-version:refname' --format '%(refname:short)' refs 2>/dev/null)
)
_arguments '--help' \
'--no-workflows' \
Expand Down
10 changes: 7 additions & 3 deletions completions/git-elegant.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _git_elegant() {
accept-work|obtain-work)
local opts=(
${gecops}
$(git for-each-ref --format='%(refname:short)' refs/remotes)
$(git for-each-ref --format='%(refname:short)' refs/remotes 2>/dev/null)
)
COMPREPLY=(
$(compgen -W "${opts[*]}" -- ${cursor})
Expand All @@ -45,7 +45,9 @@ _git_elegant() {
if [[ ${#COMP_WORDS[*]} > $(( 2 + ${offset} )) ]]; then
case "${COMP_WORDS[COMP_CWORD-$(( 2 + ${offset} ))]}" in
show-release-notes)
local opts=($(git for-each-ref --sort "-version:refname" --format "%(refname:short)" refs))
local opts=(
$(git for-each-ref --sort "-version:refname" --format "%(refname:short)" refs 2>/dev/null)
)
COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cursor}) )
return 0 ;;
*) ;;
Expand All @@ -56,7 +58,9 @@ _git_elegant() {
if [[ ${#COMP_WORDS[*]} > $(( 3 + ${offset} )) ]]; then
case "${COMP_WORDS[COMP_CWORD-$(( 3 + ${offset} ))]}" in
show-release-notes)
local opts=($(git for-each-ref --sort "-version:refname" --format "%(refname:short)" refs))
local opts=(
$(git for-each-ref --sort "-version:refname" --format "%(refname:short)" refs 2>/dev/null)
)
COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cursor}) )
return 0 ;;
*) ;;
Expand Down
2 changes: 1 addition & 1 deletion libexec/git-elegant
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ MESSAGE
local type=${1}
local command=${2}
if [[ ! "init-repository clone-repository" =~ ${command} ]]; then
local prefix=$(git rev-parse --show-cdup)
local prefix=$(git rev-parse --show-cdup 2>/dev/null)
fi
--run-file "${prefix}.git/.workflows/${command}-${type}"
--run-file "${prefix}.workflows/${command}-${type}"
Expand Down

0 comments on commit 6e2ec1e

Please sign in to comment.