Ibn Abbas reported that on the day of Badr, the captives were brought in, and Abbas was among them, but he had no garment on. The Prophet ﷺ looked for a shirt to fit him, and they found that the shirt of Abdullah bin Ubayy was the one that suited him, so the Prophet ﷺ clothed him in it. That is why the Prophet ﷺ later removed his own shirt and placed it on Abdullah bin Ubayy.Ibn Uyayna said, "Abdullah bin Ubayy had once done the Prophet ﷺ a favor, so he wished to repay him in kind."
لما كان يوم بدر أتي بأسارى، وأتي بالعباس، ولم يكن عليه ثوب، فنظر النبي ﷺ له قميصا، فوجدوا قميص عبد الله بن أبي يقدر عليه، فكساه النبي ﷺ إياه، فلذلك نزع النبي ﷺ قميصه الذي ألبسه. قال ابن عيينة: كانت له عند النبي ﷺ يد، فأحب أن يكافئه.
Bukhari narrated it in Jihad and Expeditions (3008), from Abdullah bin Muhammad, who said, "Ibn Uyayna narrated to us, from Amr, who heard Jabir bin Abdullah," and he related it.