Comments (9)
Even if I do not count, I vote for Izaak :-) I think that trailing white spaces must be trimmed out (I have an autocommand in vim to ensure this). Anyhow, I am curios: what OCD means?
from json-fortran.
OCD means Obsessive Compulsive Disorder… It is actually a serious and often debilitating psychological illness, but in casual/slang speaking (at least in American English) it is often used to mean excessively picky or opinionated or particular—not to imply that anyone actually suffers from this disorder. To be honest, it is a bad habit to use it in this manner and insensitive to those who actually suffer from it. I will try not to use it in this context, now that @szaghi caused me contemplate the actual implications of doing so.
@szaghi as far as scripting goes, I set my whitespace
settings in my global gitconfig
and then enable the pre-commit
example hook that comes with git to prevent me from committing new white space errors. I also have devised a more aggressive approach which will automatically sanitize white space whenever you add something to the index with git ‘clean’ and ‘smudge’ filters. For more info check out: http://stackoverflow.com/questions/591923/make-git-automatically-remove-trailing-whitespace-before-committing/28446440#28446440
from json-fortran.
Hi Izaak,
thank you for the explanation. I am often obsessive and compulsive on many aspects and I am not offended by this bad (not polite) speaking.
The link on git hook is very interesting, even if I have eradicated this problem at roots by my vim configuration. Thank you very much, your links are always interesting.
from json-fortran.
FWIW these are the hooks I am currently using:
pre-commit
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
pre-push
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
commit-msg
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
from json-fortran.
great hooks! I have to study them...
from json-fortran.
actually, for the pre-commit
hook to be of use, you need to make sure you set your white space settings in your gitconfig
Something like:
git config --gobal core.whitespace trailing-space,space-before-tab,blank-at-eol,blank-at-eof
should do the trick.
from json-fortran.
As Stefano would say...I'm just a poor Fortran man, I don't understand what you are saying!! I'll try to look into how to use these hooks. Note that I use SourceTree to do my commits, I guess maybe there is a way to use these?
I edit on three different platforms with three different editors, so I can see how the line breaks were probably all messed up! Probably we should also add the whitespace guidelines to the CONTRIBUTING.md (see issue #47).
from json-fortran.
@jacobwilliams You raise me a smile :-)
Managing a project on 3 different platforms maybe a nightmare. I hope that Izaak has the suitable git-hooks-set to sanitize your commits :-)
from json-fortran.
@jacobwilliams I think, on each machine you use, go into source tree, and figure out where the local git repo is. Then you can go to the local repo and add the git hooks in the .git/hooks/
folder. Also, in each repo do git config core.whitespace trailing-space,space-before-tab,blank-at-eol,blank-at-eof
or if you always want to be able to check for whitespace issues in all projects, you can just do git config --gobal core.whitespace trailing-space,space-before-tab,blank-at-eol,blank-at-eof
once per machine.
from json-fortran.
Related Issues (20)
- null_to_integer_mode mode
- Available in Fedora 35/36 HOT 2
- Cross-platform? HOT 2
- On Definition of operator [] HOT 1
- How to get a derived-type table? HOT 2
- Make unicode support optional for homebrew HOT 1
- Rounding a real when printing HOT 1
- Incorrect mod locations when using FetchContent HOT 3
- Fails to build on PPC due to missing ieee_arithmetic in gfortran HOT 2
- Tests fail with nvfortran compiler HOT 10
- Many tests unable to find executable, several tests fail (PowerPC): what am I doing wrong here? HOT 12
- Check if keyword is valid HOT 1
- Add test to FPM file
- Unable to build json-fortran with nvfortran HOT 1
- libdir and includedir empty in json-fortran.pc HOT 2
- All tests fail with errors like "Could not find executable ./jf_test_45" HOT 2
- json parse failed HOT 1
- Can not find some variables in json file HOT 1
- Write out 2d array to JSON file HOT 3
- Question: dealing with duplicate named objects HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-fortran.