It's better to avoid being in such a situation, but given that you were in it, good judgment was shown by all involved. It makes far better sense to share gas BEFORE anybody is out; that way, if there is a problem with separation, no one is without something to breathe. But it's also important to remember that, for the vast majority of dives, a safety stop is completely optional, so if there is a low on gas or other urgency, it is fine just to continue a nice, controlled ascent all the way to the big gas tank in the sky