git-meld icon indicating copy to clipboard operation
git-meld copied to clipboard

Error -1 when trying to handle diffs with thousands of files

Open mburr opened this issue 13 years ago • 2 comments

When I try to git-meld a commit that has thousands of files in it the safe_cmd() call containing the git archive shell command fails with an error == -1. I'm not sure what the exact problem is, because if I put the command that failed from the Perl script into a bash script and run it, it works.

But, if I change copy_file_names_tree() to call git archive with smaller batches of files it seems to work.

A patch follows; keep in mind that Perl is a non-native language to me, so it's probably less than idiomatic.

diff --git a/git-meld.pl b/git-meld.pl
index e581781..f98a2b6 100755
--- a/git-meld.pl
+++ b/git-meld.pl
@@ -146,8 +146,17 @@ sub copy_files_named_tree($$$) {
     if (scalar @$file_list == 0) {
         return;
     }
-    my $escaped_file_list = join(" ", map{shell_escape($_)} @$file_list);
-    safe_cmd("cd \$(git rev-parse --show-toplevel) && git archive $tree $escaped_file_list | tar -x -C \"$out_dir\"");
+    #my $escaped_file_list = join(" ", map{shell_escape($_)} @$file_list);
+    #safe_cmd("cd \$(git rev-parse --show-toplevel) && git archive $tree $escaped_file_list | tar -x -C \"$out_dir\"");
+
+    safe_cmd("cd \$(git rev-parse --show-toplevel)");
+    my @flist = @$file_list;
+
+    while (scalar @flist != 0) {
+        my @sub_list = splice @flist, 0, 200;
+        my $escaped_file_list = join(" ", map{shell_escape($_)} @sub_list);
+        safe_cmd("git archive $tree $escaped_file_list | tar -x -C \"$out_dir\"");
+    }
 }

 # Links the files given as a list in the first argument from the working

mburr avatar May 02 '12 00:05 mburr

By the way, thanks very much for the script. GUI git diffs are quite painful without it.

mburr avatar May 02 '12 00:05 mburr

Thanks for the patch! Was a great help. After a permission change of the whole repo I couldn't diff the branches before/after the change. Would be great to put this into the master branch..

kribor avatar Oct 16 '12 08:10 kribor