holygeek / git-number

Use numbers for dealing with files in git
ISC License
281 stars 25 forks source link

Bugfix for filenames containing parentheses #19

Closed jonsmithers closed 10 years ago

jonsmithers commented 10 years ago

git-list already adds quotations for filenames containing spaces. It should also use quotations for filenames containing parentheses.

Suppose you do git-number add 3, where 3 corresponds to file(withParens).txt. git-number will run: git add file(withParens).txt Which fails. Parens ought to be escaped or placed inside quotes. This proposed fix changes git-list so that git-number instead runs: git add "file(withParens).txt"

jonsmithers commented 10 years ago

My initial solution was in git-number (line 144):

    if ( $arg =~ m/^[0-9][0-9]*$/ ) {
        my @filepaths = split("\n", `git-list $arg`);
        @filepaths = map { qq/"$_"/ } @filepaths;
        push @args, @filepaths;
        $converted=1;
    } ...

However, I think the change proposed here (in git-list) is far more appropriate.

holygeek commented 10 years ago

Thanks for making the pull request. I've added your commit to master and also make it handle more characters.