threads / discuss / 8046

Perl code for git-clean

Subject: Perl code for git-clean

## tl;dr

One message between May 8, 2007 and May 8, 2007.

replies: 0people: 1as markdown or json

Randal L. Schwartz· May 8, 2007, 23:51 UTC · lore

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!

← back to recent threads