about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchThread.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/SearchThread.pm')
-rw-r--r--lib/PublicInbox/SearchThread.pm4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/PublicInbox/SearchThread.pm b/lib/PublicInbox/SearchThread.pm
index 1d250b46..450a06f4 100644
--- a/lib/PublicInbox/SearchThread.pm
+++ b/lib/PublicInbox/SearchThread.pm
@@ -76,7 +76,9 @@ sub _add_message ($$) {
 
         # C. Set the parent of this message to be the last element in
         # References.
-        $prev->add_child($this) if defined $prev;
+        if (defined $prev && !$this->has_descendent($prev)) { # would loop
+                $prev->add_child($this);
+        }
 }
 
 package PublicInbox::SearchThread::Msg;