# Perl code for git-clean

1 messages from 2007-05-08 to 2007-05-08. Participants: Randal L. Schwartz.
Thread: https://gitlist.dev/t/8046

## Randal L. Schwartz, 2007-05-08 23:51

Subject: Perl code for git-clean
Message-ID: <86hcqm98mc.fsf@blue.stonehenge.com>
URL: https://gitlist.dev/e/86hcqm98mc.fsf%40blue.stonehenge.com

```

OK, this is untested, but I usually get this stuff right
by eyeballing it. :)

export cleandir;
git-ls-files -z --others --directory $excl ${excl_info:+"$excl_info"} -- "$@" |
perl -ln0e '
  use File::Path qw(rmtree);
  if (-d and not -L) {
    if (not $ENV{cleandir}) {
      print "Not removing $_";
      next;
    }
    print "Removing $_";
    rmtree($_);
  } else {
    print "Removing $_";
    unlink($_);
  }
'

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

```
