Bug 134286

Summary: pre-commit check for allownonascii is incorrect
Product: LibreOffice Reporter: Shiro Kawai <shiro.kawai>
Component: LibreOfficeAssignee: Shiro Kawai <shiro.kawai>
Status: RESOLVED FIXED    
Severity: trivial CC: himajin100000, serval2412, xiscofauli
Priority: medium    
Version: 7.0.0.0.beta1+   
Hardware: All   
OS: All   
Whiteboard: target:7.1.0
Crash report or crash signature: Regression By:

Description Shiro Kawai 2020-06-24 20:10:03 UTC
In pre-commit git hook, non-ascii filenames are checked unless `git config hooks.allownonascii` is "true".  However, the comparison $allownonascii ne "true" is done without trailing newline, the hook always exists no matter what the value of hooks.allownonascii is.

I don't intend to commit files with non-ascii filenames into the main repo, but we needed it in our local fork.

Here's a suggested patch.


--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -280,6 +280,7 @@ if ( system( "git rev-parse --verify HEAD >/dev/null 2>&1" ) == 0 )
 
 # If you want to allow non-ascii filenames set this variable to true.
 my $allownonascii=`git config hooks.allownonascii`;
+chomp $allownonascii;
 
 # Cross platform projects tend to avoid non-ascii filenames; prevent
 # them from being added to the repository. We exploit the fact that the
Comment 1 Julien Nabet 2020-06-26 06:43:51 UTC
Thank you Shiro for the patch!
So you've already retrieved sources, analyzed the pb and found the fix, what about submitting your patch on gerrit?
Indeed, the 3 only remaining steps are:
- provide license statement
- create a gerrit account
- submit your patch
See https://wiki.documentfoundation.org/Development/GetInvolved

If you can't or don't want to, at minimum provide license statement so we can submit the patch for you.

Waiting for your feedback.
Comment 2 Shiro Kawai 2020-06-26 11:28:16 UTC
Done, done and done!
Comment 3 Julien Nabet 2020-06-26 11:35:10 UTC
Thank you for your quick feedback!

Considering https://gerrit.libreoffice.org/c/core/+/97213, let's assign this tracker to you then.
Comment 4 Commit Notification 2020-10-09 06:42:13 UTC
Shiro Kawai committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d73776daa4a0e9397a9b86b5a250b210062fd760

tdf#134286: fix pre-commit hook to make hooks.allownonascii work

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Xisco FaulĂ­ 2021-02-09 14:29:32 UTC
Closing