add rename

This avoids creating the target directory if the old and new path are
identical.

required for js-git data integrity fix I'm about to push.
If you move this case to the top on the `if` and use a return, then the else block won't be needed and the larger section can save a level of indentation.