The Prophet, pbuh, was keen to provide the most perfect conditions for Muslims to attain devoutness during prayer in congregational in particular. Accordingly, it is sunnah of the Prophet for those bad brethed not to witness congregational prayer until he is cleaned, because missing the congregational prayer for one or two is better than missing devoutness for the masses of Muslims. Such bad smell comes out from many foods, like garlic, onions, and leeks. It is related in Bukhari that the Prophet, pbuh, said: (a Muslim having eaten from this tree, namely garlic, should not attend mosques. `Ataa asked jabber: what is meant by that? Jaber replied: the Prophet definitely meant the raw of garlic).
Muslim narrated: (the Prophet, pbuh, forbade eating onions and leeks. Jabber said: we became eager to them and hence we ate, so the Prophet said: whoever a Muslim ate from this odious tree shall not approach mosque, as angels disdain what humans do)
The latter narration specifically referred to the reason behind forbiddance, which reflects the permission of eating these foods. This is demonstrated in the narration cited in Muslim on the authority of Abu-Said who said: ( after opening Khaibar we ate very much from garlic as people were very hungry, then we went to mosque, and the Prophet smelled its odor and said: whoever a Muslim eats from this heinous tree shall not approach the mosque. Muslims thought it is forbidden which reached the Prophet who commented: O people! I cannot forbid anything Allah Almighty held it permissible, however, it is a tree I dislike I hate its odor)
It is narrated in Abu-dawud, Al-Albani ranked it sound, that the Prophet, pbuh, said: (if you eat them, then cook them extremely, namely onions and garlic)
Let's be keen to dhere to this fine sunnah, and we should keep in mind that people feel disguise for he same we do.