unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/3] lei rediff fixes
@ 2021-05-05 17:49 Eric Wong
  2021-05-05 17:49 ` [PATCH 1/3] script/public-inbox-extindex: chmod +x Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2021-05-05 17:49 UTC (permalink / raw)
  To: meta

1/3 was necessary anyways, and also provided a test case for
2/3.  3/3 makes things less surprising, and thankfully wasn't
difficult at all.

Eric Wong (3):
  script/public-inbox-extindex: chmod +x
  lei rediff: capture and regenerate file modes
  lei rediff: do not automatically store patches/mails

 MANIFEST                     |  1 +
 lib/PublicInbox/LeiRediff.pm | 28 ++++++++++++++++++++--------
 script/public-inbox-extindex |  1 -
 t/solve/bare.patch           |  8 ++++++++
 t/solver_git.t               | 16 ++++++++++++++++
 5 files changed, 45 insertions(+), 9 deletions(-)
 mode change 100644 => 100755 script/public-inbox-extindex
 create mode 100644 t/solve/bare.patch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] script/public-inbox-extindex: chmod +x
  2021-05-05 17:49 [PATCH 0/3] lei rediff fixes Eric Wong
@ 2021-05-05 17:49 ` Eric Wong
  2021-05-05 17:49 ` [PATCH 2/3] lei rediff: capture and regenerate file modes Eric Wong
  2021-05-05 17:49 ` [PATCH 3/3] lei rediff: do not automatically store patches/mails Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-05-05 17:49 UTC (permalink / raw)
  To: meta

Everything else that's intended to be executable at some
point has the executable bit set.  Remove an inaccurate
comment while we're at it.
---
 script/public-inbox-extindex | 1 -
 1 file changed, 1 deletion(-)
 mode change 100644 => 100755 script/public-inbox-extindex

