From: Junio C Hamano Date: Thu, 19 May 2011 06:35:00 +0000 (-0700) Subject: Meta/amlook: wip gc X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91c921be5b849786def82f258c97b9eb234a56bf;p=thirdparty%2Fgit.git Meta/amlook: wip gc --- diff --git a/amlook b/amlook new file mode 100755 index 0000000000..5c270d6da3 --- /dev/null +++ b/amlook @@ -0,0 +1,116 @@ +#!/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 "$@" +else + for msg + do + find_commit "$msg" + done +fi