summaryrefslogtreecommitdiffstats
path: root/git-gc
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2022-01-11 23:57:35 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2022-01-11 23:57:35 +0100
commit8fadfa33e957613c613d79688a5f152545a874bb (patch)
treec3bc022618579fcc13353cb46e090352c86cc848 /git-gc
parent9ff370385fd710ff12368ebf9f44f38990ffcce3 (diff)
downloadbin-8fadfa33e957613c613d79688a5f152545a874bb.zip
bin-8fadfa33e957613c613d79688a5f152545a874bb.tar.gz
git-gc : improves a lot
Diffstat (limited to 'git-gc')
-rwxr-xr-xgit-gc33
1 files changed, 27 insertions, 6 deletions
diff --git a/git-gc b/git-gc
index 8d5de89..75ada5d 100755
--- a/git-gc
+++ b/git-gc
@@ -1,7 +1,28 @@
-#! /bin/sh
+#! /bin/bash
+#
+RESET="\033[0m"
+RED="\033[0;31m"
+BROWN="\033[0;33m"
-echo "* repack" && git repack -adf && \
- echo "* prune" && git prune && \
- echo "* prune-packed" && git prune-packed && \
- echo "* gc" && git gc --aggressive && \
- echo "* done"
+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