mirror of https://github.com/xemu-project/xemu.git
scripts/clean-includes: Fully skip / ignore files
When clean-includes claims to skip or ignore a file, only the part that sanitizes use of qemu/osdep.h skips the file. The part that looks for duplicate #include does not, and neither does committing to Git. The latter can get unrelated stuff included in the commit, but only if you run clean-includes in a dirty tree, which is unwise. Messed up when we added skipping in commitfd3e39a40c
"scripts/clean-includes: Enhance to handle header files". The former can cause bogus reports for --check-dup-head. Added in commitd66253e46a
"scripts/clean-includes: added duplicate #include check", duplicating the prior mistake. Fix the script to fully skip files. Fixes:fd3e39a40c
("scripts/clean-includes: Enhance to handle header files") Fixes:d66253e46a
("scripts/clean-includes: added duplicate #include check") Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20230202133830.2152150-2-armbru@redhat.com>
This commit is contained in:
parent
969d09c3a6
commit
aa735872a8
|
@ -111,6 +111,7 @@ cat >"$COCCIFILE" <<EOT
|
||||||
)
|
)
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
files=
|
||||||
for f in "$@"; do
|
for f in "$@"; do
|
||||||
case "$f" in
|
case "$f" in
|
||||||
*.c.inc)
|
*.c.inc)
|
||||||
|
@ -144,6 +145,7 @@ for f in "$@"; do
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
files="$files $f"
|
||||||
|
|
||||||
if [ "$MODE" = "c" ]; then
|
if [ "$MODE" = "c" ]; then
|
||||||
# First, use Coccinelle to add qemu/osdep.h before the first existing include
|
# First, use Coccinelle to add qemu/osdep.h before the first existing include
|
||||||
|
@ -174,8 +176,8 @@ for f in "$@"; do
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$DUPHEAD" = "yes" ]; then
|
if [ "$DUPHEAD" = "yes" ] && [ -n "$files" ]; then
|
||||||
egrep "^[[:space:]]*#[[:space:]]*include" "$@" | tr -d '[:blank:]' \
|
egrep "^[[:space:]]*#[[:space:]]*include" $files | tr -d '[:blank:]' \
|
||||||
| sort | uniq -c | awk '{if ($1 > 1) print $0}'
|
| sort | uniq -c | awk '{if ($1 > 1) print $0}'
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Found duplicate header file includes. Please check the above files manually."
|
echo "Found duplicate header file includes. Please check the above files manually."
|
||||||
|
@ -184,7 +186,7 @@ if [ "$DUPHEAD" = "yes" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$GIT" = "yes" ]; then
|
if [ "$GIT" = "yes" ]; then
|
||||||
git add -- "$@"
|
git add -- $files
|
||||||
git commit --signoff -F - <<EOF
|
git commit --signoff -F - <<EOF
|
||||||
$GITSUBJ: Clean up includes
|
$GITSUBJ: Clean up includes
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue