Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upGit pre-commit hook doesn't work with BSD grep. #1018
Comments
This comment has been minimized.
This comment has been minimized.
|
@ttencate thoughts on this? |
This comment has been minimized.
This comment has been minimized.
ttencate
commented
Nov 22, 2017
|
Indeed The
Instead of nulls, we could use newlines (
But then we'd need the Here's a useful reference: Properly escaping output from pipe in xargs. If your
I also added |
This comment has been minimized.
This comment has been minimized.
|
I had misread the definition of That
By default I appreciate you guys looking into this issue with me. This code is definitely stretching my understanding of |
This comment has been minimized.
This comment has been minimized.
ttencate
commented
Nov 22, 2017
•
|
Ah, I missed the required changes in Your handling of |
This comment has been minimized.
This comment has been minimized.
|
Makes sense to be more explicit. I think it needs to be Should I open a pull request with all of these changes? |
This comment has been minimized.
This comment has been minimized.
naturalethic
commented
Jan 31, 2018
|
Until someone finds the best canonical solution, this is working for us:
|
standard
deleted a comment
Feb 5, 2018
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
May 10, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
May 10, 2018
This comment has been minimized.
This comment has been minimized.
|
@naturalethic @ttencate Do you think we ought to mention @naturalethic's workaround in the readme for OS X users? We can also recommend that the user install GNU grep with Is that a better approach? Can one of you make a decision about which approach is preferred and send a PR to add it to the docs? |
stale
bot
removed
the
stale
label
May 11, 2018
This comment has been minimized.
This comment has been minimized.
ttencate
commented
May 12, 2018
|
@feross Ideally, pre-commit hook scripts should be portable across platforms without requiring anyone to install anything (at least on POSIX platforms). I think @adriantrunzo's #1025 contains all our combined efforts and no known issues, so why not just merge it? |
This comment has been minimized.
This comment has been minimized.
|
@ttencate Good point, didn't see that there was already a PR for this. Merged. |
adriantrunzo commentedNov 21, 2017
The pre-commit hook was recently changed in commit bd5445c, but unfortunately the use of
grep -z(after git-diff) doesn't seem valid for BSD grep. To note I am on macOS 10.13.1 and have verified the following on both the system bash (GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17) and brew installed bash (GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0).In this case the
-zoption is meant to handle null-terminated input lines created withgit-diff -z(and later parsed byxargs -0). However,grep -zon macOS/BSD is defined as:That definition is obviously not want we want, and unfortunately seems to be subject to it's own issues, namely if you try to use the
-zoption you will seegrep: invalid option -- z.To make the pre-commit hook work in my setup I changed the
grep -ztogrep -a --null, which is not quite functionally equivalent (treating input as text vs null-terminated lines) but close enough to get things working. I believe the-aand--nulloptions are the same across most grep versions.