Not sure what year your M5 was. If you had an E39, chances are it was ok.
I'm talking about most BMWs after 2002, or whenever they started using the IBS sensor on the battery terminal. Then everyone started using similar stuff.
The story goes the car is better off when you charge through the IBS, so it can control things. Charging at the battery's poles bypasses it. Which won't damage the battery, but might damage car electronics.
You won't automatically damage the car if you charge directly at the poles, but there's a real risk. So if you have to do that - disconnect the car's cables first.
Which, in itself, is a whole different adventure, as a BMW has to go to sleep gracefully before you disconnect, which is a whole thing.
I put "German" together, as they all use such a system nowadays, one way or the other.