[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#290332: [PATCH] [lndir] ignore revision info of more SCMs



tags 290332 +patch
thanks

Hi all,

I stumbled across this issue recently, had a look at the code and fixed
it for me.

Attached is a patch, that extends the list of known revision
information directories to include Arch, Darcs, Git, and Mercurial.

To ease the future development of an --ignore option, the previous
logic is changed to use a loop over a static list, instead of hard-coded
comparisons.

If I have missed some other important SCM implementation, or got some of
the corresponding directories wrong, please let me know.

Best regards,
Philipp
From e8da6643c57b8b8f6a18c11fe2cf2c313efefc8b Mon Sep 17 00:00:00 2001
From: Philipp A. Hartmann <ph@sorgh.de>
Date: Thu, 5 Feb 2009 13:03:50 +0100
Subject: [PATCH] ignore revision info of more SCMs

This commit extends the list of known revision information
directories to include Arch, Darcs, Git, and Mercurial.

To ease the future development of an --ignore option, the
logic is changed to use a static list, instead of hard-coded
comparisons.

Signed-off-by: Philipp A. Hartmann <ph@sorgh.de>
---
 lndir/lndir.c   |   33 +++++++++++++++++++++------------
 lndir/lndir.man |   11 +++++++----
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/lndir/lndir.c b/lndir/lndir.c
index cd1d983..f391761 100644
--- a/lndir/lndir.c
+++ b/lndir/lndir.c
@@ -141,6 +141,21 @@ equivalent(char *lname, char *rname, char **p)
     return !strcmp(lname, rname);
 }
 
+static char * revinfo_dirs[] =
+{
+	"BitKeeper",
+	"RCS",
+	"SCCS",
+	"CVS",
+	"CVS.adm",
+	".svn",
+	"{arch}",
+	".arch-ids",
+	"_darcs",
+	".git",
+	".hg",
+	NULL /* end of list */
+};
 
 /* Recursively create symbolic links from the current directory to the "from"
    directory.  Assumes that files described by fs and ts are directories. */
@@ -153,7 +168,7 @@ dodir (char *fn,		/* name of "from" directory, either absolute or
 {
     DIR *df;
     struct dirent *dp;
-    char buf[MAXPATHLEN + 1], *p;
+    char buf[MAXPATHLEN + 1], *p, **rd;
     char symbuf[MAXPATHLEN + 1];
     char basesym[MAXPATHLEN + 1];
     struct stat sb, sc;
@@ -212,17 +227,11 @@ dodir (char *fn,		/* name of "from" directory, either absolute or
 					       dp->d_name[2] == '\0')))
 		    continue;
 		if (!with_revinfo) {
-		    if (!strcmp (dp->d_name, "BitKeeper"))
-			continue;
-		    if (!strcmp (dp->d_name, "RCS"))
-			continue;
-		    if (!strcmp (dp->d_name, "SCCS"))
-			continue;
-		    if (!strcmp (dp->d_name, "CVS"))
-			continue;
-		    if (!strcmp (dp->d_name, "CVS.adm"))
-			continue;
-		    if (!strcmp (dp->d_name, ".svn"))
+		    for (rd = revinfo_dirs; *rd; ++rd) {
+			if (!strcmp (dp->d_name, *rd))
+			    break;
+		    }
+		    if (*rd) /* found revinfo dir */
 			continue;
 		}
 		ocurdir = rcurdir;
diff --git a/lndir/lndir.man b/lndir/lndir.man
index 244e8a5..4823896 100644
--- a/lndir/lndir.man
+++ b/lndir/lndir.man
@@ -76,8 +76,10 @@ argument may be relative (e.g., ../src) and is relative to
 (not the current directory).
 .PP 
 .\" CVS.adm is used by the Concurrent Versions System.
-Note that BitKeeper, RCS, SCCS, .svn, CVS and CVS.adm directories are
-shadowed only if the \fB\-withrevinfo\fP flag is specified.
+.\" .hg is used by Mercurial.
+Note that BitKeeper, RCS, SCCS, CVS, CVS.adm, {arch}, .arch-ids,
+_darcs, .git, .hg, and .svn directories are shadowed only if the
+\fB\-withrevinfo\fP flag is specified.
 .PP
 If you add files, simply run
 .I lndir
@@ -105,8 +107,9 @@ If the link is to a directory, this is almost certainly the wrong thing.
 This option exists mostly to emulate the behavior the C version of
 \fIlndir\fP had in X11R6.  Its use is not recommended.
 .IP \-withrevinfo
-Causes any BitKeeper, RCS, SCCS, .svn, CVS and CVS.adm subdirectories to be
-treated as any other directory, rather than ignored.
+Causes any BitKeeper, RCS, SCCS, CVS, CVS.adm, {arch}, .arch-ids,
+_darcs, .git, .hg, and .svn subdirectories to be treated as
+any other directory, rather than ignored.
 .SH DIAGNOSTICS
 The program displays the name of each subdirectory it enters, followed
 by a colon.  The \fB\-silent\fP option suppresses these messages.
-- 
1.6.0.6

Attachment: signature.asc
Description: PGP signature


Reply to: