314d1a9a41231220ae79fc971758da141c21f233
markd
  Fri Oct 2 21:36:10 2026 -0700
Revert the superTrack nesting fix on master; it lives on superTrackNesting. refs #38460

Taken off master with its only consumer, the TSS trackDb change reverted in the
previous commit. It is a library change every CGI links, in trackDbCustom.c,
hdb.c, hubConnect.c and hgTracks.c, and nothing on master needs it until the TSS
tracks nest again.

Kept on the superTrackNesting branch with its regression evidence. Note for
whoever lands it: trackDbToTxt has to be rebuilt too, or the curated hub it
writes names a parent stanza it did not emit.

diff --git src/hg/lib/hubConnect.c src/hg/lib/hubConnect.c
index af9b83a9a9f..219ffc10a3a 100644
--- src/hg/lib/hubConnect.c
+++ src/hg/lib/hubConnect.c
@@ -480,44 +480,35 @@
 }
 
 static struct trackDb *findSuperTrack(struct trackDb *tdbList, char *trackName)
 /*  discover any supertracks, and if there are some add them 
  *  to the subtrack list of the supertrack */
 {
 struct trackDb *tdb;
 struct trackDb *p = NULL;
 struct trackDb *next;
 
 for(tdb = tdbList; tdb; tdb = next)
     {
     /* save away the next pointer becuase we may detach this node and
      * add it to its supertrack parent */
     next = tdb->next;
-    /* Walk up the chain: a supertrack may sit inside another supertrack, and
-     * neither is in tdbList, so an outer one is only named by an ancestor of a
-     * track that is.  Only an immediate child is added as a subtrack. */
-    struct trackDb *ancestor;
-    for (ancestor = tdb->parent; ancestor != NULL; ancestor = ancestor->parent)
+    if (tdb->parent != NULL && sameString(trackName, tdb->parent->track))
 	{
-	if (sameString(trackName, ancestor->track))
-	    {
-	    /* found a supertrack with the right name */
-	    p = ancestor;
-	    if (ancestor == tdb->parent)
+	/* found a supertrack with the right name, add this child */
+	p = tdb->parent;
 	slAddHead(&p->subtracks, tdb);
-	    break;
-	    }
 	}
     }
 
 return p;
 }
 
 
 void hubConnectAddDescription(char *database, struct trackDb *tdb)
 /* Fetch tdb->track's html description (or nearest ancestor's non-empty description)
  * and store in tdb->html. */
 {
 unsigned hubId = hubIdFromTrackName(tdb->track);
 struct hubConnectStatus *hub = hubFromId(hubId);
 struct trackHubGenome *hubGenome = trackHubFindGenome(hub->trackHub, database);
 trackHubPolishTrackNames(hub->trackHub, tdb);