Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Exception opening an existing repository #6093

Closed
fabvit opened this issue Jan 11, 2019 · 54 comments
Closed

System.Exception opening an existing repository #6093

fabvit opened this issue Jan 11, 2019 · 54 comments
Assignees
Labels
status: workaround available type: bug 🐛 up-for-grabs Easy tasks for those looking to get involved. Refer to https://up-for-grabs.net/
Milestone

Comments

@fabvit
Copy link

fabvit commented Jan 11, 2019

Current behaviour

  1. Open one of my local repositories
    after the repository is opened I got a System exception:
Unable to parse git command output.

Target System: System.Collections.Generic.IReadOnlyList`1[GitCommands.Remote] <GetRemotes>g__ParseRemotes|154_0(System.Collections.Generic.IEnumerable`1[System.String]) @ GitCommands.GitModule

Application: GitExtensions.exe [3.00.00.4433]

NBug: 3.00.rc2

CLR: 4.0.30319.42000

Please note that thes exception happens only when the left panel (the one enumerating branches and remotes) is visible.
If I hide the the left panel, no exception arises.

Expected behaviour

No exceptions opening a repo.

Steps to reproduce

See Current behaviour section above

Screenshots

Did this work in previous version of GitExtensions

Yes it works fine in GitExtensions-2.51.05

Environment

  • GitExtensions version: GitExtensions-3.00.00.4433

  • GIT version: $ git --version
    git version 2.20.1.windows.1

  • OS version: Windows 7 Pro 64 bit

  • .NET version: 4.0.30319.42000

Diagnostics

@vbjay
Copy link
Contributor

vbjay commented Jan 11, 2019 via email

@gerhardol
Copy link
Member

gerhardol commented Jan 11, 2019

Please include the complete stacktrace from NBug.
If you dismiss the dialog, can you continue?
Can you share the repo where this occurred if the stacktrace is not obvious?

I believe @vbjay reacted on that NBug said 3.00.rc2. That may be incorrectly set there if so, for someone to follow up.

@vbjay
Copy link
Contributor

vbjay commented Jan 11, 2019

Oh right. That issue has been fixed.

@fabvit
Copy link
Author

fabvit commented Jan 11, 2019

