Skip to content
Snippets Groups Projects
Commit 6dc2ca3f authored by Arkadiusz Hiler's avatar Arkadiusz Hiler Committed by Simona Vetter
Browse files

dim: Make dim sparse check each commit in the range-ish


Previously 'dim sparse' just touched all the files affected by the range
and run sparse against that. Since this may show issues from included
headers and sparse-compliance does not seem to be strongly enforced the
output is rather unhelpful.

With this change the repo is checkout at each commit, sparse is run on
incrementally, on every file that was changed.

Each result is compared to it's parent's result using remap-log to
adjust for potential line numbering changes.

Only the difference is reported.

v2:
    Clearer wording on remap-log check.
    Use the incremental build.
    Reset ref on exit.

v3:
    Make shellcheck happy:
      * Ignore SC2064 in trap
      * Quote array expansion

Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 0e1349fe
No related branches found
No related tags found
No related merge requests found
......@@ -1438,15 +1438,66 @@ function dim_checkpatch
return $rv
}
function _restore_head_on_exit
{
local original_ref
original_ref="$(git rev-parse --abbrev-ref HEAD)"
if [ "$original_ref" == "HEAD" ]; then
original_ref="$(git rev-parse HEAD)"
fi
# we want to expand this now
# shellcheck disable=SC2064
trap "git checkout -q $original_ref" EXIT
}
function dim_sparse
{
local range
local range rv sr prev_sr prev_remapped diff_result remap_log commits
range=$(rangeish "${1:-}")
remap_log=$DIM_PREFIX/maintainer-tools/remap-log
make $DIM_MAKE_OPTIONS
touch --no-create $(git diff --name-only $range) $(git diff --name-only)
make C=1
if [ ! -e $remap_log ]; then
echo "$remap_log is not compailed, please run make in maintainer-tools dir!"
exit 1
fi
_restore_head_on_exit
# make the initial reference build
commits=( $(git rev-list --reverse $range) )
git checkout --detach ${commits[0]}~ > /dev/null 2>&1
make -j8 drivers/gpu/drm/ > /dev/null 2>&1
for commit in "${commits[@]}"; do
touch --no-create $(git diff --name-only $commit~...$commit)
prev_sr="$(make C=1 -j$(nproc) drivers/gpu/drm/ 2>&1 1>/dev/null | sort)"
git checkout --detach $commit >/dev/null 2>&1
sr="$(make C=1 -j$(nproc) drivers/gpu/drm/ 2>&1 1>/dev/null | sort)"
prev_remapped="$(echo "$prev_sr" | $remap_log <(git diff HEAD~ | $remap_log))"
diff_result="$(diff -u <(echo "$prev_remapped") <(echo "$sr") || true)"
echo "Commit: $(git log -n1 --format='%s' $commit)"
if [ -n "$diff_result" ]; then
echo "$diff_result" | egrep '^[+-]' | egrep -v '^[+-]{3}'
else
echo "Okay!"
fi
echo
if (echo "$diff_result" | grep -q '^+'); then
rv=1
fi
prev_sr="$sr"
done
return $rv
}
function dim_checker
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment