unixorn/git-extra-commands

View on GitHub
bin/git-diff-last

Summary

Maintainability
Test Coverage
#!/bin/sh
#
# original source: https://github.com/sschuberth/dev-scripts/blob/master/git/git-diff-last.sh

# shellcheck disable=SC2086
if [ $# -ne 1 ]; then
  echo "Rationale : Show the last committed change in a given file."
  echo "Usage     : $(basename $0) <filename>"
  exit 1
fi

git diff "$(git log --pretty=oneline -1 $1 | cut -b 1-40)"^ $1