From 71b863ad2d1a12501dbfaeec09730bb63eafc976 Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Wed, 17 Jul 2024 19:19:11 +0200 Subject: [PATCH] Ignore all Git configuration files and directories Suggested by Amitai Schleier via private mail. --- v23/util.go | 16 +++++++++++++--- v23/util_test.go | 5 +++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/v23/util.go b/v23/util.go index 2bb11d74..6455a865 100644 --- a/v23/util.go +++ b/v23/util.go @@ -341,12 +341,22 @@ func getSubdirs(filename CurrPath) []RelPath { func isIgnoredFilename(filename string) bool { switch filename { - case "CVS", ".svn", ".git", ".hg", ".idea": + case "CVS", ".svn", ".hg", ".idea": return true } + switch { + + case hasPrefix(filename, ".#"): + // https://www.gnu.org/software/trans-coord/manual/cvs/cvs.html#cvsignore + return true + case hasPrefix(filename, ".git"): + return true + case hasSuffix(filename, "~"): + return true + } + + return false - // https://www.gnu.org/software/trans-coord/manual/cvs/cvs.html#cvsignore - return hasPrefix(filename, ".#") || hasSuffix(filename, "~") } // Checks whether a file is already committed to the CVS repository. diff --git a/v23/util_test.go b/v23/util_test.go index 2109bb78..a8963678 100644 --- a/v23/util_test.go +++ b/v23/util_test.go @@ -204,9 +204,10 @@ func (s *Suite) Test_isIgnoredFilename(c *check.C) { } test("filename.mk", false) - test(".gitignore", false) + test(".github", true) + test(".gitignore", true) test(".git", true) - test(".gitattributes", false) + test(".gitattributes", true) test("CVS", true) test(".svn", true) test(".hg", true)