It was narrated from Abdullah bin Safwan that :
his father slept in the mosque, using his upper wrap as a pillow, and it was taken from beneath his head. He brought the thief to the Prophet (ﷺ) and the Prophet (ﷺ) ordered that his hand be cut off. Safwan said: "O Messenger of Allah , (ﷺ) I did not want this! I give my upper wrap to him in charity." The Messenger of Allah (ﷺ) said: "Why did you not give it to him before you brought him to me?"
English reference: Vol. 3, Book 20, Hadith 2595
Arabic reference: Book 20, Hadith 2693