From 739337c857303388ac11d66d15323286393dd981 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 12 Oct 2010 02:36:20 -0400 Subject: Do not warn about special files or hardlinks if they are ignored by git. Fixes #549354 for git, but not for other VCSs. --- pre-commit.d/20warn-problem-files | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 pre-commit.d/20warn-problem-files (limited to 'pre-commit.d/20warn-problem-files') diff --git a/pre-commit.d/20warn-problem-files b/pre-commit.d/20warn-problem-files new file mode 100755 index 0000000..3e9e476 --- /dev/null +++ b/pre-commit.d/20warn-problem-files @@ -0,0 +1,27 @@ +#!/bin/sh +set -e + +exclude_internal () { + grep -v '/\(.git\|.hg\|.bzr\|_darcs\)/' +} + +if [ "$VCS" = hg ] || [ "$VCS" = bzr ] || [ "$VCS" = darcs ]; then + special=$(find . -not -type d -not -type f -not -type l | exclude_internal) || true + hardlinks=$(find . -type f -not -links 1 | exclude_internal ) || true +elif [ "$VCS" = git ]; then + special=$(find . -not -type d -not -type f -not -type l -exec git ls-files --exclude-standard --cached --others {} \; | exclude_internal) || true + hardlinks=$(find . -type f -not -links 1 -exec git ls-files --exclude-standard --cached --others {} \; | exclude_internal) || true +else + special="" +fi + +if [ -n "$special" ]; then + echo "etckeeper warning: special files could cause problems with $VCS:" >&2 + echo "$special" >&2 +fi +if [ -n "$hardlinks" ]; then + echo "etckeeper warning: hardlinked files could cause problems with $VCS:" >&2 + echo "$hardlinks" >&2 +fi + +true -- cgit v1.2.3