Both Mary and Joseph descended from David’s line.
Mary’s lineage is detailed in Luke 3: 23-38.
Joseph’s lineage is detailed in Matthew 1: 1-17
Per the MacArthur Study Bible Notes: Luke 3:2338 Lukes genealogy moves backward, from Jesus to Adam; Matthews moves forward, from Abraham to Joseph. Lukes entire section from Joseph to David differs starkly from that given by Matthew. The two genealogies are easily reconciled if Lukes is seen as Marys genealogy, and Matthews version represents Josephs. Thus the royal line is passed through Jesus legal father, and his physical descent from David is established by Marys lineage. Luke, unlike Matthew (see note on Matt. 1:3), includes no women in his genealogyeven Mary herself. Joseph was the son of Heli by marriage (Heli having no sons of his own), and thus is named here in Luke 3:23 as the representative of Marys generation.
The scholars have to really work at this stuff to keep the dogma about Joseph being a stepfather afloat. Meanwhile, the Messiah is the son of David. Son to son to son. Y chromosome. Tribe father, religion mother. Nobody's going to recognize because traditions void out the Word of God.
This is what happened when man couldn't see any other dynamic for a virgin birth, other than to decide that the Messiah has to be god then.
In this day and age especially, there is absolutely no excuse for that. For almost *40 years* now, man has caused conception by means of physicians and lab technicians. That does not mean those people are the babies' fathers, except for those creepy stories of malevolent fertility docs 'getting around'.