about summary refs log tree commit homepage
path: root/lib/PublicInbox/SolverGit.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-01-04 03:34:14 +0000
committerEric Wong <e@80x24.org>2020-01-04 03:34:35 +0000
commitd13ab9e514cbae66e911f9c88e09d3213c34a952 (patch)
tree0d023ebe122315e0a2ff5a30a77775c5e0dc2213 /lib/PublicInbox/SolverGit.pm
parent957127ead2716ae375ccc1e2b50fc9be53e117dd (diff)
downloadpublic-inbox-d13ab9e514cbae66e911f9c88e09d3213c34a952.tar.gz
This is needed to work with patches with many renames,
such as what makes "git/eebf7a8/s/?b=t%2Ftest-lib.sh"
Diffstat (limited to 'lib/PublicInbox/SolverGit.pm')
-rw-r--r--lib/PublicInbox/SolverGit.pm23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index a78360fd..b12cd9d2 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -112,6 +112,8 @@ sub extract_diff ($$) {
         }
 
         state $LF = qr!\r?\n!;
+        state $ANY = qr![^\r\n]+!;
+        state $MODE = '100644|120000|100755';
         state $FN = qr!(?:("?[^/\n]+/[^\r\n]+)|/dev/null)!;
 
         $s =~ m!( # $1 start header lines we save for debugging:
@@ -124,17 +126,16 @@ sub extract_diff ($$) {
                 # try to get the pre-and-post filenames as $2 and $3
                 (?:^diff\x20--git\x20$FN\x20$FN$LF)
 
-                # old mode $4
-                (?:^old mode\x20(100644|120000|100755)$LF)?
-
-                # ignore other info
-                (?:^(?:copy|rename|deleted|dissimilarity|similarity).*$LF)?
-
-                # new mode (possibly new file) ($5)
-                (?:^new\x20(?:file\x20)?mode\x20(100644|120000|100755)$LF)?
-
-                # ignore other info
-                (?:^(?:copy|rename|deleted|dissimilarity|similarity).*$LF)?
+                (?:^(?: # pass all this to git-apply:
+                        # old mode $4
+                        (?:old\x20mode\x20($MODE))
+                        |
+                        # new mode (possibly new file) ($5)
+                        (?:new\x20(?:file\x20)?mode\x20($MODE))
+                        |
+                        (?:(?:copy|rename|deleted|
+                                dissimilarity|similarity)$ANY)
+                )$LF)*
 
                 )? # end of optional stuff, everything below is required