Bug 7839 - Git config crash IDE
Summary: Git config crash IDE
Status: RESOLVED INVALID
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Version Control ()
Version: 3.0.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Marius Ungureanu
URL:
Depends on:
Blocks:
 
Reported: 2012-10-15 05:46 UTC by xarkam
Modified: 2013-07-30 07:08 UTC (History)
5 users (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 INVALID

Description xarkam 2012-10-15 05:46:21 UTC
The ide crash on build a project or simply clicking on version control menu if the current solution is a git version control.

System.ArgumentException: Repository config file C:\Developpements\dev-test - Copy\.git\config invalid Cannot read file C:\Developpements\dev-test - Copy\.git\config
   à NGit.BaseRepositoryBuilder`2.LoadConfig()
   à NGit.BaseRepositoryBuilder`2.GetConfig()
   à NGit.BaseRepositoryBuilder`2.GuessWorkTreeOrFail()
   à NGit.BaseRepositoryBuilder`2.SetupWorkTree()
   à NGit.BaseRepositoryBuilder`2.Setup()
   à NGit.Storage.File.FileRepository..ctor(FilePath gitDir)
   à NGit.Storage.File.FileRepository..ctor(String gitDir)
   à MonoDevelop.VersionControl.Git.LocalGitRepository..ctor(String path)
   à MonoDevelop.VersionControl.Git.GitRepository..ctor(FilePath path, String url)
   à MonoDevelop.VersionControl.Git.GitVersionControl.GetRepositoryReference(FilePath path, String id)
   à MonoDevelop.VersionControl.Git.GitVersionControl.GetRepositoryReference(FilePath path, String id)
   à MonoDevelop.VersionControl.Git.GitVersionControl.GetRepositoryReference(FilePath path, String id)
   à MonoDevelop.VersionControl.VersionControlService.GetRepositoryReference(String path, String id)
   à MonoDevelop.VersionControl.VersionControlService.GetRepository(IWorkspaceObject entry)
   à MonoDevelop.VersionControl.SolutionVersionControlCommandHalder.GetItems()
   à MonoDevelop.VersionControl.SolutionVersionControlCommandHalder.Update(CommandInfo info)
   à MonoDevelop.Components.Commands.CommandHandler.InternalUpdate(CommandInfo info)
   à MonoDevelop.Components.Commands.CommandManager.DefaultUpdateCommandInfo(ActionCommand cmd, CommandInfo info)
   à MonoDevelop.Components.Commands.CommandManager.GetCommandInfo(Object commandId, CommandTargetRoute targetRoute)

The git onfig file content:

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
	hideDotFiles = dotGitOnly
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@babi.homelinux.net:dev-test
	puttykeyfile = C:/Users/Benjamin/.ssh/git_benjamin.xarkam@osames.org.ppk
[branch "master"]
	remote = origin
	merge = refs/heads/master
---------------------------------------------------------------------------------------
Monodevelop used: 3.0.4.7
git used: msysgit 1.7.11
git extention used: 2.41 (.NET4)
Comment 1 Marco.Leise 2013-02-24 03:41:59 UTC
I'm getting the exact same error now that I switched to 4.0 on Gentoo Linux. To make sure it is not an file corruption, I tried it with a project that I just ran "git init" in for the fist time: same error. It used to work with 3.0.6 for me though, so it is probably a different error source. But right now there is nothing to at hand to discriminate between these two crashes besides OS and MD version. 
---------------------
MonoDevelop : 4.0 (built from source)
git         : 1.7.12.4
Comment 2 Marius Ungureanu 2013-07-01 06:49:10 UTC
What are the permissions for the .gitconfig file? MD might not have permissions to read it.
Comment 3 Marco.Leise 2013-07-01 07:01:05 UTC
I run MonoDevelop under my user account and I have read and write permissions to .gitignore. Same goes for .git/config, which is the file that cannot be read according to the OP. The contents for .git/config here are:

-------8<------
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = git@github.com:mleise/piped.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
------->8------

Line-break format is Unix and there is a line-break on the last line, indentation uses tabs. Everything about this file looks like a prime example of a well formatted text file.
Comment 4 Marius Ungureanu 2013-07-09 05:37:57 UTC
The only difference between my config and yours is that you use git@github.com, I use git://github.com.

Can you verify if changing the url type fixes it? Just out of curiosity.
Comment 5 Marco.Leise 2013-07-09 06:28:10 UTC
I just tried that and it doesn't change anything.
Comment 6 Marius Ungureanu 2013-07-12 11:43:57 UTC
Does adding lines like below help? This is the only difference I can find against my config file.

[user]
	name = blah
	email = blah@blah.com
Comment 7 Marco.Leise 2013-07-12 11:57:45 UTC
No, that didn't change anything either. I have set my user name globally, btw.
What else can be different?

I'm using:
Gentoo Linux on amd64, kernel 3.8.13
mono 3.0.12
MonoDevelop 4.1.4
Git 1.8.1.5 (with the following disabled: cgi cvs doc emacs gtk highlight iconv perl ppcsha1 python subversion test threads tk webdav xinetd)

I'll try reinstalling Git with every single option enabled. Or do you use some home brewed library to read the git config ?
Comment 8 Marco.Leise 2013-07-12 12:01:15 UTC
Only 80 new packages to be installed, hey ! :D
But most of them are small Perl modules.
Comment 9 Marco.Leise 2013-07-12 12:36:48 UTC
Enabling all the options to Git didn't help either.
Comment 10 Marius Ungureanu 2013-07-12 14:05:36 UTC
It seems that it sees that config file as invalid. And I can't find anything that helps. Do you have MD built from source? Maybe running in debug can grab more information on this. "Cannot read file" is not giving any lead.
Comment 11 Marco.Leise 2013-07-12 15:36:33 UTC
The exception log actually says this that this System.ArgumentException has been thrown:
  Repository config file <…>/.git/config invalid
  Cannot read file <…>/.git/config

That happened in the method "LoadConfig()" of "NGit.BaseRepositoryBuilder" which got instantiated with "NGit.Storage.File.FileRepositoryBuilder" and "NGit.Storage.File.FileRepository", which leads us here:
https://github.com/mono/ngit/blob/master/NGit/NGit/BaseRepositoryBuilder.cs#L904

There only ConfigInvalidException is catched, which in turn is only thrown in FileBasedConfig.Load(), if the file is not "properly formatted". This is what we already assumed and which looks like a false alarm.
I'll try an empty config file next.
Comment 12 Marco.Leise 2013-07-12 16:00:10 UTC
My MonoDevelop build is from http://mono-d.alexanderbothe.com/. So I neither built from source or used an official package.

The empty file still produces the same error. Which puzzles me, since from a glimpse at the current NGit source code it looks like it should just accept this. Then again I don't know C# much.
Comment 13 Marius Ungureanu 2013-07-12 16:26:49 UTC
I don't know what could be wrong. It puzzles me. I'll try to get the package and run it to see if it is caused by it.
Comment 14 Marius Ungureanu 2013-07-15 08:48:21 UTC
Can you tell me what type of file the config file is?

i.e. file .git/config
Comment 15 Marius Ungureanu 2013-07-15 08:50:54 UTC
From what I see on the web, NGit removed support for symlink config files. =D
Comment 16 Marius Ungureanu 2013-07-15 08:52:19 UTC
https://bugs.eclipse.org/bugs/show_bug.cgi?id=354367
Comment 17 Marco.Leise 2013-07-15 21:18:13 UTC
That prints: .git/config: ASCII text
The file is not a symlink.
Comment 18 Marius Ungureanu 2013-07-22 10:30:53 UTC
It seems that the code ignored its inner exception and we couldn't find out more.

A patch will be applied to sharpen and an update to NGit in MD as well. I'd like you to try it out when it happens. I'll also post another comment when it goes live.
Comment 19 Marius Ungureanu 2013-07-22 10:47:13 UTC
Ah, this won't be applied, since I can't do it from Sharpen.

Can I ask you to do a manual change in NGit and compile and see what the stacktrace is? The process of updating NGit is different from usual projects.

BaseRepositoryBuilder.cs line 905: change err.Message to err.

We should get a full stacktrace and find out what happens.

Thanks alot!
Comment 20 Marco.Leise 2013-07-22 12:14:55 UTC
I don't know what the work flow is with C# and Linux, but I can try when I get to it. I assume there is some kind of Makefile for NGit and I can search for the resulting binary name in MonoDevelop's directory in order to replace it?
Comment 21 Marius Ungureanu 2013-07-22 12:19:31 UTC
You just modify the file and run "make && make run" in root of the repo checkout and it will also build NGit. (don't forget ./configure)
Comment 22 Marco.Leise 2013-07-28 22:09:42 UTC
I have to tell you something horrible. I had --optimize=unsafe set in MONO_ENV_OPTIONS, which was the cause for the NGit crashes. It works for me now.

The stack with your change to BaseRepositoryBuilder.cs was:
System.ArgumentException: Repository config file .git/config invalid NGit.Errors.ConfigInvalidException: Cannot read file .git/config ---> NGit.Errors.ConfigInvalidException: Bad entry name: 
  at NGit.Config.ReadKeyName (NGit.StringReader in) [0x0012e] in monodevelop/main/external/ngit/NGit/NGit/Config.cs:1294 
  at NGit.Config.FromText (System.String text) [0x0019f] in monodevelop/main/external/ngit/NGit/NGit/Config.cs:1140 
  at NGit.Storage.File.FileBasedConfig.Load () [0x000c6] in monodevelop/main/external/ngit/NGit/NGit.Storage.File/FileBasedConfig.cs:152 
  --- End of inner exception stack trace ---
  at NGit.Storage.File.FileBasedConfig.Load () [0x00152] in monodevelop/main/external/ngit/NGit/NGit.Storage.File/FileBasedConfig.cs:171 
  at NGit.BaseRepositoryBuilder`2[NGit.Storage.File.FileRepositoryBuilder,NGit.Storage.File.FileRepository].LoadConfig () [0x00033] in monodevelop/main/external/ngit/NGit/NGit/BaseRepositoryBuilder.cs:900 
  at NGit.BaseRepositoryBuilder`2[NGit.Storage.File.FileRepositoryBuilder,NGit.Storage.File.FileRepository].LoadConfig () [0x00062] in monodevelop/main/external/ngit/NGit/NGit/BaseRepositoryBuilder.cs:904 
  at NGit.BaseRepositoryBuilder`2[NGit.Storage.File.FileRepositoryBuilder,NGit.Storage.File.FileRepository].GetConfig () [0x0000f] in monodevelop/main/external/ngit/NGit/NGit/BaseRepositoryBuilder.cs:872 
  at NGit.BaseRepositoryBuilder`2[NGit.Storage.File.FileRepositoryBuilder,NGit.Storage.File.FileRepository].GuessWorkTreeOrFail () [0x00002] in monodevelop/main/external/ngit/NGit/NGit/BaseRepositoryBuilder.cs:918 
  at NGit.BaseRepositoryBuilder`2[NGit.Storage.File.FileRepositoryBuilder,NGit.Storage.File.FileRepository].SetupWorkTree () [0x00033] in monodevelop/main/external/ngit/NGit/NGit/BaseRepositoryBuilder.cs:833 
  at NGit.BaseRepositoryBuilder`2[NGit.Storage.File.FileRepositoryBuilder,NGit.Storage.File.FileRepository].Setup () [0x0000e] in monodevelop/main/external/ngit/NGit/NGit/BaseRepositoryBuilder.cs:745 
  at NGit.Storage.File.FileRepository..ctor (Sharpen.FilePath gitDir) [0x0000c] in monodevelop/main/external/ngit/NGit/NGit.Storage.File/FileRepository.cs:115 
  at NGit.Storage.File.FileRepository..ctor (System.String gitDir) [0x00002] in monodevelop/main/external/ngit/NGit/NGit.Storage.File/FileRepository.cs:130 
  at MonoDevelop.VersionControl.Git.LocalGitRepository..ctor (System.String path) [0x00000] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs:1705 
  at MonoDevelop.VersionControl.Git.GitRepository..ctor (FilePath path, System.String url) [0x00040] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs:73 
  at MonoDevelop.VersionControl.Git.GitVersionControl.GetRepositoryReference (FilePath path, System.String id) [0x00095] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitVersionControl.cs:61 
  at MonoDevelop.VersionControl.Git.GitVersionControl.GetRepositoryReference (FilePath path, System.String id) [0x000b1] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitVersionControl.cs:65 
  at MonoDevelop.VersionControl.VersionControlService.GetRepositoryReference (System.String path, System.String id) [0x00022] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs:205 
  at MonoDevelop.VersionControl.VersionControlService.GetRepository (IWorkspaceObject entry) [0x0003f] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs:188 
  at MonoDevelop.VersionControl.FileVersionControlCommandHandler.GetItem () [0x0004a] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs:98 
  at MonoDevelop.VersionControl.FileVersionControlCommandHandler.GetItems () [0x00008] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs:81 
  at MonoDevelop.VersionControl.FileVersionControlCommandHandler.Update (MonoDevelop.Components.Commands.CommandInfo info) [0x00002] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs:113 
  at MonoDevelop.VersionControl.RevertCommandHandler.Update (MonoDevelop.Components.Commands.CommandInfo info) [0x00003] in monodevelop/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/Commands.cs:184 
  at MonoDevelop.Components.Commands.CommandHandler.InternalUpdate (MonoDevelop.Components.Commands.CommandInfo info) [0x00003] in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandHandler.cs:47 
  at MonoDevelop.Components.Commands.CommandManager.DefaultUpdateCommandInfo (MonoDevelop.Components.Commands.ActionCommand cmd, MonoDevelop.Components.Commands.CommandInfo info) [0x00083] in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1272 
  at MonoDevelop.Components.Commands.CommandManager.GetCommandInfo (System.Object commandId, MonoDevelop.Components.Commands.CommandTargetRoute targetRoute) [0x001c5] in monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1237
Comment 23 Marius Ungureanu 2013-07-29 00:13:58 UTC
We now have a cause. Thanks! :D
Comment 24 Marius Ungureanu 2013-07-29 09:49:18 UTC
Apparently, we don't support --unsafe. Marking as WONTFIX.
Comment 25 Rodrigo Kumpera 2013-07-29 09:49:57 UTC
Don't use -O=unsafe. XS is not safe enough for this kind of thing.

Tons of stuff that violates the requirements of -O=unsafe happens there.

Just don't use outside of controlled environments.
Comment 26 Alan McGovern 2013-07-29 10:22:40 UTC
Just to add: You should never ever use --optimize=unsafe. It turns off a bunch of features in the runtime which prevent memory corruption. If you enable this feature, you will experience strange and unusual crashes unless the application you are running has specifically been written to work in this mode. No general purpose library or application is.
Comment 27 Marco.Leise 2013-07-29 10:48:00 UTC
Yes, it was a stupid attempt at making a plugin run faster. I just added all the optimization flags and removed them one by one until the IDE would start. Then I put it in /etc/env.d and forgot about it. Thanks for the additional information though.
By the way I was expecting an RESOLVED INVALID.