Skip to contentSkip to conversation

outside repository fatal error

PATCH New Julia Lawall 2 participants 4 messages Sep 20, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

The commit bcf4271d4bc3 ("checkpatch: allow not using -f with files that are in git") in linux-next seems to cause checkpatch to fail on a file containing a patch if that file is not in the directory containing the Linux kernel. Is that intentional?

thanks,
julia

maintainer
#1 lore raw
Quoted 4 lines · Julia Lawall

The commit bcf4271d4bc3 ("checkpatch: allow not using -f with files that are in git") in linux-next seems to cause checkpatch to fail on a file containing a patch if that file is not in the directory containing the Linux kernel.

Thanks for the report.

Quoted 1 line

Is that intentional?

No. It doesn't really fail, it just emits a fatal warning from git.

I believe this makes it better by silencing the error.
---

scripts/checkpatch.pl +1 -1
index 3e474072aa90..469f8e7456df 100755
@@ -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}$};
 }
author Reviewed-by
#2 lore raw
Quoted 6 lines · Joe Perches
Quoted 4 lines · Julia Lawall

The commit bcf4271d4bc3 ("checkpatch: allow not using -f with files that are in git") in linux-next seems to cause checkpatch to fail on a file containing a patch if that file is not in the directory containing the Linux kernel.

Quoted 8 lines

Thanks for the report.

Quoted 1 line

Is that intentional?

No. It doesn't really fail, it just emits a fatal warning from git.

I believe this makes it better by silencing the error.

It seems fine now.

julia

Quoted 18 lines

---

scripts/checkpatch.pl +1 -1
index 3e474072aa90..469f8e7456df 100755
@@ -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}$};
 }
maintainer
#3 lore raw

PATCH 1/1 checkpatch: Fix git "fatal" warning if file argument outside kernel tree

In reply to Joe Perches

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.

---

scripts/checkpatch.pl +1 -1
index 3e474072aa90..469f8e7456df 100755
@@ -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}$};
 }