Genealogies in scripture do not necessarily operate according to the logic you might expect. Consider Caleb the son of Jephunneh the Kenizzite, one of the guides provided by Hovav son of Reuel the Midianite at the behest of Moses:
And Moses said to Hobab the son of Reuel the Midianite, Moses’ father-in-law, “We are setting out for the place of which the LORD said, ‘I will give it to you.’ Come with us, and we will do good to you, for the LORD has promised good to Israel.” But he said to him, “I will not go. I will depart to my own land and to my kindred.” And he said, “Please do not leave us, for you know where we should camp in the wilderness, and you will serve as eyes for us. And if you do go with us, whatever good the LORD will do to us, the same will we do to you.” (Numbers 10:29-32)
Caleb is later chosen by Judah as one of the men from each tribe sent into Canaan to spy out the land, and it is Caleb who later encourages the Israelites to enter the land despite the reservations of other spies:
And they told him, “We came to the land to which you sent us. It flows with milk and honey, and this is its fruit. However, the people who dwell in the land are strong, and the cities are fortified and very large. And besides, we saw the descendants of Anak there. The Amalekites dwell in the land of the Negeb. The Hittites, the Jebusites, and the Amorites dwell in the hill country. And the Canaanites dwell by the sea, and along the Jordan.” But Caleb quieted the people before Moses and said, “Let us go up at once and occupy it, for we are well able to overcome it.” Then the men who had gone up with him said, “We are not able to go up against the people, for they are stronger than we are.” (Numbers 13:25-32)
Though not an Israelite by birth, Caleb’s faith gains him a choice inheritance in the territory allotted to Judah (Joshua 14:6-14):
Then the people of Judah came to Joshua at Gilgal. And Caleb the son of Jephunneh the Kenizzite said to him, “You know what the LORD said to Moses the man of God in Kadesh-barnea concerning you and me. I was forty years old when Moses the servant of the LORD tent me from Kadesh-barnea to spy out the land, and I brought him word again as it was in my heart. But my brothers who went up with me made the heart of the people melt; yet I wholly followed the LORD my God. And Moses swore on that day, saying, ‘Surely the land won which your foot has trodden shall be an inheritance for you and your children forever, because you have wholly followed the LORD my God.’
And now, behold, the LORD has kept me alive, just as he said, these forty-five years since the time that the LORD spoke this word to Moses, while Israel walked in the wilderness. And now, behold, I am this day eighty-five years old. I am still as strong today as I was in the day that Moses sent me; my strength now is as my strength was then, for war and for going and coming. So now give me this hill country of which the LORD spoke on that day, for you heard on that day how the Anakim were there, with great fortified cities. It may be that the LORD will be with me, and I shall drive them out just as the LORD said.” Then Joshua blessed him, and he gave Hebron to Caleb the son of Jephunneh for an inheritance. Therefore Hebron became the inheritance of Caleb the son of Jephunneh the Kenizzite to this day, because he wholly followed the LORD, the God of Israel.
Caleb is thereafter numbered among the descendants of Judah through Perez and Hezron:
The sons of Judah: Er, Onan and Shelah; these three Bath-shua the Canaanite bore to him. Now Er, Judah’s firstborn, was evil in the sight of the LORD, and he put him to death. His daughter-in-law Tamar also bore him Perez and Zerah. Judah had five sons in all. The sons of Perez: Hezron and Hamul. (1 Chronicles 2:3-5)
Caleb the son of Hezron fathered children by his wife Azubah, and by Jerioth; and these were her sons: Jesher, Shobab, and Ardon. (1 Chronicles 2:18)
In effect, Caleb was grafted into the line of Jacob by faith.