binutils: Add pre-commit hook check-copies
Introduces a pre-commit hook to verify file copies, preventing errors from manual symlink management.
This commit adds a new pre-commit hook called check-copies to the binutils-gdb repository. The hook is designed to prevent errors that arise from maintaining identical files manually, which is prone to mistakes. It ensures that files intended to be copies are indeed exact copies and that no unintended files are treated as copies. The testsuite is excluded from this check to avoid complications with its specific file management practices.
In Details
The binutils-gdb repository is adopting a pre-commit hook system to enforce coding standards and prevent common errors before commits are finalized. This commit introduces the check-copies hook, implemented in gdb/contrib/check-copies.py. This hook scans the repository, identifying files that are exact byte-for-byte duplicates. It verifies that these known copies are indeed identical and that no other unrelated files have been accidentally duplicated. This replaces the previous use of symlinks, which was found to be error-prone. The hook is configured in .pre-commit-config.yaml.
- pre-commit hook
- A script that runs automatically before a commit is created, allowing for checks, formatting, or other validations of the staged changes.
- binutils-gdb
- The combined repository for the GNU Binary Utilities (binutils) and the GNU Debugger (GDB).
- file copy
- An instance where the content of one file is identical to another file.
- symlink
- Symbolic link, a type of file that acts as a pointer to another file or directory.
- repository
- A central location where code and its history are stored and managed, typically using a version control system like Git.
- testsuite
- A collection of tests designed to verify the correct functionality of a software project.