Fix writing diff when sub-directories are under base path