So I just found a command that I think i can use to detect the "merge_head"
git rev-parse -q --verify MERGE_HEAD
If rev-parse returns a hash that means we are currently in a merge state. I can use that to bypass this logic. But will wait for some better advice from more experienced individuals.