#!/usr/bin/env fish

if set -q argv[1]
	set N $argv[1]
else
	set N 1
end

function nth_commit -a n
	git log --author "joakim@hulthe.net" --pretty=format:%H \
		| head -n $n \
		| tail -n 1
end

set DIFF_FROM (nth_commit $N)
set DIFF_TO "HEAD"

if test $N -gt 1
	set DIFF_TO (nth_commit (math $N - 1))"~1"
end

#echo "git diff"
#echo "    $DIFF_FROM"
#echo "    $DIFF_TO"

git diff $DIFF_FROM $DIFF_TO
