From 90c64819b7f7b223b6ab76841441979d2e97b213 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Nov 2012 15:23:07 -0500 Subject: [PATCH] Update to exclude git/hg/bzr repo directories. --- NEWS | 3 +++ README | 2 +- shredtree.c | 4 ++-- shredtree.py | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 40fca37..09a0cfa 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +2.9: 2012-11-24 + Exclude .git/.bzr/.hg repo directories as well as .svn. + 2.8: 2005-10-19 Change license to BSD. Tweak Python to use hashlib rather than the deprecated md5 module. Suppress some compiler warnings. diff --git a/README b/README index 68ce747..e48b470 100644 --- a/README +++ b/README @@ -21,6 +21,6 @@ srcdupchk - the shred algorithm in C++ ctcompare - C Token Comparator http://minnie.tuhs.org/Programs/Ctcompare/ -See the xhangelog in the RPM spec file for recent developments. +See the NEWS file for recent developments. diff --git a/shredtree.c b/shredtree.c index b0e9402..bb3edd8 100644 --- a/shredtree.c +++ b/shredtree.c @@ -42,10 +42,10 @@ static int file_count; static int eligible(const char *file) /* is the specified file eligible to be compared? */ { - if (strstr(file, "CVS") || strstr(file,"RCS") || strstr(file,"SCCS") || strstr(file, "SVN") || strstr(file, ".svn")) +#define endswith(suff) !strcmp(suff, file + strlen(file) - strlen(suff)) + if (strstr(file, "CVS") || strstr(file,"RCS") || strstr(file,"SCCS") || strstr(file, "SVN") || endswith(".svn") || endswith(".git") || endswith(".hg") || endswith(".bzr")) return(0); /* fast check for the most common suffixes */ -#define endswith(suff) !strcmp(suff, file + strlen(file) - strlen(suff)) else if (endswith(".c") || endswith(".h") || endswith(".html")) return(1); else if (endswith(".o") || endswith("~") || endswith(".bdf")) diff --git a/shredtree.py b/shredtree.py index a8aaaf8..9ce32d6 100755 --- a/shredtree.py +++ b/shredtree.py @@ -14,7 +14,9 @@ def eligible(file): return False elif filter(lambda x: file.endswith(x), ('.o','~', '.bdf')): return False - elif filter(lambda x: file.find(x)>-1, ('RCS','SCCS','CVS','SVN','.svn')): + elif filter(lambda x: file.find(x)>-1, ('RCS','SCCS','CVS','SVN')): + return False + elif filter(lambda x: file.endswith(x), ('.svn','.git','.hg','.bzr')): return False elif c_only: return filter(lambda x: file.endswith(x), ('.c','.cc','.h','.html')) -- 2.43.0