Ryan Anderson <[EMAIL PROTECTED]> writes:

> +open(F,"-|","git-ls-files")
> +     or die "Failed to open pipe from git-ls-files: " . $!;
> +
> +close(F);

We can afford to handle funny characters in the filename right
without pain in Perl, so let's do it right:

    use vars qw($/);
    $/ = "\0";
    open F, '-|', 'git-ls-files', '-z'
        or die "Failed to open pipe from git-ls-files: " . $!;
    @allfiles = map { chomp; $_} <F>;

> [EMAIL PROTECTED] = grep /^$src/, @allfiles;
> [EMAIL PROTECTED] = @srcfiles;
> +s#^$src(/|$)#$dst$1# for @dstfiles;

Be careful with these regexps.  Perhaps something like this?

    @dstfiles = @srcfiles = grep /^\Q$src\E/, @allfiles;
    s#^\Q$src\E(/|$)#$dst$1# for @dstfiles;

or perhaps a bit more readable:

    my $qsrc = quotemeta($src);
    @dstfiles = @srcfiles = grep /^$qsrc/, @allfiles;
    for (@dstfiles) { s/^$qsrc(/|$)/$dst$1/; }

> +rename($src,$dst)
> +     or die "rename failed: $!";

Making sure leading directories for $dst exists, perhaps?

Otherwise looks good.

> +sub usage($) {

This is just a style thing, but do you really care to force a
scalar contect when "usage" is used?

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

Reply via email to