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

GitVersion.Portable 3.1.2: NullReferenceException #674

Closed
asbjornu opened this issue Oct 7, 2015 · 7 comments
Closed

GitVersion.Portable 3.1.2: NullReferenceException #674

asbjornu opened this issue Oct 7, 2015 · 7 comments

Comments

@asbjornu
Copy link
Member

asbjornu commented Oct 7, 2015

When running gitversion.exe in a repository, it crashes with the following output:

INFO [10/07/15 15:40:31:88] Working directory: C:\Redacted
INFO [10/07/15 15:40:31:91] Project root is: C:\Redacted
INFO [10/07/15 15:40:31:96] Using latest commit on specified branch
INFO [10/07/15 15:40:31:96] Begin: Attempting to inherit branch configuration from parent branch
  INFO [10/07/15 15:40:31:98] Begin: Finding branch source
  INFO [10/07/15 15:40:32:02] End: Finding branch source (Took: 40.94ms)
INFO [10/07/15 15:40:32:02] End: Attempting to inherit branch configuration from parent branch (Took: 56.89ms)
ERROR [10/07/15 15:40:32:02] An unexpected error occurred:
System.NullReferenceException: Object reference not set to an instance of an object.
   at GitVersion.LibGitExtensions.<>c__DisplayClass3_0.<FindCommitBranchWasBranchedFrom>b__1(Branchb)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at GitVersion.LibGitExtensions.FindCommitBranchWasBranchedFrom(Branch branch, IRepository repository, Branch[] excludedBranches)
   at GitVersion.BranchConfigurationCalculator.InheritBranchConfiguration(Boolean onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair`2 keyValuePair, BranchConfig branchConfiguration, Config config, IList`1 excludedInheritBranches)
   at GitVersion.BranchConfigurationCalculator.GetBranchConfiguration(Commit currentCommit, IRepository repository, Boolean onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList`1 excludedInheritBranches)
   at GitVersion.GitVersionContext.CalculateEffectiveConfiguration()
   at GitVersion.GitVersionContext..ctor(IRepository repository, Branch currentBranch, Config configuration, Boolean onlyEvaluateTrackedBranches, String commitId)
   at GitVersion.GitVersionContext..ctor(IRepository repository, Config configuration, Boolean isForTrackingBranchOnly, String commitId)
   at GitVersion.ExecuteCore.ExecuteGitVersion(IFileSystem fileSystem, String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)
   at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
   at GitVersion.Program.VerifyArgumentsAndRun()
INFO [10/07/15 15:40:32:02]
INFO [10/07/15 15:40:32:02] Here is the current git graph (please include in issue):
INFO [10/07/15 15:40:32:02] Showing max of 100 commits
INFO [10/07/15 15:40:32:12] * a461a04 51 minutes ago  (HEAD -> feature/gitversion)
* 37a15d3 72 minutes ago
* aebf2e0 85 minutes ago  (origin/develop, develop)
* d6a4946 85 minutes ago
* 90e8ac7 2 hours ago
* 3213092 2 hours ago  (tag: 4.8.2, origin/master)
* f4f7224 3 hours ago
* 9dcd702 2 days ago
* c40e2db 2 days ago  (tag: 4.8.1, master)
* cd90e31 2 days ago
* 69faea4 2 days ago
* 14b5ac2 2 days ago
* c0c5d38 2 days ago  (tag: 4.7.4)
* d3ea3f7 2 days ago
* 24f0e0c 5 days ago
* a255288 5 days ago
* 02b85c7 5 days ago
* 744ff9c 5 days ago
* 297d0e3 5 days ago
* a1a54a1 5 days ago  (tag: 4.7.3)
* 0fe510d 5 days ago
* 0ab79c0 6 days ago
* 7615f34 6 days ago  (tag: 4.7.2)
* 3988f59 6 days ago
* 3b596fe 6 days ago
* 17e19d8 6 days ago
* 1e4afc7 7 days ago  (tag: 4.7.1)
* c38cb9a 7 days ago
* 024bd56 7 days ago
* 990b449 7 days ago
* 35ccbab 8 days ago
* 9c54837 13 days ago
* 7bf8cde 13 days ago  (tag: 4.6.10)
* 0325d78 13 days ago
* 7c2423c 13 days ago
*   f551cf4 13 days ago
|\
| *   dfb354b 3 weeks ago  (tag: 4.6.9)
| |\
| * | 008e3d7 3 weeks ago
| * | e8b5a28 3 weeks ago
| * | 154bb10 3 weeks ago
* | | ed25239 2 weeks ago
* | | 695b618 2 weeks ago
* | | 2be6cc3 2 weeks ago
* | | 47d877d 2 weeks ago
* | | 54fcb32 2 weeks ago
* | | 0d0d60e 2 weeks ago
* | | 87d7337 3 weeks ago
* | | 9085d68 3 weeks ago
* | | 4c2e352 3 weeks ago
* | | a98d758 3 weeks ago
* | | b4ee9b8 3 weeks ago
* | | efbb84c 3 weeks ago
| |/
|/|
* | 0d106a8 3 weeks ago
* | 914df4e 3 weeks ago
* | 02ec44d 3 weeks ago
* | 62b1424 3 weeks ago
* | 4475a4b 3 weeks ago
* | 19ebc8e 3 weeks ago
|/
* 2520efd 3 weeks ago  (tag: 4.6.8)
* 1d6f779 3 weeks ago
* ea288fe 3 weeks ago
* e01583c 3 weeks ago
* f2cc771 3 weeks ago
* 4f6d7da 3 weeks ago
* 08288c1 4 weeks ago
* 31f9878 4 weeks ago  (tag: 4.6.7)
* 5281588 4 weeks ago
* 0084b80 4 weeks ago
* a27a9d7 4 weeks ago
* 1b92c76 4 weeks ago
* 7d3ebd4 5 weeks ago
* 81f09ad 5 weeks ago  (tag: 4.6.6)
* 829998c 5 weeks ago
* 4919037 5 weeks ago
* 9e26f24 5 weeks ago  (tag: 4.6.5)
* b030318 5 weeks ago
* c02933a 5 weeks ago
* f532f3b 5 weeks ago  (tag: 4.6.4)
* f127142 5 weeks ago
* eaf6473 5 weeks ago
* bf401d4 5 weeks ago  (tag: 4.6.3)
* 18cd554 5 weeks ago
* 5e0b34e 5 weeks ago
* 6ebb577 5 weeks ago  (tag: 4.6.2)
* 8563acf 5 weeks ago
* d47642e 5 weeks ago
* 0c02169 5 weeks ago
* 014c539 5 weeks ago
* a98b610 5 weeks ago
* b20e0ff 5 weeks ago
* b5012f4 5 weeks ago
* d23a18d 5 weeks ago
* 94a9d49 5 weeks ago
* 61714e8 5 weeks ago
* 5dd47b2 6 weeks ago
* 25d1e91 6 weeks ago
* 463c885 6 weeks ago  (tag: 4.6.1)
* 5680a8a 6 weeks ago
* 06e3fa4 6 weeks ago
* 0764c21 6 weeks ago

What may be causing this? This is a large and old repository and I doubt I'll be able to reproduce a simple test case. GitVersion has never been run in this project before; I'm planning on adding GitVersionTask to it, which is why I wanted to see how gitversion.exe was handling the repository first.

@orjan
Copy link
Contributor

orjan commented Oct 7, 2015

Do you mind running gv in debug mode and provide a stacktrace with line numbers?

/Örjan

On 07 Oct 2015, at 15:46, Asbjørn Ulsberg [email protected] wrote:

When running gitversion.exe in a repository, it crashes with the following output:

INFO [10/07/15 15:40:31:88] Working directory: C:\Redacted
INFO [10/07/15 15:40:31:91] Project root is: C:\Redacted
INFO [10/07/15 15:40:31:96] Using latest commit on specified branch
INFO [10/07/15 15:40:31:96] Begin: Attempting to inherit branch configuration from parent branch
INFO [10/07/15 15:40:31:98] Begin: Finding branch source
INFO [10/07/15 15:40:32:02] End: Finding branch source (Took: 40.94ms)
INFO [10/07/15 15:40:32:02] End: Attempting to inherit branch configuration from parent branch (Took
: 56.89ms)
ERROR [10/07/15 15:40:32:02] An unexpected error occurred:
System.NullReferenceException: Object reference not set to an instance of an object.
at GitVersion.LibGitExtensions.<>c__DisplayClass3_0.b__1(Branchb)
at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at GitVersion.LibGitExtensions.FindCommitBranchWasBranchedFrom(Branch branch, IRepository repository, Branch[] excludedBranches) at GitVersion.BranchConfigurationCalculator.InheritBranchConfiguration(Boolean onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair2 keyValuePair, BranchConfig branchConfiguration, Config config, IList1 excludedInheritBranches) at GitVersion.BranchConfigurationCalculator.GetBranchConfiguration(Commit currentCommit, IRepository repository, Boolean onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList1 excludedInheritBranches)
at GitVersion.GitVersionContext.CalculateEffectiveConfiguration()
at GitVersion.GitVersionContext..ctor(IRepository repository, Branch currentBranch, Config configuration, Boolean onlyEvaluateTrackedBranches, String commitId)
at GitVersion.GitVersionContext..ctor(IRepository repository, Config configuration, Boolean isForTrackingBranchOnly, String commitId)
at GitVersion.ExecuteCore.ExecuteGitVersion(IFileSystem fileSystem, String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)
at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()
INFO [10/07/15 15:40:32:02]
INFO [10/07/15 15:40:32:02] Here is the current git graph (please include in issue):
INFO [10/07/15 15:40:32:02] Showing max of 100 commits
INFO [10/07/15 15:40:32:12] * a461a04 51 minutes ago (HEAD -> feature/gitversion)

  • 37a15d3 72 minutes ago
  • aebf2e0 85 minutes ago (origin/develop, develop)
  • d6a4946 85 minutes ago
  • 90e8ac7 2 hours ago
  • 3213092 2 hours ago (tag: 4.8.2, origin/master)
  • f4f7224 3 hours ago
  • 9dcd702 2 days ago
  • c40e2db 2 days ago (tag: 4.8.1, master)
  • cd90e31 2 days ago
  • 69faea4 2 days ago
  • 14b5ac2 2 days ago
  • c0c5d38 2 days ago (tag: 4.7.4)
  • d3ea3f7 2 days ago
  • 24f0e0c 5 days ago
  • a255288 5 days ago
  • 02b85c7 5 days ago
  • 744ff9c 5 days ago
  • 297d0e3 5 days ago
  • a1a54a1 5 days ago (tag: 4.7.3)
  • 0fe510d 5 days ago
  • 0ab79c0 6 days ago
  • 7615f34 6 days ago (tag: 4.7.2)
  • 3988f59 6 days ago
  • 3b596fe 6 days ago
  • 17e19d8 6 days ago
  • 1e4afc7 7 days ago (tag: 4.7.1)
  • c38cb9a 7 days ago
  • 024bd56 7 days ago
  • 990b449 7 days ago
  • 35ccbab 8 days ago
  • 9c54837 13 days ago
  • 7bf8cde 13 days ago (tag: 4.6.10)
  • 0325d78 13 days ago
  • 7c2423c 13 days ago
  • f551cf4 13 days ago
    |
    | * dfb354b 3 weeks ago (tag: 4.6.9)
    | |
    | * | 008e3d7 3 weeks ago
    | * | e8b5a28 3 weeks ago
    | * | 154bb10 3 weeks ago
  • | | ed25239 2 weeks ago
  • | | 695b618 2 weeks ago
  • | | 2be6cc3 2 weeks ago
  • | | 47d877d 2 weeks ago
  • | | 54fcb32 2 weeks ago
  • | | 0d0d60e 2 weeks ago
  • | | 87d7337 3 weeks ago
  • | | 9085d68 3 weeks ago
  • | | 4c2e352 3 weeks ago
  • | | a98d758 3 weeks ago
  • | | b4ee9b8 3 weeks ago
  • | | efbb84c 3 weeks ago
    | |/
    |/|
  • | 0d106a8 3 weeks ago
  • | 914df4e 3 weeks ago
  • | 02ec44d 3 weeks ago
  • | 62b1424 3 weeks ago
  • | 4475a4b 3 weeks ago
  • | 19ebc8e 3 weeks ago
    |/
  • 2520efd 3 weeks ago (tag: 4.6.8)
  • 1d6f779 3 weeks ago
  • ea288fe 3 weeks ago
  • e01583c 3 weeks ago
  • f2cc771 3 weeks ago
  • 4f6d7da 3 weeks ago
  • 08288c1 4 weeks ago
  • 31f9878 4 weeks ago (tag: 4.6.7)
  • 5281588 4 weeks ago
  • 0084b80 4 weeks ago
  • a27a9d7 4 weeks ago
  • 1b92c76 4 weeks ago
  • 7d3ebd4 5 weeks ago
  • 81f09ad 5 weeks ago (tag: 4.6.6)
  • 829998c 5 weeks ago
  • 4919037 5 weeks ago
  • 9e26f24 5 weeks ago (tag: 4.6.5)
  • b030318 5 weeks ago
  • c02933a 5 weeks ago
  • f532f3b 5 weeks ago (tag: 4.6.4)
  • f127142 5 weeks ago
  • eaf6473 5 weeks ago
  • bf401d4 5 weeks ago (tag: 4.6.3)
  • 18cd554 5 weeks ago
  • 5e0b34e 5 weeks ago
  • 6ebb577 5 weeks ago (tag: 4.6.2)
  • 8563acf 5 weeks ago
  • d47642e 5 weeks ago
  • 0c02169 5 weeks ago
  • 014c539 5 weeks ago
  • a98b610 5 weeks ago
  • b20e0ff 5 weeks ago
  • b5012f4 5 weeks ago
  • d23a18d 5 weeks ago
  • 94a9d49 5 weeks ago
  • 61714e8 5 weeks ago
  • 5dd47b2 6 weeks ago
  • 25d1e91 6 weeks ago
  • 463c885 6 weeks ago (tag: 4.6.1)
  • 5680a8a 6 weeks ago
  • 06e3fa4 6 weeks ago
  • 0764c21 6 weeks ago
    What may be causing this? This is a large and old repository and I doubt I'll be able to reproduce a simple test case. GitVersion has never been run in this project before; I'm planning on adding GitVersionTask to it, which is why I wanted to see how gitversion.exe was handling the repository first.


Reply to this email directly or view it on GitHub.

@JakeGinnivan
Copy link
Contributor

If I had to guess there is a branch without a tip, which I have no idea how that would happen..

Here is the select statement the exception is happening in..

var mergeBases = otherBranches.Select(b =>
{
    var otherCommit = b.Tip;
    if (b.Tip.Parents.Contains(branch.Tip))
    {
        otherCommit = b.Tip.Parents.First();
    }
    var mergeBase = repository.Commits.FindMergeBase(otherCommit, branch.Tip);
    return mergeBase;
})

@nulltoken any idea where a nullreferenceexception could be coming from in here?

@JakeGinnivan
Copy link
Contributor

@asbjornu if you can debug into this and see what exactly is throwing that would be super handy

@nulltoken
Copy link
Contributor

If I had to guess there is a branch without a tip, which I have no idea how that would happen..

This would happen with an orphan branch (ie. When HEAD points to a refs/heads reference to be created).

@JakeGinnivan
Copy link
Contributor

In that case it should be an easy fix, we need to filter branches without Tips. @nulltoken do you add R# annotations to libgit2sharp, would be a good place for a [CanBeNull] attribute so r# warns.

@asbjornu
Copy link
Member Author

asbjornu commented Oct 8, 2015

Seems like this is a duplicate of #618, no?

@asbjornu
Copy link
Member Author

asbjornu commented Oct 8, 2015

@JakeGinnivan @nulltoken I've been able to get GitVersion.exe to throw more informative exceptions in #677, so please give it a review. As I mention there, the optimal solution would be to not throw exceptions at all, but just issue a warning and then continuing the algorithm unaffected. I'm just not sure if that's possible, so please provide some advice. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@asbjornu @nulltoken @orjan @JakeGinnivan @pascalberger and others