3 #=======================================================================
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
16 test -d $dudir/objects
/. ||
{ echo git-realgc
: .git
/objects
/ or objects
/ not found
>&2; exit 1; }
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)
28 echo tot_before
: $
(echo $tot_before | commify
)
29 echo tot_after
: $
(echo $tot_after | commify
)
32 [ "$tot_before" != "0" ] && echo "Totally saved: $(echo $saved | commify) ($(echo "scale
=4; 100*$saved/$tot_before" | bc -l)%)"