Sanctuary
You ward a creature within range. Until the spell ends, any creature who targets the warded creature with an attack roll or a damaging spell must succeed on a Wisdom saving throw or either choose a new target or lose the attack or spell. This spell doesn't protect the warded creature from areas of effect.
The spell ends if the warded creature makes an attack roll, casts a spell, or deals damage.
Sanctuary 5e 2024 vs. 2014 edition differences
The 2024 version specifies "attack roll" and "damaging spell," clarifying targeting conditions, and states the spell ends if the warded creature makes an attack roll, casts a spell, or deals damage, whereas the 2014 version ends if the creature makes an attack, casts a spell affecting an enemy, or deals damage.