Pacman does check for changes in configuration files, and adds .pacnew files instead of overwriting them:
https://wiki.archlinux.org/title/Pacman/Pacnew_and_Pacsave