diff options
author | Lluis Sanchez <slluis.devel@gmail.com> | 2016-04-18 20:48:11 +0300 |
---|---|---|
committer | Lluis Sanchez <slluis.devel@gmail.com> | 2016-04-18 20:48:11 +0300 |
commit | d244f0ec0bb38124dbbc41a6290258c9931259ce (patch) | |
tree | f32b39192940ce95e37a4e8d27db2781e39604cc /main | |
parent | f1b7c29d0d498c67f7f7d8a65c4e7568c2c4804f (diff) | |
parent | f24866a93308e2cbab260adc0823509f5ac42fd7 (diff) |
Merge pull request #1396 from mono/bug35665
Case rename support.
Diffstat (limited to 'main')
2 files changed, 23 insertions, 2 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs index 01e1c89b1d..18b280abcf 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs @@ -1444,7 +1444,19 @@ namespace MonoDevelop.VersionControl.Git dstRepo.Unstage (localDestPath); if (srcRepo == dstRepo) { - srcRepo.Move (localSrcPath, localDestPath); + if (string.Equals (localSrcPath, localDestPath, StringComparison.OrdinalIgnoreCase)) { + try { + string temp = Path.GetTempFileName (); + File.Delete (temp); + File.Move (localSrcPath, temp); + DeleteFile (localSrcPath, true, monitor, false); + File.Move (temp, localDestPath); + } finally { + srcRepo.Stage (localDestPath); + } + } else {
+ srcRepo.Move (localSrcPath, localDestPath); + } ClearCachedVersionInfo (localSrcPath, localDestPath); } else { File.Copy (localSrcPath, localDestPath); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs index 8142f496d2..a3cb32a7bb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs @@ -181,7 +181,7 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad if (!FileService.IsValidPath (newPath) || ProjectFolderCommandHandler.ContainsDirectorySeparator (newName)) { MessageService.ShowWarning (GettextCatalog.GetString ("The name you have chosen contains illegal characters. Please choose a different name.")); - } else if ((newProjectFile != null && newProjectFile != file) || File.Exists (file.FilePath.ParentDirectory.Combine (newName))) { + } else if ((newProjectFile != null && newProjectFile != file) || FileExistsCaseSensitive (file.FilePath.ParentDirectory, newName)) { // If there is already a file under the newPath which is *different*, then throw an exception MessageService.ShowWarning (GettextCatalog.GetString ("File or directory name is already in use. Please choose a different one.")); } else { @@ -195,6 +195,15 @@ namespace MonoDevelop.Ide.Gui.Pads.ProjectPad MessageService.ShowError (GettextCatalog.GetString ("There was an error renaming the file."), ex); } } + + static bool FileExistsCaseSensitive (FilePath parentDirectory, string fileName) + { + if (!Directory.Exists (parentDirectory)) + return false; + + return Directory.GetFiles (parentDirectory, fileName) + .Any (file => Path.GetFileName (file) == fileName); + } public override void ActivateItem () { |