Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Koch
dune-common
Commits
68ff9b74
Commit
68ff9b74
authored
11 years ago
by
Martin Nolte
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
http://git.dune-project.org/repositories/dune-common
parents
de0b6e9e
cdb05322
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/git-whitespace-hook
+40
-5
40 additions, 5 deletions
bin/git-whitespace-hook
with
40 additions
and
5 deletions
bin/git-whitespace-hook
+
40
−
5
View file @
68ff9b74
...
...
@@ -14,7 +14,7 @@
# files will be matched against those regexes.
# git-diff-index needs a valid commit to compare to
if
git
-
rev-parse
--verify
HEAD
2
>/dev/null
if
git
rev-parse
--verify
HEAD
>
/dev/null
2>&1
then
against
=
HEAD
else
...
...
@@ -65,11 +65,46 @@ else
USER_HAS_CUSTOM_WHITESPACE
=
1
fi
# Figure out how to call xargs to make sure it won't invoke its argument with
# an empty argument list. BSD xargs will not do that by default, while GNU xargs
# needs -r to do the same. So we start by checking whether xargs does the right
# thing without options. Now there could be other obscure versions of xargs out
# there (on clusters etc.) that behave in yet another way, so we try with -r as
# well. If that fails, we throw a big error message at the user.
# In the following line, xargs should not call false, so the return value should be 0.
echo
""
| xargs
false
if
[
$?
-ne
0
]
;
then
# Let's try with -r
echo
""
| xargs
-r
false
if
[
$?
-ne
0
]
;
then
# Houston, we have a problem
if
[
-z
"
$DUNE_WHITESPACE_IGNORE_XARGS
"
]
;
then
echo
"You seem to be lacking a version of xargs that is compatible to either BSD or GNU!"
1>&2
echo
"Please file a bug report at http://dune-project.org about this issue with your exact operating system type and version!"
1>&2
echo
"You can still use this hook by setting the environment variable DUNE_WHITESPACE_IGNORE_XARGS to 1, but please be aware"
1>&2
echo
"that the hook might create false positives."
1>&2
echo
"=============================================================="
1>&2
echo
"Aborting the commit..."
1>&2
exit
99
else
SILENTXARGS
=
xargs
fi
else
SILENTXARGS
=
"xargs -r"
fi
else
SILENTXARGS
=
xargs
fi
fail
=
0
done
=
0
restore_config
()
do_cleanup
()
{
if
[
$done
-ne
1
]
;
then
echo
"Error while executing whitespace checking pre-commit hook!"
1>&2
...
...
@@ -88,7 +123,7 @@ restore_config()
exit
$fail
}
trap
restore_config
EXIT
trap
do_cleanup
EXIT
# set custom value
git config
--replace-all
core.whitespace trailing-space
...
...
@@ -98,7 +133,7 @@ then
git diff-index
--check
--cached
$against
--
result
=
$?
else
git diff-index
--cached
--name-only
$against
| perl
-ne
"print if /
$TRAILING_WHITESPACE_FILES
/"
|
xargs
git diff-index
--check
--cached
$against
--
git diff-index
--cached
--name-only
$against
| perl
-ne
"print if /
$TRAILING_WHITESPACE_FILES
/"
|
$SILENTXARGS
git diff-index
--check
--cached
$against
--
result
=
$?
fi
...
...
@@ -114,7 +149,7 @@ then
git diff-index
--check
--cached
$against
--
result
=
$?
else
git diff-index
--cached
--name-only
$against
| perl
-ne
"print if /
$TAB_IN_INDENT_FILES
/"
|
xargs
git diff-index
--check
--cached
$against
--
git diff-index
--cached
--name-only
$against
| perl
-ne
"print if /
$TAB_IN_INDENT_FILES
/"
|
$SILENTXARGS
git diff-index
--check
--cached
$against
--
result
=
$?
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment