pretty patch doesn't show image diffs with newer versions of git
authorclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2017 19:38:39 +0000 (19:38 +0000)
committerclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2017 19:38:39 +0000 (19:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173691

A new security check added in git >= 2.3.3 causes it to abort
when the tool runs "git apply" to generate the images.
Detect if git supports the flag --unsafe-paths and pass it.

Reviewed by Darin Adler.

* PrettyPatch/PrettyPatch.rb:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218711 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

index a2ac031..64950bf 100644 (file)
@@ -1,3 +1,16 @@
+2017-06-22  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        pretty patch doesn't show image diffs with newer versions of git
+        https://bugs.webkit.org/show_bug.cgi?id=173691
+
+        A new security check added in git >= 2.3.3 causes it to abort
+        when the tool runs "git apply" to generate the images.
+        Detect if git supports the flag --unsafe-paths and pass it.
+
+        Reviewed by Darin Adler.
+
+        * PrettyPatch/PrettyPatch.rb:
+
 2017-05-26  Devin Rousso  <drousso@apple.com>
 
         Provide bug information when https://webkit.org/b/# URLs are added in comments
index 62cab1c..a4aaf16 100644 (file)
@@ -777,7 +777,16 @@ END
 
         def self.run_git_apply_on_patch(output_filepath, patch)
             # Apply the git binary patch using git-apply.
-            cmd = GIT_PATH + " apply --directory=" + File.dirname(output_filepath)
+            cmd = GIT_PATH + " apply"
+            # Check if we need to pass --unsafe-paths (git >= 2.3.3)
+            helpcmd = GIT_PATH + " help apply"
+            stdin, stdout, stderr = *Open3.popen3(helpcmd)
+            begin
+                if stdout.read().include? "--unsafe-paths"
+                    cmd += " --unsafe-paths"
+                end
+            end
+            cmd += " --directory=" + File.dirname(output_filepath)
             stdin, stdout, stderr = *Open3.popen3(cmd)
             begin
                 stdin.puts(patch)