builtin/notes.c: Split notes ref DWIMmery into a separate function