'Of course they were,' said Fudge. 'Potter trusted Black beyond all his other friends. Nothing changed when they left school. Black was best man when James married Lily. Then they named him godfather to Harry. Harry has no idea, of course. You can imagine how the idea would torment him.'
'Because Black turned out to be in league with You-Know-Who?' whispered Madam Rosmerta.
'Worse even than that, m'dear ...' Fudge dropped his voice and proceeded in a sort of low rumble.
I don't understand the sentence "they named him godfather to Harry". What does it convey in this context?
Edit: I know the word 'name' means, but I don't understand why they call him "godfather to Harry". What does that imply? Maybe, my difficulty lies in what godfather would do?