diff --git a/script/public-inbox-extindex b/script/public-inbox-extindex
old mode 100644
new mode 100755
index 15ac20eb..771486c4
--- a/script/public-inbox-extindex
+++ b/script/public-inbox-extindex
@@ -1,7 +1,6 @@
 #!perl -w
 # Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-# Basic tool to create a Xapian search index for a public-inbox.
 use strict;
 use v5.10.1;
 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] lei rediff: capture and regenerate file modes
  2021-05-05 17:49 [PATCH 0/3] lei rediff fixes Eric Wong
  2021-05-05 17:49 ` [PATCH 1/3] script/public-inbox-extindex: chmod +x Eric Wong
@ 2021-05-05 17:49 ` Eric Wong
  2021-05-05 17:49 ` [PATCH 3/3] lei rediff: do not automatically store patches/mails Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-05-05 17:49 UTC (permalink / raw)
  To: meta

Don't lose file mode information when regenerating a diff.
---
 MANIFEST                     |  1 +
 lib/PublicInbox/LeiRediff.pm | 19 +++++++++++++++----
 t/solve/bare.patch           |  8 ++++++++
 t/solver_git.t               | 13 +++++++++++++
 4 files changed, 37 insertions(+), 4 deletions(-)
 create mode 100644 t/solve/bare.patch

diff --git a/MANIFEST b/MANIFEST
index 7be07aa5..a6d94c77 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -480,6 +480,7 @@ t/shared_kv.t
 t/sigfd.t
 t/solve/0001-simple-mod.patch
 t/solve/0002-rename-with-modifications.patch
+t/solve/bare.patch
 t/solver_git.t
 t/spamcheck_spamc.t
 t/spawn.t
diff --git a/lib/PublicInbox/LeiRediff.pm b/lib/PublicInbox/LeiRediff.pm
index 6c734bef..d73e3e28 100644
--- a/lib/PublicInbox/LeiRediff.pm
+++ b/lib/PublicInbox/LeiRediff.pm
@@ -16,6 +16,8 @@ use PublicInbox::Import;
 use PublicInbox::LEI;
 use PublicInbox::SolverGit;
 
+my $MODE = '(100644|120000|100755|160000)';
+
 sub rediff_user_cb { # called by solver when done
 	my ($res, $self) = @_;
 	my $lei = $self->{lei};
@@ -69,7 +71,7 @@ EOM
 	$tb =~ tr!A!B!;
 	my $lei = $self->{lei};
 	my $wait = delete($self->{-do_done}) ? $lei->{sto}->ipc_do('done') : 0;
-	while (my ($oid_a, $oid_b, $pa, $pb) = splice(@$ctxq, 0, 4)) {
+	while (my ($oid_a, $oid_b, $pa, $pb, $ma, $mb) = splice(@$ctxq, 0, 6)) {
 		my $xa = $blob->{$oid_a} //= solve_1($self, $oid_a,
 							{ path_b => $pa });
 		my $xb = $blob->{$oid_b} //= solve_1($self, $oid_b, {
@@ -77,8 +79,8 @@ EOM
 						path_a => $pa,
 						path_b => $pb
 					});
-		$ta .= "M 100644 $xa ".git_quote($pa)."\n" if $xa;
-		$tb .= "M 100644 $xb ".git_quote($pb)."\n" if $xb;
+		$ta .= "M $ma $xa ".git_quote($pa)."\n" if $xa;
+		$tb .= "M $mb $xb ".git_quote($pb)."\n" if $xb;
 	}
 	my $rw = $self->{gits}->[-1]; # has all known alternates
 	if (!$rw->{-tmp}) {
@@ -148,6 +150,15 @@ sub extract_oids { # Eml each_part callback
 		if (scalar(@top) >= 4 &&
 				$top[1] =~ $PublicInbox::ViewDiff::IS_OID &&
 				$top[0] =~ $PublicInbox::ViewDiff::IS_OID) {
+			my ($ma, $mb);
+			$x =~ /^old mode $MODE/sm and $ma = $1;
+			$x =~ /^new mode $MODE/sm and $mb = $1;
+			if (!defined($ma) && $x =~
+				/^index [a-z0-9]+\.\.[a-z0-9]+ $MODE/sm) {
+				$ma = $mb = $1;
+			}
+			$ma //= '100644';
+			$mb //= $ma;
 			my ($oid_a, $oid_b, $pa, $pb) = splice(@top, 0, 4);
 			$pa eq '/dev/null' or
 				$pa = (split(m'/', git_unquote($pa), 2))[1];
@@ -155,7 +166,7 @@ sub extract_oids { # Eml each_part callback
 				$pb = (split(m'/', git_unquote($pb), 2))[1];
 			$blobs->{$oid_a} //= undef;
 			$blobs->{$oid_b} //= undef;
-			push @$ctxq, $oid_a, $oid_b, $pa, $pb;
+			push @$ctxq, $oid_a, $oid_b, $pa, $pb, $ma, $mb;
 		} elsif ($ctxq) {
 			my @out;
 			for (split(/^/sm, $x)) {
diff --git a/t/solve/bare.patch b/t/solve/bare.patch
new file mode 100644
index 00000000..25d7f344
--- /dev/null
+++ b/t/solve/bare.patch
@@ -0,0 +1,8 @@
+diff --git a/script/public-inbox-extindex b/script/public-inbox-extindex
+old mode 100644
+new mode 100755
+index 15ac20eb..771486c4
+--- a/script/public-inbox-extindex
++++ b/script/public-inbox-extindex
+@@ -4 +3,0 @@
+-# Basic tool to create a Xapian search index for a public-inbox.
diff --git a/t/solver_git.t b/t/solver_git.t
index 44cbbfdb..ad0c295b 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -73,6 +73,19 @@ test_lei({tmpdir => "$tmpdir/rediff"}, sub {
 	lei_ok(qw(rediff -q -U9 t/solve/0001-simple-mod.patch));
 	like($lei_out, qr!^\Q+++\E b/TODO\n@@ -103,9 \+103,11 @@!sm,
 		'got more context with -U9');
+	lei_ok(qw(rediff -q -U9 t/solve/bare.patch));
+	my $exp = <<'EOM';
+diff --git a/script/public-inbox-extindex b/script/public-inbox-extindex
+old mode 100644
+new mode 100755
+index 15ac20eb..771486c4
+--- a/script/public-inbox-extindex
++++ b/script/public-inbox-extindex
+@@ -1,13 +1,12 @@
+ #!perl -w
+EOM
+	ok(index($lei_out, $exp) >= 0,
+		'preserve mode, regen header + context from -U0 patch');
 });
 
 test_lei({tmpdir => "$tmpdir/index-eml-only"}, sub {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] lei rediff: do not automatically store patches/mails
  2021-05-05 17:49 [PATCH 0/3] lei rediff fixes Eric Wong
  2021-05-05 17:49 ` [PATCH 1/3] script/public-inbox-extindex: chmod +x Eric Wong
  2021-05-05 17:49 ` [PATCH 2/3] lei rediff: capture and regenerate file modes Eric Wong
@ 2021-05-05 17:49 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-05-05 17:49 UTC (permalink / raw)
  To: meta

We can use a temporary lei/store to avoid cluttering up
future search results.  This is especially useful since
we expect "lei rediff" to be useful for non-email diffs
and individual attachments, too.
---
 lib/PublicInbox/LeiRediff.pm | 9 +++++----
 t/solver_git.t               | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/LeiRediff.pm b/lib/PublicInbox/LeiRediff.pm
index d73e3e28..deb6c3ae 100644
--- a/lib/PublicInbox/LeiRediff.pm
+++ b/lib/PublicInbox/LeiRediff.pm
@@ -70,7 +70,6 @@ EOM
 	my $tb = $ta;
 	$tb =~ tr!A!B!;
 	my $lei = $self->{lei};
-	my $wait = delete($self->{-do_done}) ? $lei->{sto}->ipc_do('done') : 0;
 	while (my ($oid_a, $oid_b, $pa, $pb, $ma, $mb) = splice(@$ctxq, 0, 6)) {
 		my $xa = $blob->{$oid_a} //= solve_1($self, $oid_a,
 							{ path_b => $pa });
@@ -193,8 +192,8 @@ sub extract_oids { # Eml each_part callback
 
 sub input_eml_cb { # callback for all emails
 	my ($self, $eml) = @_;
-	$self->{lei}->{sto}->ipc_do('add_eml', $eml);
-	$self->{-do_done} = 1;
+	$self->{tmp_sto}->add_eml($eml);
+	$self->{tmp_sto}->done;
 	$eml->each_part(\&extract_oids, $self, 1);
 }
 
@@ -239,7 +238,9 @@ sub ipc_atfork_child {
 	binmode $lei->{1}, ':utf8';
 	$self->{blobs} = {}; # oidhex => filename
 	$self->{rdtmp} = File::Temp->newdir('lei-rediff-XXXX', TMPDIR => 1);
-	$self->{rmt} = [ map {
+	$self->{tmp_sto} = PublicInbox::LeiStore->new(
+			"$self->{rdtmp}/tmp.store", { creat => 1 });
+	$self->{rmt} = [ $self->{tmp_sto}->search, map {
 			PublicInbox::LeiRemote->new($lei, $_)
 		} $self->{lxs}->remotes ];
 	$self->{gits} = [ map {
diff --git a/t/solver_git.t b/t/solver_git.t
index ad0c295b..13e478b3 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -86,6 +86,9 @@ index 15ac20eb..771486c4
 EOM
 	ok(index($lei_out, $exp) >= 0,
 		'preserve mode, regen header + context from -U0 patch');
+	my $e = { GIT_DIR => "$ENV{HOME}/.local/share/lei/store/ALL.git" };
+	my @x = xqx([qw(git cat-file --batch-all-objects --batch-check)], $e);
+	is_deeply(\@x, [], 'no objects stored') or diag explain(\@x);
 });
 
 test_lei({tmpdir => "$tmpdir/index-eml-only"}, sub {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-05 17:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 17:49 [PATCH 0/3] lei rediff fixes Eric Wong
2021-05-05 17:49 ` [PATCH 1/3] script/public-inbox-extindex: chmod +x Eric Wong
2021-05-05 17:49 ` [PATCH 2/3] lei rediff: capture and regenerate file modes Eric Wong
2021-05-05 17:49 ` [PATCH 3/3] lei rediff: do not automatically store patches/mails Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).