detached-stash: introduce parse_flags_and_revs function