Hadithcore
Al-Adab Al-Mufrad, 163
hasan· Al-Albani

Abu Umama said, "The Prophet, (ﷺ), came with two slaves and gave one of them to 'Ali and said, 'Do not beat him. I have forbidden beating the people of the prayer and I saw him praying before we came.' He gave Abu Dharr a slave and said, "I recommend that you treat him well,' so Abu Dharr set him free. He said, 'What have you done?' He replied, 'You commanded me to treat him well, so I set him free.'"

حَدَّثَنَا حَجَّاجٌ، قَالَ‏:‏ حَدَّثَنَا حَمَّادٌ، هُوَ ابْنُ سَلَمَةَ، قَالَ‏:‏ أَخْبَرَنَا أَبُو غَالِبٍ، عَنْ أَبِي أُمَامَةَ، قَالَ‏:‏ أَقْبَلَ النَّبِيُّ صلى الله عليه وسلم مَعَهُ غُلامَانِ، فَوَهَبَ أَحَدُهُمَا لِعَلِيٍّ صَلَوَاتُ اللهِ عَلَيْهِ، وَقَالَ‏:‏ لاَ تَضْرِبْهُ، فَإِنِّي نُهِيتُ عَنْ ضَرْبِ أَهْلِ الصَّلاَةِ، وَإِنِّي رَأَيْتُهُ يُصَلِّي مُنْذُ أَقْبَلْنَا، وَأَعْطَى أَبَا ذَرٍّ غُلاَمًا، وَقَالَ‏:‏ اسْتَوْصِ بِهِ مَعْرُوفًا فَأَعْتَقَهُ، فَقَالَ‏:‏ مَا فَعَلَ‏؟‏ قَالَ‏:‏ أَمَرْتَنِي أَنْ أَسْتَوْصِي بِهِ خَيْرًا فَأَعْتَقْتُهُ‏.‏

References2 variants
In-Book Reference
Book 9, Hadith 8
English Reference
Book 9, Hadith 163