Fix edge case when rel path changes from file to dir (2014.1 branch)

**This is #11280, cherrypicked for the 2014.1 branch**

This fixes an edge case in gitfs where a path that once was a file is
now a directory.