Refactor "rev-parse --show-cdup" into a utility function