كتاب الأشربة
36  
The Book of Drinks
(31)
Chapter: It is permissible to eat garlic, but the one who is going to address prominent people should refrain from eating it, and the same applies to other, similar foods
(31)
باب إِبَاحَةِ أَكْلِ الثُّومِ وَأَنَّهُ يَنْبَغِي لِمَنْ أَرَادَ خِطَابِ الْكِبَارِ تَرْكُهُ وَكَذَا مَا فِي مَعْنَاهُ
Sahih Muslim 2053 a

Abd Ayydb Ansari reported that when food was brought to Allah's Messenger (ﷺ) he ate out of that, and sent the remaining part to me, and one day he sent to me the left-over; (I found that he) had not taken from it at all for it included garlic. I asked him whether that was forbidden, whereupon he said:

No, but I do not like it because of its odour. He (Abu Ayyub Ansiri) said: Then I also do not like what you do not like.
حَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، وَابْنُ، بَشَّارٍ - وَاللَّفْظُ لاِبْنِ الْمُثَنَّى - قَالاَ حَدَّثَنَا مُحَمَّدُ، بْنُ جَعْفَرٍ حَدَّثَنَا شُعْبَةُ، عَنْ سِمَاكِ بْنِ حَرْبٍ، عَنْ جَابِرِ بْنِ سَمُرَةَ، عَنْ أَبِي أَيُّوبَ الأَنْصَارِيِّ، قَالَ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم إِذَا أُتِيَ بِطَعَامٍ أَكَلَ مِنْهُ وَبَعَثَ بِفَضْلِهِ إِلَىَّ وَإِنَّهُ بَعَثَ إِلَىَّ يَوْمًا بِفَضْلَةٍ لَمْ يَأْكُلْ مِنْهَا لأَنَّ فِيهَا ثُومًا فَسَأَلْتُهُ أَحَرَامٌ هُوَ قَالَ ‏ "‏ لاَ وَلَكِنِّي أَكْرَهُهُ مِنْ أَجْلِ رِيحِهِ ‏"‏ ‏.‏ قَالَ فَإِنِّي أَكْرَهُ مَا كَرِهْتَ ‏.‏
Reference : Sahih Muslim 2053a
In-book reference : Book 36, Hadith 230
USC-MSA web (English) reference : Book 23, Hadith 5097
  (deprecated numbering scheme)