Allow `git cp` to create destination folder automatically by weiw005 · Pull Request #1091 · tj/git-extras
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! Although the code still works for ./foo (because DESTINATION_DIR will simply be ./ and creating it is a harmless no-op), another case that I tested did lead to incorrect behavior which is when the DESTINATION_FILENAME is just a filename. The previous revision would create a folder of that name, and make a copy of the source file into that folder (rather than copy to a file of that name).
I've now switched the condition to be checking whether DESTINATION_FILENAME contains any slash characters - if not the folder creation is skipped.