Our previous pinning prevention only worked to prevent older
(non-most-recent) topics from being pinned to the landing page,
but not the most recent window of messages.
We still sort messages within threads by Date: because that
makes git-send-email patchsets display more nicely, but we
don't want recent topics pinned due to future Date: headers.
I nearly switched sort_ds() back to sorting by Received: until
I looked back on commit
8e52e5fdea416d6fda0b8d301144af0c043a5a76
(use both Date: and Received: times, 2018-03-21) and was reminded
git-send-email relies on Date: for large series, so I added a
note about it for sort_ds().
Reported-by: Kyle Meyer <kyle@kyleam.com>
Tested-by: Kyle Meyer <kyle@kyleam.com>
Link: https://public-inbox.org/meta/87edr5gx63.fsf@kyleam.com/
+# note: we favor Date: here because git-send-email increments it
+# to preserve [PATCH $N/$M] ordering in series (it can't control Received:)
sub sort_ds {
@{$_[0]} = sort {
(eval { $a->topmost->{ds} } || 0) <=>
sub sort_ds {
@{$_[0]} = sort {
(eval { $a->topmost->{ds} } || 0) <=>
if ($has_blob) {
my $subj = subject_normalized($smsg->{subject});
$subj = '(no subject)' if $subj eq '';
if ($has_blob) {
my $subj = subject_normalized($smsg->{subject});
$subj = '(no subject)' if $subj eq '';
my $ds = $smsg->{ds};
if ($level == 0) { # new, top-level topic
my $ds = $smsg->{ds};
if ($level == 0) { # new, top-level topic
- my $topic = [ $ds, 1, { $subj => $mid }, $subj ];
+ my $topic = [ $ts, $ds, 1, { $subj => $mid }, $subj ];
$ctx->{-cur_topic} = $topic;
push @{$ctx->{order}}, $topic;
return 1;
$ctx->{-cur_topic} = $topic;
push @{$ctx->{order}}, $topic;
return 1;
# continue existing topic
my $topic = $ctx->{-cur_topic}; # should never be undef
# continue existing topic
my $topic = $ctx->{-cur_topic}; # should never be undef
- $topic->[0] = $ds if $ds > $topic->[0];
- $topic->[1]++; # bump N+ message counter
- my $seen = $topic->[2];
- if (scalar(@$topic) == 3) { # parent was a ghost
+ $topic->[0] = $ts if $ts > $topic->[0];
+ $topic->[1] = $ds if $ds > $topic->[1];
+ $topic->[2]++; # bump N+ message counter
+ my $seen = $topic->[3];
+ if (scalar(@$topic) == 4) { # parent was a ghost
push @$topic, $subj;
} elsif (!defined($seen->{$subj})) {
push @$topic, $level, $subj; # @extra messages
push @$topic, $subj;
} elsif (!defined($seen->{$subj})) {
push @$topic, $level, $subj; # @extra messages
$seen->{$subj} = $mid; # latest for subject
} else { # ghost message
return 1 if $level != 0; # ignore child ghosts
$seen->{$subj} = $mid; # latest for subject
} else { # ghost message
return 1 if $level != 0; # ignore child ghosts
- my $topic = $ctx->{-cur_topic} = [ -666, 0, {} ];
+ my $topic = $ctx->{-cur_topic} = [ -666, -666, 0, {} ];
push @{$ctx->{order}}, $topic;
}
1;
push @{$ctx->{order}}, $topic;
}
1;
}
# sort by recency, this allows new posts to "bump" old topics...
foreach my $topic (sort { $b->[0] <=> $a->[0] } @$order) {
}
# sort by recency, this allows new posts to "bump" old topics...
foreach my $topic (sort { $b->[0] <=> $a->[0] } @$order) {
- my ($ds, $n, $seen, $top_subj, @extra) = @$topic;
+ my ($ts, $ds, $n, $seen, $top_subj, @extra) = @$topic;
@$topic = ();
next unless defined $top_subj; # ghost topic
my $mid = delete $seen->{$top_subj};
@$topic = ();
next unless defined $top_subj; # ghost topic
my $mid = delete $seen->{$top_subj};