aboutsummaryrefslogtreecommitdiff
path: root/gdb/contrib/check-whitespace-pre-commit.py
AgeCommit message (Collapse)AuthorFilesLines
4 days[gdb] Fix whitespace in NEWSTom de Vries1-1/+1
Fix this: ... $ empty=$(git hash-object -t tree /dev/null) $ git diff-index --check $empty gdb/NEWS gdb/NEWS:1874: space before tab in indent. + [--basename | --dirname] ... and add the file to the clean list in gdb/contrib/check-whitespace-pre-commit.py. [ I'm not sure if NEWS has an official style. There are no settings for NEWS in .gitattributes, so the whitespace attribute defaults to trailing-space (shorthand for blank-at-eol, blank-at-eof) and space-before-tab. We could require either spaces only (tab-in-indent) in gdb/.gitattributes: ... NEWS whitespace=space-before-tab,tab-in-indent,trailing-space ... or tab style (indent-with-non-tab): ... NEWS whitespace=space-before-tab,indent-with-non-tab,trailing-space ... For tab-in-indent, we get: ... $ git diff-index --check $empty gdb/NEWS | wc -l 228 ... and for indent-with-non-tab instead: ... $ git diff-index --check $empty gdb/NEWS | wc -l 40 ... so the more common style seems to be tab style. But I'm leaving this as is for now. ]
4 days[gdb] Fix whitespace in *.defTom de Vries1-1/+3
Add indent-with-non-tab for *.def in gdb*/.gitattributes. Fix whitespace in the *.def files in gdb*, and add these files to the clean list in gdb/contrib/check-whitespace-pre-commit.py. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
4 days[gdb] Fix whitespace in *.[ly]Tom de Vries1-1/+1
Add indent-with-non-tab for *.[ly] in gdb/.gitattributes. Fix whitespace in the *.[ly] files in gdb, and add these files to the clean list in gdb/contrib/check-whitespace-pre-commit.py. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
4 days[gdb] Fix whitespace in *.cTom de Vries1-1/+4
Fix whitespace in the *.c files in gdb, and add these files to the clean list in gdb/contrib/check-whitespace-pre-commit.py. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
4 days[gdb] Fix whitespace in *.hTom de Vries1-1/+1
Fix whitespace in the *.h files in gdb, and add these files to the clean list in gdb/contrib/check-whitespace-pre-commit.py. Tested on x86_64-linux. Approved-By: Tom Tromey <tom@tromey.com>
5 days[gdb/contrib] Add more clean files in check-whitespace-pre-commit.pyTom de Vries1-6/+1
Add gdbsupport and gdbserver as whitespace-clean in gdb/contrib/check-whitespace-pre-commit.py. Likewise for *.ac and *.m4. Also drop the ignore of configure, that's already taken care of in .gitattributes. Approved-By: Tom Tromey <tom@tromey.com>
6 days[gdb/contrib] Check clean files in check-whitespace-pre-commit.shTom de Vries1-0/+52
The pre-commit check check-whitespace checks diffs. Consequently, we detect something like this: ... $ echo >> gdb/testsuite/lib/gdb.exp $ git commit -a -m trailing-empty-line ... check-whitespace.........................................................Failed - hook id: check-whitespace - duration: 0.01s - exit code: 2 gdb/testsuite/lib/gdb.exp:11717: new blank line at EOF. ... But say we work around the failing check using --no-verify, then we no longer detect it after the commit has succeeded: ... $ git commit -a -m trailing-empty-line --no-verify [detached HEAD e6302105522] trailing-empty-line 1 file changed, 1 insertion(+) $ pre-commit run --all-files check-whitespace check-whitespace.........................................................Passed - hook id: check-whitespace - duration: 0.3s ... Fix this in check-whitespace-pre-commit.sh by distinguishing between clean and other files. Doing so is easier to do in a more advanced scripting language, so rewrite into python. Since a recent commit, gdb/testsuite is clean, so I'm using that as simple classifier for now. For the other files we do what we did before, and check just the staging area: ... $ git --no-pager diff --staged --check "${other[@]}" ... But for clean files, we check the entire file, including staged changes: ... $ empty=$(git hash-object -t tree /dev/null) $ git diff-index --cached --check $empty "${clean[@]}" ... Consequently, we do see: ... $ git commit -a -m trailing-empty-line --no-verify [detached HEAD e6302105522] trailing-empty-line 1 file changed, 1 insertion(+) $ pre-commit run --all-files check-whitespace check-whitespace.........................................................Failed - hook id: check-whitespace - duration: 0.64s - exit code: 2 gdb/testsuite/lib/gdb.exp:11717: new blank line at EOF. ... PR build/33616 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33616