-sub git_ls_files {
- my $dir = shift || '.';
- return run_git('-C', $dir, 'ls-files', @_, \&_unescape_git_filepath);
-}
-
-# Depending on git's "core.quotepath" config, non-ASCII chars may be
-# escaped (identified by surrounding dquotes), so try to unescape.
-sub _unescape_git_filepath {
- return $_ if $_ !~ /^"(.+)"$/;
- return decode('UTF-8', unbackslash($1));
-}
-
-sub git_toplevel {
- my $dir = shift || '.';
-
- my ($proc, $path) = run_git('-C', $dir, qw{rev-parse --show-toplevel});
-
- return if $proc->wait != 0 || !$path;
- return path($path);
-}