diff: fix and improve detection of filename