Add a script that checks if commits maintained literal copies

When updating, say, gcc, it is possible that some files were updated, but
others were left as-are.  This is particularly wrong with files that are
supposed to be hardlinks (but that are actually copies due to being
checked out by Git).

Provide a script that checks if commits left literal copies intact.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2009-03-27 15:04:23 +01:00
Родитель 711e85baf8
Коммит 4dae1edb67
1 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,32 @@
#!/bin/sh
# This script will check for files that were literal copies in the
# parents of the given commits, but are no literal copies currently
# (ignoring those files that do no longer exist).
# Use it like this:
#
# $0 $(git rev-list HEAD -- mingw/bin/gcc.exe)
#
# This would check that literal copies were maintained in all the commits
# in the current branch that touched mingw/bin/gcc.exe.
for rev in "$@"
do
# Ignore initial commit
git rev-parse -q --verify $rev^ > /dev/null || continue
for f in $(git diff --name-only --diff-filter=RDM $rev^!)
do
test -f $f || continue
sha1=$(git rev-parse $rev^:$f)
matches="$(git ls-tree -r $rev^ | grep $sha1)"
test 1 -lt $(echo "$matches" | wc -l) && {
for f2 in $(echo "$matches" | sed "s/.* //")
do
test -f $f2 || continue
cmp $f $f2 || echo "$f != $f2"
done
}
done
done