summaryrefslogtreecommitdiffstats
path: root/git-gc
blob: 75ada5df60dfd7c5ee1a7c6a629dee0550f4c3b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /bin/bash
#
RESET="\033[0m"
RED="\033[0;31m"
BROWN="\033[0;33m"

MINDT=$((72*3600))
CMD="git gc --aggressive"
WHERE=${1:-.}
echo -e "exec '$BROWN$CMD$RESET' on repost below '$RED$WHERE$RESET' - [Ctrl-c to abort]" && read none

for path in $(find $WHERE -maxdepth 5 -type d -name .git); do
   path=${path%.git}
   echo -e " # $BROWN check : $RED$path$RESET"
   pushd $path >/dev/null || exit 1
   A=$(stat --format="%Y" .git/objects)
   B=$(stat --format="%Y" .git/packed-refs)
   D=$((A - B))
   if [ $D -gt $MINDT ]
   then
       h=$((D/3600))
       m=$(((D - h*3600)/60))
       s=$((D - h*3600 - m*60))
       echo "dt is $h:$m:$s"
       $CMD
   fi
   popd >/dev/null
done