This is an automated email from the git hooks/post-receive script. dmn pushed a commit to branch master in repository pkg-perl-tools.
commit f7d42753a52ffa2ff4f45c698f762f815f9bb285 Author: Damyan Ivanov <[email protected]> Date: Sun Dec 3 21:31:12 2017 +0000 gc: add -p option, running 'git gc' via 'parallel', utilising all available CPUs --- debian/control | 1 + scripts/gc | 70 +++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/debian/control b/debian/control index e5a0a8a..d56f35b 100644 --- a/debian/control +++ b/debian/control @@ -82,6 +82,7 @@ Suggests: bc, cdbs, duck, moreutils, + parallel, perl-depends, python, python-launchpadlib diff --git a/scripts/gc b/scripts/gc index 1601ab4..d7fca6f 100755 --- a/scripts/gc +++ b/scripts/gc @@ -13,8 +13,9 @@ usage() { STATS= VERBOSE= HAVE_BC= +PARALLEL= -while getopts vsh opt; do +while getopts vshp opt; do case $opt in h) usage;; s) STATS=1 @@ -24,6 +25,13 @@ while getopts vsh opt; do echo "W: 'bc' not available, stats will use byte units" >&2 fi ;; + p) + if which parallel > /dev/null ; then + PARALLEL=1 + else + echo "W: 'parallel' not available, wil run sequentially" >&2 + fi + ;; v) VERBOSE=1;; ?) usage;; esac @@ -37,7 +45,7 @@ cd "${DPT_PACKAGES:?}" if [ -n "$HAVE_BC" ]; then calc() { - ( echo "scale=1"; echo "$@" ) | bc + ( echo "scale=1"; echo "$@" ) | LC_ALL=C bc } else calc() { @@ -65,38 +73,44 @@ human() { fi } -TOTAL_BEFORE=0 -TOTAL_AFTER=0 -for d in `find . -maxdepth 1 -type d`; do - [ -d "$d/.git" ] || continue +if [ -n "$STATS" ]; then + TOTAL_BEFORE=$(find . -maxdepth 2 -type d -name .git -print0 | du -sbP --total --files0-from=- | tail -1 | cut -f1) +fi - if [ -n "$VERBOSE" ]; then - echo -n "`basename $d`" - fi - if [ -n "$STATS" ]; then - BEFORE=`du -sbP $d/.git | cut -f1` - TOTAL_BEFORE=$(( $TOTAL_BEFORE + $BEFORE )) - fi - GIT_DIR="$d/.git" git gc --quiet - if [ -n "$STATS" ]; then - AFTER=`du -sbP $d/.git | cut -f1` - TOTAL_AFTER=$(( $TOTAL_AFTER + $AFTER )) - fi - if [ -n "$VERBOSE" ]; then - echo -n " done." +if [ -n "$PARALLEL" ]; then + find . -maxdepth 2 -type d -name .git | \ + parallel --will-cite sh -c "GIT_DIR='{}' git gc --quiet" +else + for d in `find . -maxdepth 1 -type d`; do + [ -d "$d/.git" ] || continue + + if [ -n "$VERBOSE" ]; then + echo -n "`basename $d`" + fi if [ -n "$STATS" ]; then - printf " %s -> %s (-%s, %0.1f%%)" \ - `human $BEFORE` `human $AFTER` \ - `human $(( $BEFORE - $AFTER ))` \ - `calc "100*($BEFORE-$AFTER)/$BEFORE"` + BEFORE=`du -sbP $d/.git | cut -f1` fi - echo - fi -done + GIT_DIR="$d/.git" git gc --quiet + if [ -n "$STATS" ]; then + AFTER=`du -sbP $d/.git | cut -f1` + fi + if [ -n "$VERBOSE" ]; then + echo -n " done." + if [ -n "$STATS" ]; then + printf " %s -> %s (-%s, %0.1f%%)" \ + `human $BEFORE` `human $AFTER` \ + `human $(( $BEFORE - $AFTER ))` \ + `calc "100*($BEFORE-$AFTER)/$BEFORE"` + fi + echo + fi + done +fi if [ -n "$STATS" ]; then + TOTAL_AFTER=$(find . -maxdepth 2 -type d -name .git -print0 | du -sbP --total --files0-from=- | tail -1 | cut -f1) GAIN=$(( $TOTAL_BEFORE - $TOTAL_AFTER )) - printf "Total disk usage: %s -> %s (-%s, %0.1f%%)" \ + printf "Total disk usage: %s -> %s (-%s, %0.1f%%)\n" \ `human $TOTAL_BEFORE` `human $TOTAL_AFTER` \ `human $GAIN` \ `calc "100*($GAIN)/$TOTAL_BEFORE"` -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git _______________________________________________ Pkg-perl-cvs-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits
