#!/bin/sh
#
# git-attic [-M] [PATH] - list deleted files of git repositories
#
# usage:
#   use -M to not show renamed files, and other git-log options as you like
#
# the output is designed to be copy'n'pasted:
#   pass the second field to git show to display the file contents
#   or just select the hash without ^ to see the commit where removal happened
#
# ---
# see: https://leahneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html
# source: https://leahneukirchen.org/dotfiles/bin/git-attic

git log --raw --no-renames --date=short --format='%h %cd' "$@" \
  | awk '/^[0-9a-f]/ { commit=$1; date=$2 }
       /^:/ && $5 == "D" { print date, commit "^:" $6 }' \
  | git -p column
  # | less
