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/makeDb/hgTrackDb/hgTrackDb.c src/hg/makeDb/hgTrackDb/hgTrackDb.c
index 19687b0b51c..bd8d9563bef 100644
--- src/hg/makeDb/hgTrackDb/hgTrackDb.c
+++ src/hg/makeDb/hgTrackDb/hgTrackDb.c
@@ -699,36 +699,32 @@
 {
 struct trackDb *tdb;
 for (tdb = tdbList; tdb != NULL; tdb = tdb->next)
     {
     trackDbPolish(tdb);
     rPolish(tdb->subtracks);
     }
 }
 
 static void polishSupers(struct trackDb *tdbList)
 /* Run polish on supertracks. */
 {
 struct trackDb *tdb;
 for (tdb = tdbList; tdb != NULL; tdb = tdb->next)
     {
-    /* Walk the whole chain of parents, not just the immediate one: a supertrack
-     * inside another supertrack is reached only through its child, and without
-     * its fields filled in from settings it reaches the write with a NULL
-     * shortLabel. */
-    struct trackDb *parent;
-    for (parent = tdb->parent; parent != NULL; parent = parent->parent)
+    struct trackDb *parent = tdb->parent;
+    if (parent != NULL)
 	{
 	trackDbFieldsFromSettings(parent);
 	trackDbPolish(parent);
 	}
     }
 }
 
 static struct trackDb *buildTrackDb(char *org, char *database, char *hgRoot, boolean strict)
 /* Build trackDb objects from files. */
 {
 struct hash *trackHash = newHash(0);
 char rootDir[PATH_LEN], orgDir[PATH_LEN], asmDir[PATH_LEN];
 
 /* Create track list from hgRoot and hgRoot/org and hgRoot/org/assembly
  * ra format database. */
@@ -777,44 +773,41 @@
 
 return tdbList;
 }
 
 static struct trackDb *flatten(struct trackDb *tdbForest)
 /* Convert our peculiar forest back to a list.
  * This for now rescues superTracks from the heavens. */
 {
 struct hash *superTrackHash = hashNew(0);
 struct slRef *ref, *refList = trackDbListGetRefsToDescendants(tdbForest);
 
 struct trackDb *tdbList = NULL;
 for (ref = refList; ref != NULL; ref = ref->next)
     {
     struct trackDb *tdb = ref->val;
-    /* Walk up the chain of floating supertrack parents, not just the immediate
-     * one: a supertrack may itself sit inside another supertrack, and only the
-     * innermost is reachable from a track in the forest. */
-    struct trackDb *parent;
-    for (parent = tdb->parent; parent != NULL && tdbIsSuperTrack(parent);
-         parent = parent->parent)
+    struct trackDb *parent = tdb->parent;
+    if (parent != NULL && tdbIsSuperTrack(parent))
 	{
 	/* The supertrack may appear as a 'floating' parent for multiple tracks.
 	 * Only put it on the list once. */
-	if (hashLookup(superTrackHash, parent->track))
-	    break;
+	if (!hashLookup(superTrackHash, parent->track))
+	    {
 	    hashAdd(superTrackHash, parent->track, parent);
 	    slAddHead(&tdbList, parent);
 	    }
+	}
     slAddHead(&tdbList, tdb);
     }
 
 slFreeList(&refList);
 hashFree(&superTrackHash);
 slReverse(&tdbList);
 return tdbList;
 }
 
 static int findMaxCartVersion(struct trackDb *tdbList)
 /* Search the track list for the maximum cartVersion. */
 {
 struct trackDb *tdb;
 int maxVal = 0;
 for (tdb = tdbList; tdb != NULL; tdb = tdb->next)