]> Sergey Matveev's repositories - public-inbox.git/commitdiff
solver: do not enforce order on extended headers
authorEric Wong <e@80x24.org>
Sat, 4 Jan 2020 03:34:14 +0000 (03:34 +0000)
committerEric Wong <e@80x24.org>
Sat, 4 Jan 2020 03:34:35 +0000 (03:34 +0000)
This is needed to work with patches with many renames,
such as what makes "git/eebf7a8/s/?b=t%2Ftest-lib.sh"

lib/PublicInbox/SolverGit.pm
xt/solver.t

index a78360fd6bac59a956b7a6c31305fd5fa1b19fc8..b12cd9d28d955a9ff114f892472deb893fd7eaa5 100644 (file)
@@ -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
 
index 238abecd2ef524c7bf6ac400e815cc8cf3434084..e9f24e7f78ae6dbb0fd6b3ff2168564252f72f9e 100644 (file)
@@ -20,7 +20,7 @@ my $app = sub {
 # TODO: convert these to self-contained test cases
 my $todo = {
        'git' => [
-               # 'eebf7a8/s/?b=t%2Ftest-lib.sh', TODO
+               'eebf7a8/s/?b=t%2Ftest-lib.sh',
                'eb580ca513/s/?b=remote-odb.c',
                '776fa90f7f/s/?b=contrib/git-jump/git-jump',
                '5cd8845/s/?b=submodule.c',