Bug 2711 - Git switch remote branch fails, "Wrong Repository State: SAFE"
Summary: Git switch remote branch fails, "Wrong Repository State: SAFE"
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Version Control ()
Version: 2.8.4.1
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Alan McGovern
URL:
Depends on:
Blocks:
 
Reported: 2012-01-02 09:07 UTC by Robert Nordan
Modified: 2012-02-21 10:44 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Robert Nordan 2012-01-02 09:07:08 UTC
From my post to the mailing list:

Hi all, I'm trying to use the MonoDevelop version control system to build a specific branch of Pinta but failing.

This is my approach:

1) Checkout git://github.com/PintaProject/Pinta.git , which gives me the
master branch.
2) Choose the menu Version Control -> Manage Branches and Remotes ->
Remote Sources and track release-1.1 in the local branch.
3) Choose the menu Version Control -> Switch to Branch -> release-1.1 ,
which seems to change (The title changes from Pinta (master) to Pinta
(release-1.1)) but the files do not change, so I assume it behaves like
when you create a local branch.
4) Therefore I choose the menu Version Control -Update Solution
because I imagine it will work like "git pull origin release-1.1", but I
get this error message:

Version control operation failed: Wrong Repository State: SAFE. Wrong
Repository State: SAFE.

Details: 

NGit.Api.Errors.WrongRepositoryStateException: Wrong Repository State:
SAFE
 at NGit.Api.RebaseCommand.CheckParameters () [0x00000] in <filename
unknown>:0 
 at NGit.Api.RebaseCommand.Call () [0x00000] in <filename unknown>:0 
 at MonoDevelop.VersionControl.Git.GitRepository.Rebase (System.String
upstreamRef, Boolean saveLocalChanges, IProgressMonitor monitor)
[0x001fb]
in /usr/src/packages/BUILD/monodevelop-2.8.1/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs:447 
 at MonoDevelop.VersionControl.Git.GitRepository.Update
(MonoDevelop.Core.FilePath[] localPaths, Boolean recurse,
IProgressMonitor monitor) [0x000c9]
in /usr/src/packages/BUILD/monodevelop-2.8.1/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs:375 
 at MonoDevelop.VersionControl.UpdateCommand+UpdateWorker.Run ()
[0x00017]
in /usr/src/packages/BUILD/monodevelop-2.8.1/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/UpdateCommand.cs:43 
 at MonoDevelop.VersionControl.Task.BackgroundWorker (System.Object
state) [0x00000]
in /usr/src/packages/BUILD/monodevelop-2.8.1/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Task.cs:49 


That was on MD 2.8.1 on Windows, and I've since confirmed it on MD 2.8.5 on OpenSUSE 11.4. Another Pinta contributor has confirmed it on Mac OS.
Comment 1 Alan McGovern 2012-02-21 09:46:14 UTC
This is caused by monodevelop creating a local branch based on the current branch rather than a local branch based on the remote branch you've chosen. Looking into fixing this now.
Comment 2 Alan McGovern 2012-02-21 10:44:50 UTC
If the user creates a new local branch with no remote branch specified, we generate the local branch using the HEAD commit of the current branch. If they specify a remote branch, we use the HEAD commit of that branch to generate the new local branch. This fixes your issue and is consistent with what commandline git does.