summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/assets/init/hooks/pre-commit.sample
blob: 9d256d4c64e658f1e24886c21340c7022694595d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
# A sample hook to prevent commits with merge-markers
#####################################################
# This example hook rejects changes that are about to be committed with merge markers,
# as that would be a clear indication of a failed merge. It is triggered by `git commit`
# and returning with non-zero exit status prevents the commit from being created.
#
# To enable this hook remove the `.sample` suffix from this file entirely.

# Check for merge markers in modified files
for file in $(git diff --cached --name-only); do
    if grep -q -E '^(<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|)$' "$file"; then
        echo "Error: File '$file' contains merge markers. Please remove them before committing."
        exit 1
    fi
done

# Exit with success if there are no errors
exit 0