+{
+my $prefix;
+sub decode_git_file ($) {
+ my $file=shift;
+
+ # git does not output utf-8 filenames, but instead
+ # double-quotes them with the utf-8 characters
+ # escaped as \nnn\nnn.
+ if ($file =~ m/^"(.*)"$/) {
+ ($file=$1) =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
+ }
+
+ # strip prefix if in a subdir
+ if (! defined $prefix) {
+ ($prefix) = run_or_die('git', 'rev-parse', '--show-prefix');
+ if (! defined $prefix) {
+ $prefix="";
+ }
+ }
+ $file =~ s/^\Q$prefix\E//;
+
+ return decode("utf8", $file);
+}
+}
+
+sub parse_diff_tree ($) {