@gerhardol and @vbjay yes I am on the very last version (https://github.com/gitextensions/gitextensions/releases/latest), namely Version 3.00.00 released on Dec 7, 2018.

@vbjay at this point I confused: what issue was been fixed?

    1. the wrong NBug: 3.00.rc2 text

OR

    2. my issue of System.Exception when opening an existing repository

Yes I can continue after dismissing the dialog and hiding the left panel.

Unfortunately I cannot share the repo.

@vbjay
Copy link
Contributor

vbjay commented Jan 11, 2019

Yes. the wrong NBug: 3.00.rc2 text

@gerhardol
Copy link
Member

The complete stacktrace is needed

I am not aware that this is reported before (but there are related corrections fixed in the upcoming 3.0.1
The complete stacktrace is needed

How many remotes do you have?
What is seen in the command log? (F12)

@vbjay
Copy link
Contributor

vbjay commented Jan 11, 2019

Part of it was you didn't use help about to get environment info so the rc2 jumped out at me.
image

@amaiorano
Copy link
Contributor

Looks like it must be failing in GitModule.GetRemotes here:

                        if (!fetchMatch.Success || !pushMatch.Success || fetchMatch.Groups["direction"].Value != "fetch" || pushMatch.Groups["direction"].Value != "push")
                        {
                            throw new Exception("Unable to parse git command output.");
                        }

This code expects to match this regex on the result of 'git remote -v':

private static readonly Regex _remoteVerboseLineRegex = new Regex(@"^(?<name>[^	]+)\t(?<url>.+?) \((?<direction>fetch|push)\)$", RegexOptions.Compiled);

@fabvit could you also share the result of running git remote -v in bash (Ctrl+G from your remote)?

@fabvit
Copy link
Author

fabvit commented Jan 13, 2019

@amaiorano , thank to your hint I found the cause of my issue.:

$ git remote -v
all     git@gitlab.com:tiger/my_project.git (fetch)
all     git@gitlab.com:tiger/my_project.git (push)
all     ssh://git@bitbucket.org/tiger/my_project.git (push)
gitlab  git@gitlab.com:tiger/my_project.git (fetch)
gitlab  git@gitlab.com:tiger/my_project.git (push)
origin  ssh://git@bitbucket.org/tiger/my_project.git (fetch)
origin  ssh://git@bitbucket.org/tiger/my_project.git (push)

I then removed the [remote "all"] section, and magically the exception disappeared. So I turned on left panel, done a refresh and the exception neve happened again.

P.S. The [remote "gitlab"] was put in the config as a way to perform a single command push instead of three separate pushes to:

git@gitlab.com
git@gitlab.com
git@bitbucket.org

@fabvit fabvit closed this as completed Jan 13, 2019
@fabvit
Copy link
Author

fabvit commented Jan 13, 2019

@gerhardol finnally I figured how to obtain the stack trace:

   at GitCommands.GitModule.<GetRemotes>g__ParseRemotes|154_0(IEnumerable`1 lines)
   at GitCommands.GitModule.GetRemotes()
   at GitUI.BranchTreePanel.RepoObjectsTree.RemoteBranchTree.<LoadNodesAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitUI.BranchTreePanel.RepoObjectsTree.Tree.<ReloadAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitUI.BranchTreePanel.RepoObjectsTree.<ReloadAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at GitUI.BranchTreePanel.RepoObjectsTree.<ReloadAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GitUI.ThreadHelper.<>c__DisplayClass13_0.<<FileAndForget>b__0>d.MoveNext()

@RussKie
Copy link
Member

RussKie commented Jan 13, 2019 via email

@amaiorano
Copy link
Contributor

I'm not sure I understood the problem, exactly. Was it that there were two remotes pointing to the same thing?

@gerhardol
Copy link
Member

Duplicate of #5943 - closed though

Suggest this is handled as a bug:

  • Use first remote if more than one
  • Report to user once per repo (need to be stored somehow). It is better to have a popup when using than a crash though...

Enhancement: Handle multiple (auto name, activate/deactivate must be handled)

@RussKie RussKie reopened this Jan 15, 2019
@RussKie RussKie added type: bug 🐛 up-for-grabs Easy tasks for those looking to get involved. Refer to https://up-for-grabs.net/ status: workaround available labels Jan 15, 2019
@RussKie
Copy link
Member

RussKie commented Jan 15, 2019

Reopening since this would be good to fix

@SailorMax
Copy link

SailorMax commented Feb 23, 2019

Crash on startup.
GitExtensions.exe [3.1.0.5342]

System.Exception: Remote URLs should appear in pairs.
Target Site: System.Collections.Generic.IReadOnlyList`1[GitCommands.Remote] <GetRemotes>g__ParseRemotes|153_0(System.Collections.Generic.IEnumerable`1[System.String]) @ GitCommands.GitModule
CLR: 4.0.30319.42000
HResult: -2146233088

@escherstair
Copy link

escherstair commented Mar 8, 2019

I see this error with the following environment

  • Git Extensions 3.0.2.5232
  • Build 23b6f51
  • Git 2.21.0.windows.1
  • Microsoft Windows NT 6.1.7601 Service Pack 1
  • .NET Framework 4.7.3130.0
  • DPI 96dpi (no scaling)

This happens when my repo has submodules (which have remotes) but it doesn't have a remote itself.
After I add a remote for the main repo (through git command line) everything is ok.

@vbjay
Copy link
Contributor

vbjay commented Mar 8, 2019 via email

@escherstair
Copy link

Is this a question?
Which git config?
Either the one of the main repo (but it doesn't have remote when the issue happens), or those of submodules?

@vbjay
Copy link
Contributor

vbjay commented Mar 8, 2019 via email

@escherstair
Copy link

In the meanwhile I fixed the error (adding the remote).
I'll do what you suggest the next time I create a new repo with submodules

@escherstair
Copy link

git remote -v

origin

@fsfod
Copy link

fsfod commented Mar 21, 2019

I don't know how much helps but i bisected this issue for for my case at least to this commit c9e47e4 from pull request #5669. I have the same problem as closed as duplicate issue and i have "Open with last working directory" off.

Also this is the call stack that starting the task thats calling GitModule.GetRemotes

GitUI.dll!GitUI.BranchTreePanel.RepoObjectsTree.Tree.ReloadNodes({Method = {System.Reflection.RuntimeMethodInfo}}) Line 158	C#
GitUI.dll!GitUI.BranchTreePanel.RepoObjectsTree.BranchTree.RefreshTree() Line 203	C#
GitUI.dll!GitUI.BranchTreePanel.RepoObjectsTree.AddTree({GitUI.BranchTreePanel.RepoObjectsTree.BranchTree}) Line 254	C#
GitUI.dll!GitUI.BranchTreePanel.RepoObjectsTree.OnUICommandsSourceSet({GitUI.CommandsDialogs.FormBrowse}) Line 211	C#
GitUI.dll!GitUI.GitModuleControl.UICommandsSource.set({GitUI.CommandsDialogs.FormBrowse}) Line 83	C#
GitUI.dll!GitUI.GitModuleControl.UICommandsSource.get() Line 68	C#
GitUI.dll!GitUI.BranchTreePanel.RepoObjectsTree.Initialize({GitCommands.Git.AheadBehindDataProvider}, {GitUI.FilterBranchHelper}) Line 189	C#
GitUI.dll!GitUI.CommandsDialogs.FormBrowse.FormBrowse({GitUI.GitUICommands}, "", null) Line 185	C#
GitUI.dll!GitUI.GitUICommands.StartBrowseDialog(null, "", null) Line 1065	C#
GitExtensions.exe!GitExtensions.Program.RunApplication() Line 145	C#
GitExtensions.exe!GitExtensions.Program.Main() Line 68	C#

@amaiorano
Copy link
Contributor

@fsfod Thank you for that, it's actually very helpful. I was able to reproduce this quite easily by just setting the working directory to a non-git directory, and launching our latest build in Debug.

The problem is that RepoObjectsTree.RemoteBranchTree.LoadNodesAsync is trying to read remotes from a GitModule that is effectively invalid -- it isn't initialized with an actual module. It fails when calling Module.GetRemotes(), which attempts to parse the output of "git remote -v", which in this case returns "fatal: not a git repository (or any of the parent directories): .git" as @mstv pointed out above.

There are a couple of possible fixes:

  1. Make Module.GetRemotes robust against unexpected output, and have it simply return an empty list.
  2. Have the left panel root tree nodes check if Module is "valid" before proceeding to try and populate themselves.

Personally, I would prefer the first option. I'll take a stab at that.

@amaiorano
Copy link
Contributor

Please check out the fix in PR: #6390

@fsfod
Copy link

fsfod commented Mar 21, 2019

It fixed the issue but it looks like opening and closing the settings dialogue when no repo is open at the dashboard has the same issue of trying access non existent repository.

@amaiorano
Copy link
Contributor

It fixed the issue but it looks like opening and closing the settings dialogue when no repo is open at the dashboard has the same issue of trying access non existent repository.

Hmm, I'll take a look. In fact, my change is making one of our tests fail, and I'm still considering the right way to approach this.

@amaiorano
Copy link
Contributor

I pushed more fixes. It's working now even with open then close of Settings on a non-repo.

@ghost ghost removed the status: ready label Mar 24, 2019
@RussKie RussKie reopened this Mar 24, 2019
@mstv
Copy link
Member

mstv commented Apr 29, 2019

@RussKie, why did you reopen this issue a month ago?

@RussKie
Copy link
Member

RussKie commented Apr 29, 2019

I can't recall.

@RussKie RussKie closed this as completed Apr 29, 2019
@RussKie RussKie added this to the 3.1.0 milestone Apr 29, 2019
@RussKie
Copy link
Member

RussKie commented May 14, 2019

This is still not fixed

@RussKie RussKie reopened this May 14, 2019
@RussKie
Copy link
Member

RussKie commented May 14, 2019

#6562 #6563

@RussKie RussKie modified the milestones: 3.1.0, 3.1.1 May 14, 2019
@ojchase
Copy link

ojchase commented May 15, 2019

Yep, not fixed. I'm now hitting it just by launching Git Extensions after upgrading to the latest version. All was fine before upgrading. Now launch the application and identical to 6562/6563.

@RussKie
Copy link
Member

RussKie commented May 15, 2019 via email

@ojchase
Copy link

ojchase commented May 15, 2019

Not a lot of point as I'm not in a repository. The only difference between me and ideaalab on 3/18 is that I'm not on the portable version.

@jacekprofisoft
Copy link

jacekprofisoft commented May 20, 2019

I can confirm that bug exists in 3.1. Prior to that hiding left panel prevents from throwing exception, but in 3.1 this workaround don't work and exception is raised every time I open affected repository even if left panel is hidden.

Current behaviour

Exception is thrown when opening repository which has remote repository with more than one push url.

Expected behaviour

Exception should not be thrown.

Steps to reproduce

  1. Create new (personal) repository and do initial commit. Let's call it 'Test'.
  2. Clone 'Test' repo, assume it is 'TestA'
  3. Once again clone 'Test', assume it is 'TestB'
  4. Open 'TestA' in Git Extensions and go to Git Console
  5. Make sure 'Test' is set as 'origin' remote repository by doing: git remote -v
  6. Add another push 'origin' url to 'TestB' by executing: git remote set-url --add origin /path/to/TestB
  7. Verify that you now have two 'origin' push urls by doing: git remote -v
  8. Reload 'TestA' in Git Extensions - exception should be thrown
  9. Dissmising exception dialog closes GE

Error Details

System.Exception: Remote URLs should appear in pairs.
   w GitCommands.GitModule.<GetRemotesAsync>g__ParseRemotes|155_0(IEnumerable`1 lines)
   w GitCommands.GitModule.<GetRemotesAsync>d__155.MoveNext()
--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---
   w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   w GitUI.BranchTreePanel.RepoObjectsTree.RemoteBranchTree.<LoadNodesAsync>d__4.MoveNext()
--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---
   w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   w GitUI.BranchTreePanel.RepoObjectsTree.Tree.<ReloadNodesAsync>d__27.MoveNext()
--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---
   w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   w GitUI.BranchTreePanel.RepoObjectsTree.Tree.<<UICommands_PostRepositoryChanged>b__6_0>d.MoveNext()
--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---
   w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   w GitUI.ThreadHelper.<>c__DisplayClass13_0.<<FileAndForget>b__0>d.MoveNext()

Environment

  • Git Extensions 3.1.0.5877
  • Build bb1687f
  • Git 2.20.1.windows.1
  • Microsoft Windows NT 10.0.17763.0
  • .NET Framework 4.7.3416.0
  • DPI 96dpi (no scaling)

@RussKie
Copy link
Member

RussKie commented May 20, 2019

Fixed in #6580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: workaround available type: bug 🐛 up-for-grabs Easy tasks for those looking to get involved. Refer to https://up-for-grabs.net/
Projects
None yet
Development

No branches or pull requests