magit-toplevel-safe: append slash to DIRECTORY if necessary