#!/bin/sh

# Collect Git log data from backdoored xz repository

gitlog () (cd ../xz-backdoored >/dev/null 2>&1 && git log "$@")

gitlog --format='%h:%at:%ct:%ae:%ce' | awk -F: '
    function output(hash, timestamp) {
	return (timestamp" "int(timestamp/604800)" "(timestamp%604800)	\
		" "int(timestamp/86400)" "(timestamp%86400)" "hash)
    }

{ Oa = 1 } # "other author" flag

$4 ~ /jia/	    { Oa = 0; print output($1,$2) > "timedata-author-JiaTan" }
$4 ~ /lasse.collin/ { Oa = 0; print output($1,$2) > "timedata-author-Collin" }
Oa		    {	      print output($1,$2) > "timedata-author-other"  }

$5 ~ /jia/	    { print output($1,$3) > "timedata-committer-JiaTan"; next }
$5 ~ /lasse.collin/ { print output($1,$3) > "timedata-committer-Collin"; next }
$5 ~ /github/	    { print output($1,$3) > "timedata-committer-GitHub"; next }
$5 ~ /vnwildman/    { print output($1,$3) > "timedata-committer-vnwild"; next }
{ print "unexpected committer email: "$5 > "/dev/stderr"; exit 1 }'

# EOF
