Upgrade yt-dlp to version 2022.11.11
[sunny256-utils.git] / git-realgc
blob8b51089fa5232de17b4e44578df916879f771be4
1 #!/usr/bin/env bash
3 #=======================================================================
4 # git-realgc
5 # File ID: a0e45088-d9f3-11e1-b9d0-00c0a8deee11
6 # Compress a Git repo really good
7 # License: GNU General Public License version 2 or later.
8 #=======================================================================
10 if [ -d .git/. ]; then
11 dudir=.git
12 else
13 dudir=.
16 test -d $dudir/objects/. || { echo git-realgc: .git/objects/ or objects/ not found >&2; exit 1; }
17 git count-objects -vH
18 echo -----------
19 tot_before=$((find $dudir/objects -type f -printf '%s+' ; echo 0) | bc)
20 echo tot_before: $(echo $tot_before | commify)
21 echo ==== git reflog expire --expire=now --expire-unreachable=now --all
22 git reflog expire --expire=now --expire-unreachable=now --all
23 echo ==== git gc --prune=now "$@"
24 git gc --prune=now "$@"
25 tot_after=$((find $dudir/objects -type f -printf '%s+' ; echo 0) | bc)
26 saved=$(echo "$tot_before-$tot_after" | bc)
27 echo -----------
28 echo tot_before: $(echo $tot_before | commify)
29 echo tot_after: $(echo $tot_after | commify)
30 echo -----------
31 git count-objects -vH
32 [ "$tot_before" != "0" ] && echo "Totally saved: $(echo $saved | commify) ($(echo "scale=4; 100*$saved/$tot_before" | bc -l)%)"