stockholm/krebs/5pkgs/simple/git-preview/default.nix
2017-09-22 00:33:46 +02:00

16 lines
361 B
Nix

{ coreutils, git, stdenv, writeDashBin }:
writeDashBin "git-preview" ''
PATH=${stdenv.lib.makeBinPath [
coreutils
git
]}''${PATH+:$PATH}
hashes=$(git log --format=%h "..$1")
end=$(echo "$hashes" | head -1)
start=$(echo "$hashes" | tail -1)
# exit if no diff was found
test -z "$start" && exit 0
shift
git diff "$start^..$end" "$@"
''