Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mburr opened this issue May 2, 2012 · 2 comments
Open

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

mburr opened this issue May 2, 2012 · 2 comments

Comments

@mburr
Copy link

mburr commented May 2, 2012

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
Copy link
Author

mburr commented May 2, 2012

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

@kribor
Copy link

kribor commented Oct 16, 2012

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants