[-next] checkpatch: Fix git "fatal" warning if file argument outside kernel tree
diff mbox series

Message ID b6afa04112d450c2fc120a308d706acd60cee294.camel@perches.com
State In Next
Commit c6f1aa6ad2f00d951f001b522415786d0c03ff7d
Headers show
Series
  • [-next] checkpatch: Fix git "fatal" warning if file argument outside kernel tree
Related show

Commit Message

Joe Perches Sept. 20, 2020, 4:20 p.m. UTC
commit bcf4271d4bc3 ("checkpatch: allow not using -f with files that
are in git") in linux-next causes checkpatch to emit a fatal message:

fatal: <file>: '<file>' is outside repository at '<kernel_dir>'

Fix that by sending git's error output to /dev/null instead.

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Reviewed-by: Julia Lawall <julia.lawall@inria.fr>
---

Patch
diff mbox series

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3e474072aa90..469f8e7456df 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -981,7 +981,7 @@  sub git_is_single_file {
 
 	return 0 if ((which("git") eq "") || !(-e "$gitroot"));
 
-	my $output = `${git_command} ls-files -- $filename`;
+	my $output = `${git_command} ls-files -- $filename 2>/dev/null`;
 	my $count = $output =~ tr/\n//;
 	return $count eq 1 && $output =~ m{^${filename}$};
 }