Re: New to Git / Questions about single user / multiple projects

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

 



On Wed, Aug 19, 2009 at 02:18:07PM +0200, Jakub Narebski wrote:

> More complicated solution, used by gitweb, requires Perl, not checked
> that it works correctly, doesn't work with ancient repositories with
> symlink HEAD.
> 
>  $ perl -e '
>  use File::Find qw(find);
>  my @list = ();
>  find({follow_fast => 1, follow_skip => 2, dangling_symlinks => 0,
>        wanted => sub {
>          return if (m!^[/.]$!);
>          return unless (-d $_);
>          push @list, $_ if -e "$_/HEAD" 
>        }});
>  print join("\n", @list)."\n";
>  '

That doesn't seem very accurate. It will find 'HEAD' in "logs/" of
repositories with reflogs enabled, and "refs/remotes/*/" of cloned
repositories, giving you a lot of false positives.

If you want accuracy, you can ask git rev-parse to verify whether a
directory is a git repo; it actually uses a few different heuristics to
check. For example:

  find . -type d |
    while read dir; do
      if GIT_DIR=$dir git rev-parse --git-dir >/dev/null 2>&1; then
        echo $dir
      fi
    done

but it is a bit slower, as you invoke rev-parse for every directory, and
it actually does some verification of the contents of HEAD (so it is
probably a bad idea for something like gitweb, which cares about
performance).

If you want to do a cheap and fast check, searching for 'HEAD', 'refs',
and 'objects' in the same directory is a reasonable heuristic.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]