#!/bin/sh # Usage: # Meta/amlook /dev/null | perl -e ' my @time = localtime(time() - $ARGV[0] * 24 * 3600); my $cutoff = sprintf("%04d-%02d-%02d 00:00:00", $time[5]+1900, $time[4]+1, $time[3]); while () { if ($_ le $cutoff) { s/.* //; print; } } ' "$cutoff_days" >..gcinput : <<\INVALID : ( GIT_INDEX_FILE=/tmp/amlook.$$.tmp && export GIT_INDEX_FILE && rm -f "$GIT_INDEX_FILE" && git read-tree refs/notes/amlog && xargs git rm -f && T=$(git write-tree) && C=$(echo Prune amlog | git commit-tree $T -p refs/notes/amlog) && git update-ref -m "Prune amlog" refs/notes/amlog $C ) INVALID } if test $# = 0 then msg=$(sed -ne ' /^[ ]/{ # Append continuation line H x s/\n// x n } # Hold this new line, and look at what is in the hold space x # Is it the Message-ID line? If so, spit out and finish. /^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]:[ ]*/{ s///p q } # Otherwise, check if this new line is empty x # Is it? Then we are done with the header /^$/b end # Otherwise we need to hold onto this header line x # And start the next cycle b : end q ') && find_commit "$msg" elif test "$1" = "--gc" then shift garbage_collect "$@" elif test "$1" == "--squash" then L=notes/amlog && git notes --ref=$L prune && C=$(echo amlog | git commit-tree refs/$L^{tree}) && git update-ref refs/$L $C else for msg do find_commit "$msg" done fi