Skip to content
Snippets Groups Projects
Commit 6424ba06 authored by Ludwig Knüpfer's avatar Ludwig Knüpfer
Browse files

cppcheck: handle --diff-filter option

Add the possibility to the cppcheck script to pass git's
`--diff-filter` option.
Also improve comments a bit.
parent d17b7730
No related branches found
No related tags found
No related merge requests found
...@@ -3,18 +3,28 @@ ...@@ -3,18 +3,28 @@
BRANCH=${1} BRANCH=${1}
FILEREGEX='\.([sScHh]|cpp)$' FILEREGEX='\.([sScHh]|cpp)$'
# if branch is an option, unset branch, consume parameter otherwise # If no branch but an option is given, unset BRANCH.
# Otherwise, consume this parameter.
if echo "${BRANCH}" | grep -q '^-'; then if echo "${BRANCH}" | grep -q '^-'; then
BRANCH="" BRANCH=""
else else
shift 1 shift 1
fi fi
# If the --diff-filter option is given, consume this parameter.
# Set the default DIFFFILTER option otherwise.
DIFFFILTER="${1}"
if echo "${DIFFFILTER}" | grep -q '^--diff-filter='; then
shift 1
else
DIFFFILTER="--diff-filter=ACMR"
fi
# select either all or only touched-in-branch files, filter through FILEREGEX # select either all or only touched-in-branch files, filter through FILEREGEX
if [ -z "${BRANCH}" ]; then if [ -z "${BRANCH}" ]; then
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})" FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
else else
FILES="$(git diff --diff-filter=ACMR --name-only ${BRANCH} | grep -E ${FILEREGEX})" FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E ${FILEREGEX})"
fi fi
if [ -z "${FILES}" ]; then if [ -z "${FILES}" ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment