diff --git a/.githooks/post-commit b/.githooks/post-commit index a6a42064..db27be7e 100755 --- a/.githooks/post-commit +++ b/.githooks/post-commit @@ -17,7 +17,16 @@ if [ ! -f "${CONF_FILE}" ] || [ ! -f "${SYNC_SCRIPT}" ]; then fi # Files changed in the commit we just made. -changed="$(git diff-tree --no-commit-id --name-only -r HEAD 2>/dev/null || true)" +# Merge commits: `git diff-tree HEAD` without a range returns the +# combined-condensed diff (empty for clean, no-conflict merges), +# which would skip regen on merges that bring in watched files via +# the merged branch. Use a range against the first parent when HEAD +# has two parents; plain HEAD for regular commits. +if git rev-parse --verify HEAD^2 >/dev/null 2>&1; then + changed="$(git diff-tree --no-commit-id --name-only -r HEAD^1 HEAD 2>/dev/null || true)" +else + changed="$(git diff-tree --no-commit-id --name-only -r HEAD 2>/dev/null || true)" +fi if [ -z "${changed}" ]; then exit 0 fi