bug-findutils
[Top][All Lists]
Advanced

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

Re: Finding shallowest instance of $foo in a given structure


From: Bob Proulx
Subject: Re: Finding shallowest instance of $foo in a given structure
Date: Wed, 19 Mar 2008 00:02:07 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

RB wrote:
> In short, I'm looking for a clean way to find the shallowest 'CVS',
> '.svn', or what have you in a given directory structure without
> ignoring sibling directories.  If a project publishes multiple trees
> (trunk, branch, etc.) with no common VCS parent, it's difficult to
> cleanly categorize and/or store them without causing headaches, and
> for obvious reasons, I'm not up for starting source-management wars
> with a dozen different maintainers.

Your problem sounds interesting to me as well.  But I don't quite
understand it.  Is this following a representative test case?

  mkdir -p srcdir/proj1/CVS
  mkdir -p srcdir/proj1/foo1dir/CVS
  touch srcdir/proj1/foo1dir/foo
  mkdir -p srcdir/proj2/CVS
  mkdir -p srcdir/proj2/foo2dir/CVS
  touch srcdir/proj2/foo srcdir/proj2/foo2dir/bar
  mkdir -p srcdir/proj3/.svn
  mkdir -p srcdir/proj3/foo3dir/.svn
  touch srcdir/proj3/foo srcdir/proj3/foo3dir/bar
  mkdir -p srcdir/proj4/.git
  mkdir -p srcdir/proj4/foo3dir
  touch srcdir/proj4/foo srcdir/proj4/foo3dir/bar
  mkdir -p srcdir/subdir/proj5/.svn
  mkdir -p srcdir/subdir/proj5/foo5dir
  mkdir -p srcdir/subdir/proj6/.svn

Given that you are looking to list out the following directories?

  srcdir/proj1/CVS
  srcdir/proj2/CVS
  srcdir/proj3/.svn
  srcdir/proj4/.git
  srcdir/subdir/proj5/.svn
  srcdir/subdir/proj6/.svn

Is that right?

> I've nearly gotten where I want with -prune but only in a crufty
> manner (i.e. 'find ${PWD} -type d ! -name . -exec [ -e "{}/.svn" ] \;
> -print -prune') that makes searching large, heterogeneous trees
> painful (no need to search .git repositories for .svn or CVS).

Using the above test case the following seems to work.

  find srcdir \( -exec test -d {}/CVS \; -o -exec test -d {}/.svn \; -o -exec 
test -d {}/.git \; \) -print -prune | sort

Produces:

  srcdir/proj1
  srcdir/proj2
  srcdir/proj3
  srcdir/proj4
  srcdir/subdir/proj5
  srcdir/subdir/proj6

Is that what you are looking for?

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]