From 2d4a6b2d83dfd61760dfc569265a67fea3249bdb Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 4 Apr 2017 11:29:10 -0400 Subject: avoid leaking git output for completions completions might trigger tracking of a new package. it all goes to stderr, but let's not crowd the output regardless. --- package.inc.sh | 2 +- remote.inc.sh | 2 +- shell/bash-completion | 6 +++--- util.inc.sh | 8 ++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/package.inc.sh b/package.inc.sh index b1d438b..22147de 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -167,7 +167,7 @@ package_checkout() { git show-ref -q "refs/heads/$remote/packages/$pkgname" || git branch -qf --no-track {,}"$remote/packages/$pkgname" - git clone "$ASPROOT" --single-branch --branch "$remote/packages/$pkgname" \ + quiet_git clone "$ASPROOT" --single-branch --branch "$remote/packages/$pkgname" \ "$startdir/$pkgname" || return 1 git --git-dir="$startdir/$pkgname/.git" config pull.rebase true diff --git a/remote.inc.sh b/remote.inc.sh index 8b9674b..db6d318 100644 --- a/remote.inc.sh +++ b/remote.inc.sh @@ -52,7 +52,7 @@ remote_get_tracked_refs() { remote_update_refs() { local remote=$1 refspecs=("${@:2}") - git fetch "$remote" "${refspecs[@]}" + quiet_git fetch "$remote" "${refspecs[@]}" } remote_update() { diff --git a/shell/bash-completion b/shell/bash-completion index 7233705..acff4c8 100644 --- a/shell/bash-completion +++ b/shell/bash-completion @@ -39,11 +39,11 @@ _asp() { word=${COMP_WORDS[i]} if in_array "$word" ${verbs[ALL_PACKAGES]}; then verb=$word - comps=$(\asp list-all | sed 's,.*/,,') + comps=$(ASP_GIT_QUIET=1 \asp list-all | sed 's,.*/,,') break elif in_array "$word" ${verbs[LOCAL_PACKAGES]}; then verb=$word - comps=$(\asp list-local | sed 's,.*/,,') + comps=$(ASP_GIT_QUIET=1 \asp list-local | sed 's,.*/,,') break elif in_array "$word" ${verbs[NONE]}; then verb=$word @@ -55,7 +55,7 @@ _asp() { case $verb in show) if (( i < ${#COMP_WORDS[@]} - 2 )); then - comps=$(\asp ls-files "${COMP_WORDS[i+1]}" 2>/dev/null) + comps=$(ASP_GIT_QUIET=1 \asp ls-files "${COMP_WORDS[i+1]}" 2>/dev/null) fi ;; '') diff --git a/util.inc.sh b/util.inc.sh index c33cb63..ddd7592 100644 --- a/util.inc.sh +++ b/util.inc.sh @@ -36,3 +36,11 @@ in_array() { return 1 } + +quiet_git() { + local q + + [[ $ASP_GIT_QUIET ]] && q=('-q') + + command git "$1" "${q[@]}" "${@:2}" +} -- cgit v1.2.3-54-g00ecf