#!/bin/bash4 -eC
# git-ls-paths-modified-since - List the full names of the files modified or added between 2 commits
# Copyright (C) 2016-2017 Ivan Zakharyaschev <imz@altlinux.org>
set -o pipefail

usage()
{
cat <<'EOF'
git-filter-only-files-modified-since
- List the full names of the files modified or added between 2 commits

Usage:
  git-ls-paths-modified-since SINCE [CURRENT_COMMIT]

We are interested only in the files modified or added
in CURRENT_COMMIT since SINCE. (More precisely, in the diff between them.)

CURRENT_COMMIT defaults to HEAD.

This is just a very simple wrapper around git diff-tree (which helps
to remember its options). git-filter-only-files can be used in
combination with this helper.

EOF
}

case "$1" in
    -h|--help|--usage)
        usage
        exit 0
        ;;
esac

readonly SINCE="$1"; shift || { usage >&2; exit 1; }
CURRENT_COMMIT="$1"; if [[ "$CURRENT_COMMIT" ]]; then shift
else CURRENT_COMMIT=HEAD
fi
readonly CURRENT_COMMIT

exec git diff-tree "$SINCE": "$CURRENT_COMMIT": \
    -r --name-only --diff-filter=MACRT
