]> git.proxmox.com Git - rustc.git/blob - vendor/gix/src/assets/init/hooks/pre-commit.sample
New upstream version 1.74.1+dfsg1
[rustc.git] / vendor / gix / src / assets / init / hooks / pre-commit.sample
1 #!/bin/sh
2 # A sample hook to prevent commits with merge-markers
3 #####################################################
4 # This example hook rejects changes that are about to be committed with merge markers,
5 # as that would be a clear indication of a failed merge. It is triggered by `git commit`
6 # and returning with non-zero exit status prevents the commit from being created.
7 #
8 # To enable this hook remove the `.sample` suffix from this file entirely.
9
10 # Check for merge markers in modified files
11 for file in $(git diff --cached --name-only); do
12 if grep -q -E '^(<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|)$' "$file"; then
13 echo "Error: File '$file' contains merge markers. Please remove them before committing."
14 exit 1
15 fi
16 done
17
18 # Exit with success if there are no errors
19 exit 0