Show All Versions of a Git File

I wrote a Bash script yesterday to check out all versions of a given git file and then open them in less. The problem is ... if the file in question has been modified frequently, you could have a queue of hundreds or even thousands of files in less, which is impractical. Even if you have only four or five commits, it's an awkward interface that doesn't necessarily allow the kinds of comparisons you might want to do. Of course there are plenty of ways to look at diffs: my preferred one is (inevitably at the command line) tig - but these don't show you the whole picture, what the whole file looked like at a particular time. So I think the less interface was a bust, but the basic idea of fetching all versions of a file and parking them in a folder to be examined could still be useful. Here it is:

# ${1} is the passed-in file name
TMPFOLDER=$(mktemp -d "/tmp/gitevolve.XXXXXX") || \
    (echo "Couldn't create temp folder ${TMPFOLDER}, exiting." ; exit 3 )
for rev in $(git log --pretty=format:"%h" "${1}")
do
    datestamp="$(git show --no-patch --no-notes --date=format:'%Y-%m-%d.%H%M.%S' --pretty=format:"%ad" "${rev}")"
    author="$(git show --no-patch --no-notes --pretty=format:"%aN" "${rev}  ")"
    filestamp="${datestamp}.${author}.${rev}"
    git show "${rev}":"${1}" > "${TMPFOLDER}/${filestamp}"
done

This involved getting more familiar with git-show, and the --pretty=format: ( https://git-scm.com/docs/pretty-formats ) flag that works with several of the git utilities. The filename consists of the date (in a time format that sorts properly), the author name ("%aN" uses the .mailmap name if available - also works fine if you haven't set up a .mailmap) and the short revision.