History

checkpatch: make git output use LANGUAGE=en_US.utf8

git output parsing depends on the language being en_US english. Make the backtick execution of all `git <foo>` commands set the LANGUAGE of the process to en_US.utf8 before executing the actual command using `export LANGUAGE=en_US.utf8; git <foo>`. Because the command is executed in a child process, the parent LANGUAGE is unchanged.

Joe Perches committed 7 years ago

Commit dbbf8691 parent 5a7f4451 file · +6 −4Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+6−4
@@ -62,6 +62,8 @@ my $conststructsfile = "$D/const_structs.checkpatch"; · 61 unmodified lines
6262 my $typedefsfile = "";
6363 my $color = "auto";
6464 my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
65+# git output parsing needs US English output, so first set backtick child process LANGUAGE
66+my $git_command ='export LANGUAGE=en_US.UTF-8; git';
6567
6668 sub help {
6769 my ($exitcode) = @_;
@@ -904,7 +906,7 @@ sub seed_camelcase_includes { · 836 unmodified lines
904906 $camelcase_seeded = 1;
905907
906908 if (-e ".git") {
907− my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
909+ my $git_last_include_commit = `${git_command} log --no-merges --pretty=format:"%h%n" -1 -- include`;
908910 chomp $git_last_include_commit;
909911 $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
910912 } else {
@@ -932,7 +934,7 @@ sub seed_camelcase_includes { · 21 unmodified lines
932934 }
933935
934936 if (-e ".git") {
935− $files = `git ls-files "include/*.h"`;
937+ $files = `${git_command} ls-files "include/*.h"`;
936938 @include_files = split('\n', $files);
937939 }
938940
@@ -956,7 +958,7 @@ sub git_commit_info { · 17 unmodified lines
956958
957959 return ($id, $desc) if ((which("git") eq "") || !(-e ".git"));
958960
959− my $output = `git log --no-color --format='%H %s' -1 $commit 2>&1`;
961+ my $output = `${git_command} log --no-color --format='%H %s' -1 $commit 2>&1`;
960962 $output =~ s/^\s*//gm;
961963 my @lines = split("\n", $output);
962964
@@ -1006,7 +1008,7 @@ if ($git) { · 43 unmodified lines
10061008 } else {
10071009 $git_range = "-1 $commit_expr";
10081010 }
1009− my $lines = `git log --no-color --no-merges --pretty=format:'%H %s' $git_range`;
1011+ my $lines = `${git_command} log --no-color --no-merges --pretty=format:'%H %s' $git_range`;
10101012 foreach my $line (split(/\n/, $lines)) {
10111013 $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
10121014 next if (!defined($1) || !defined($2));