#!/usr/bin/env bash
# git-stash-diff: show a stash diff without applying it
set -euo pipefail
stash_ref="${1:-stash@{0}}"
if ! git rev-parse --verify "$stash_ref" >/dev/null 2>&1; then
echo "no stash matching $stash_ref" >&2
exit 1
fi
git --no-pager diff --color=always "$stash_ref"^! \
| less -R --no-init --quit-if-one-screen