aboutsummaryrefslogtreecommitdiff
path: root/contrib/devtools
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-03-11 17:27:39 -0400
committerMarcoFalke <falke.marco@gmail.com>2018-03-11 17:30:04 -0400
commitd8d9162f5bad39b2720dd2b2da237c6159e4755f (patch)
tree1ee1bec3d5b56e78812f1b0e9f07f99c862739fe /contrib/devtools
parentbb98aec6743ee6cfde593a0bb30d5d1c43f8b0cb (diff)
parent0fbed98e4202bb458466791e83e4e2fb25250d51 (diff)
downloadbitcoin-d8d9162f5bad39b2720dd2b2da237c6159e4755f.tar.xz
Merge #12572: [script] lint-whitespace: find errors more easily
0fbed98e42 [script] lint-whitespace: improve print linenumber (Akio Nakamura) Pull request description: Before this PR, the linenumber infomaition is output if trailing-space or tab code was found, but the output occurence is only per a file. This PR separates the output timing of file name and line number. As a result, users will find where they need to fix more easily. example: 0) git diff ``` diff --git a/dummy.txt b/dummy.txt index c0ce4d776..aebbdb88d 100644 --- a/dummy.txt +++ b/dummy.txt @@ -1,2 +1,2 @@ -1 -2 +1 + 2 @@ -8,2 +8,2 @@ -8 -9 + 8 +9 ``` 1) before this PR - Is there "9 " in second line? It may lead to be misunderstood. ``` This diff appears to have added new lines with trailing whitespace. The following changes were suspected: diff --git a/dummy.txt b/dummy.txt @@ -1,2 +1,2 @@ +1 +9 ``` 2) after this PR ``` This diff appears to have added new lines with trailing whitespace. The following changes were suspected: diff --git a/dummy.txt b/dummy.txt @@ -1,2 +1,2 @@ +1 @@ -8,2 +8,2 @@ +9 ``` Tree-SHA512: 2fd52e3c982786f86cfe10aa2578589bc9c502bcad9b85111467840d726143330c23968cde5483ee0f563893c8381044b80e8c22a7c8eca56fc73c548b9a9496
Diffstat (limited to 'contrib/devtools')
-rwxr-xr-xcontrib/devtools/lint-whitespace.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/contrib/devtools/lint-whitespace.sh b/contrib/devtools/lint-whitespace.sh
index c5b9408ff2..c5d43043d5 100755
--- a/contrib/devtools/lint-whitespace.sh
+++ b/contrib/devtools/lint-whitespace.sh
@@ -51,21 +51,26 @@ if showdiff | grep -E -q '^\+.*\s+$'; then
echo "The following changes were suspected:"
FILENAME=""
SEEN=0
+ SEENLN=0
while read -r line; do
if [[ "$line" =~ ^diff ]]; then
FILENAME="$line"
SEEN=0
elif [[ "$line" =~ ^@@ ]]; then
LINENUMBER="$line"
+ SEENLN=0
else
if [ "$SEEN" -eq 0 ]; then
# The first time a file is seen with trailing whitespace, we print the
# filename (preceded by a newline).
echo
echo "$FILENAME"
- echo "$LINENUMBER"
SEEN=1
fi
+ if [ "$SEENLN" -eq 0 ]; then
+ echo "$LINENUMBER"
+ SEENLN=1
+ fi
echo "$line"
fi
done < <(showdiff | grep -E '^(diff --git |@@|\+.*\s+$)')
@@ -78,21 +83,26 @@ if showcodediff | perl -nle '$MATCH++ if m{^\+.*\t}; END{exit 1 unless $MATCH>0}
echo "The following changes were suspected:"
FILENAME=""
SEEN=0
+ SEENLN=0
while read -r line; do
if [[ "$line" =~ ^diff ]]; then
FILENAME="$line"
SEEN=0
elif [[ "$line" =~ ^@@ ]]; then
LINENUMBER="$line"
+ SEENLN=0
else
if [ "$SEEN" -eq 0 ]; then
# The first time a file is seen with a tab character, we print the
# filename (preceded by a newline).
echo
echo "$FILENAME"
- echo "$LINENUMBER"
SEEN=1
fi
+ if [ "$SEENLN" -eq 0 ]; then
+ echo "$LINENUMBER"
+ SEENLN=1
+ fi
echo "$line"
fi
done < <(showcodediff | perl -nle 'print if m{^(diff --git |@@|\+.*\t)}')