Hakeem bin Hizam reported,

"Messenger of Allah, do you think the deeds I used to perform in piety during the days of ignorance, such as maintaining kinship ties, freeing slaves, and giving charity, will earn me any reward?"Hakeem said that the Messenger of Allah ﷺ replied, "You have embraced Islam along with all the good you did before."It is also reported from Abu al-Yaman with the wording "atahannath." Muamar, Salih, and Ibn al-Musafir likewise said "atahannath." Ibn Ishaq explained that "tahannuth" means seeking righteousness. Hisham followed them in this, narrating from his father.

Bukhari 5992

Sahih

حدثنا أبو اليمان أخبرنا شعيب عن الزهري قال أخبرني عروة بن الزبير أن

حكيم بن حزام أخبره أنه قال

يا رسول الله أرأيت أمورا كنت أتحنث بها في الجاهلية من صلة وعتاقة وصدقة هل لي فيها من أجر قال حكيم قال رسول الله ﷺ أسلمت على ما سلف من خير ويقال أيضا عن أبي اليمان أتحنث وقال معمر وصالح وابن المسافر أتحنث وقال ابن إسحاق التحنث التبرر وتابعهم هشام عن أبيه

البخاري 5992صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Manners
Chapter
One who maintained ties of kinship while in shirk then accepted Islam
Numbering
Darussalam 5992
Bukhari 5992