user/dev discussion of public-inbox itself
 help / color / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/3] solver: do not enforce order on extended headers
Date: Sat,  4 Jan 2020 03:34:14 +0000
Message-ID: <20200104033415.17097-3-e@80x24.org> (raw)
In-Reply-To: <20200104033415.17097-1-e@80x24.org>

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 | 23 ++++++++++++-----------
 xt/solver.t                  |  2 +-
 2 files changed, 13 insertions(+), 12 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
 
diff --git a/xt/solver.t b/xt/solver.t
index 238abecd..e9f24e7f 100644
--- a/xt/solver.t
+++ b/xt/solver.t
@@ -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',

  parent reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-04  3:34 [PATCH 0/3] more solver fixes Eric Wong
2020-01-04  3:34 ` [PATCH 1/3] xt/solver.t: real-world regression tests Eric Wong
2020-01-04  3:34 ` Eric Wong [this message]
2020-01-04  3:34 ` [PATCH 3/3] solver: minor cleanups to diff extraction Eric Wong
2020-01-04  4:19 ` [PATCH 4/3] solver: allow literal '\r' character in diff lines Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200104033415.17097-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git