From 91c921be5b849786def82f258c97b9eb234a56bf Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 18 May 2011 23:35:00 -0700 Subject: [PATCH] Meta/amlook: wip gc --- amlook | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 amlook 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 -- 2.47.3