Follow-up to r29036: Now that the "mergeinfo" transaction file is no
[svn.git] / contrib / hook-scripts / detect-merge-conflicts.sh
blobd6467d125a3c38c18dfc24dacc34a273304379fc
1 #!/bin/sh
3 # A pre-commit hook to detect changes that look like forgotten
4 # conflict markers. If any additions starting with '>>>>>>>',
5 # '=======' or '<<<<<<<' are found, the commit is aborted with a nice
6 # error message.
8 # $HeadURL$
9 # $LastChangedDate$
10 # $LastChangedBy$
11 # $LastChangedRevision$
13 REPOS=$1
14 TXN=$2
16 SVNLOOK=/usr/bin/svnlook
18 # Check arguments
19 if [ -z "$REPOS" -o -z "$TXN" ]; then
20 echo "Syntax: $0 path_to_repos txn_id" >&2
21 exit 1
24 # We scan through the transaction diff, looking for things that look
25 # like conflict markers. If we find one, we abort the commit.
26 SUSPICIOUS=$($SVNLOOK diff -t "$TXN" "$REPOS" | grep -E '^\+(<{7} \.|={7}$|>{7} \.)' | wc -l)
28 if [ $SUSPICIOUS -ne 0 ]; then
29 echo "Some parts of your commit look suspiciously like merge" >&2
30 echo "conflict markers. Please double-check your diff and try" >&2
31 echo "committing again." >&2
32 exit 1
35 # No conflict markers detected, let it fly!
36 exit 0