View Issue Details

IDProjectCategoryView StatusLast Update
0002540OpenFOAMBugpublic2017-05-08 17:00
ReporterMattijsJ Assigned Tohenry  
PrioritynoneSeveritytrivialReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOpenSuSEOS Version13.2
Product Versiondev 
Fixed in Versiondev 
Summary0002540: pre-commit hook failure for UPstream.C
DescriptionChecking for 'NULL' in pre-commit-hook is too strict

src/Pstream/mpi/UPstream.C:372: MPI_Group newGroup = MPI_GROUP_NULL
TagsNo tags attached.

Activities

henry

2017-05-05 15:45

manager   ~0008103

It is not clear what you would like changed to what, could you provide a patch?

wyldckat

2017-05-06 21:08

updater   ~0008106

Sorry, it's my fault on this one. I had made a contribution back in September, report #2267, for the pre-commit hook to catch occurrences of "NULL" that should be "nullptr". I didn't 'grep' OpenFOAM's whole source code to double check if it was OK to simply search for "NULL".

Anyway, the fixed file "pre-commit-hook" is attached for replacing "bin/tools/pre-commit-hook" in OpenFOAM-dev.

Below is the patch for visual check before looking into the changes:

    diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook
    index f3a0b57..f284578 100755
    --- a/bin/tools/pre-commit-hook
    +++ b/bin/tools/pre-commit-hook
    @@ -287,7 +287,7 @@ checkNonStandardCodePatterns()
            (*.[CH])
                # Directly report the incorrect markers
                git grep -n --color \
    - -e '> >' -e 'NULL' \
    + -e '> >' -e '[=( ,-/]NULL[);, -/]' \
                    $scope"$f"
            ;;
            esac


However, this will still trigger with the file "src/meshTools/triSurface/triSurfaceTools/geompack/geompack.C", but since that's pretty much imported code from another project, it's unlikely it will need to be changed.
pre-commit-hook (9,393 bytes)   

henry

2017-05-07 09:24

manager   ~0008108

pre-commit: check bad strings/characters etc ...
pre-commit: check line lengths ...
pre-commit: checking for non-standard code ...
Does this change work OK for you? I tried to commit it and get the error:

pre-commit: check copyright ...
Updated copyright for: bin/tools/pre-commit-hook
sed: -e expression #1, char 6: unterminated `s' command
pre-commit hook failure
-----------------------------------
Some copyright dates were automatically updated; Please check these before pushing

File(s):
bin/tools/pre-commit-hook

will

2017-05-07 11:01

manager   ~0008114

Grep has a "-w" option which I think does what we want. I can't get it to function in a single call with the other search pattern, but if we're happy with two git-grep-s, then the following should work:

diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook
index f3a0b57a1..d3cbfa47f 100755
--- a/bin/tools/pre-commit-hook
+++ b/bin/tools/pre-commit-hook
@@ -286,9 +286,8 @@ checkNonStandardCodePatterns()
         case "$f" in
         (*.[CH])
             # Directly report the incorrect markers
- git grep -n --color \
- -e '> >' -e 'NULL' \
- $scope"$f"
+ git grep -n --color -e '> >' $scope$f
+ git grep -w -n --color -e 'NULL' $scope$f
         ;;
         esac
     done

wyldckat

2017-05-07 11:18

updater   ~0008115

@Henry: Sorry, I ironically didn't check the script with itself. I'm also getting the issue with the "unterminated `s' command" and I'm looking into it now.

@Will: Yes, '-w' is a lot better! 'git grep' is able to use '--and'/'--or' arguments, which I've tested just now, so that we can use a single call. But I'm currently still looking into the previous issue with sed.

wyldckat

2017-05-07 11:36

updater   ~0008116

For the 'Copyright' search, had to restrict the search to the first occurrence. This was because the script's own lookup was finding the lookup string.

Attached are the following files:

  - 'pre-commit-hook_v2' for replacing 'bin/tools/pre-commit-hook'

  - 'pre-commit-hook_v2.patch' for easier inspection of the changes made.

This includes Will's suggestion of using '-w' and also by using '--or' that 'git grep' allows us to do, which the regular 'grep' doesn't have.
pre-commit-hook_v2 (9,395 bytes)   

wyldckat

2017-05-07 11:36

updater  

pre-commit-hook_v2.patch (1,477 bytes)   

henry

2017-05-08 17:00

manager   ~0008120

Thanks Bruno.

Resolved by commit 31862aeb6fcca00884fd1c7847662dd180655774

Issue History

Date Modified Username Field Change
2017-05-05 14:57 MattijsJ New Issue
2017-05-05 15:45 henry Note Added: 0008103
2017-05-06 21:08 wyldckat File Added: pre-commit-hook
2017-05-06 21:08 wyldckat Note Added: 0008106
2017-05-06 21:08 wyldckat Assigned To => henry
2017-05-06 21:08 wyldckat Status new => assigned
2017-05-07 09:24 henry Note Added: 0008108
2017-05-07 11:01 will Note Added: 0008114
2017-05-07 11:18 wyldckat Note Added: 0008115
2017-05-07 11:36 wyldckat File Added: pre-commit-hook_v2
2017-05-07 11:36 wyldckat Note Added: 0008116
2017-05-07 11:36 wyldckat File Added: pre-commit-hook_v2.patch
2017-05-08 17:00 henry Status assigned => resolved
2017-05-08 17:00 henry Resolution open => fixed
2017-05-08 17:00 henry Fixed in Version => dev
2017-05-08 17:00 henry Note Added: 0008120