Skip to content

NullReferenceException in FindCommitBranchWasBranchedFrom #618

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

Closed
michaelnoonan opened this issue Sep 1, 2015 · 21 comments
Closed

NullReferenceException in FindCommitBranchWasBranchedFrom #618

michaelnoonan opened this issue Sep 1, 2015 · 21 comments

Comments

@michaelnoonan
Copy link
Contributor

Apologies for the terse Issue, I was out of time today and am hoping to reproduce the issue locally tomorrow.

What I've noticed is this NullReferenceException started after merging from master back into our release/3.1.0 branch. Now running gitversion.exe fails with the NRE, and GitVersionTask is doing the same thing in Visual Studio making it horribly slow.

Both GitVersion.Portable and GitVersionTask are 3.1.0.

I've worked around this temporarily by adding a Tag to force the SemVer. I haven't found another workaround that gets back to normal operation (without the Tag hack).

Full log file as requested...

2015-09-01 15:55:50     INFO [09/01/15 15:55:50:78] Working directory: c:\dev\OctopusDeploy\source
2015-09-01 15:55:50     INFO [09/01/15 15:55:50:81] Project root is: c:\dev\OctopusDeploy
2015-09-01 15:55:50     INFO [09/01/15 15:55:50:85] Using latest commit on specified branch
2015-09-01 15:55:51     INFO [09/01/15 15:55:51:06] Running against branch: release/3.1.0 (7025eb3f4a737e85403ce6d24bcfd3a08dd5d640)
2015-09-01 15:55:51     INFO [09/01/15 15:55:51:10] Begin: Calculating base versions
2015-09-01 15:55:51       INFO [09/01/15 15:55:51:47] Fallback base version: 0.1.0 with commit count source b69a057dd90cf0f567819efcf8b88e3806161d72
2015-09-01 15:55:53       INFO [09/01/15 15:55:53:94] Git tag '3.0.21': 3.0.21 with commit count source 3fcb35e57ea3fda043d433e4526ac2ddc80c4cc0
2015-09-01 15:55:53       INFO [09/01/15 15:55:53:97] Git tag '3.0.20': 3.0.20 with commit count source ea8a3f0b96c77b1ea5340e67a698a1e57f0a502c
2015-09-01 15:55:53       INFO [09/01/15 15:55:53:99] Git tag '3.0.19': 3.0.19 with commit count source 16713d9a7700a750a0c271bb6ac75133a0df4ec1
2015-09-01 15:55:54       INFO [09/01/15 15:55:54:90] Merge message 'Merge remote-tracking branch 'origin/master' into release/3.1.0

Conflicts:
    source/Octopus.Server/packages.config
    source/Octopus.Tests/Octopus.Server/Orchestration/Deploy/AcquisitionPlanFixture.cs
    source/Octopus.Tests/Octopus.Server/Orchestration/Deploy/AcquisitionServiceFixture.cs
    source/Octopus.Tests/Octopus.Server/Orchestration/Deploy/DeploymentPlanFixture.cs': 3.1.0 with commit count source 7025eb3f4a737e85403ce6d24bcfd3a08dd5d640
2015-09-01 15:55:55       INFO [09/01/15 15:55:55:06] Merge message 'Merge branch 'master' into release/3.1.0': 3.1.0 with commit count source c306702545bae29299541bf0074e3401bc0f9048
2015-09-01 15:55:55       INFO [09/01/15 15:55:55:07] Merge message 'Merge branch 'master' into release/3.1.0': 3.1.0 with commit count source 218d2231f756d4c8659ca983ed954b0486fba7c8
2015-09-01 15:55:55       INFO [09/01/15 15:55:55:08] Merge message 'Merge branch 'master' into release/3.1.0': 3.1.0 with commit count source ac20450fdd842fdf79ec3783f1c8e23676d53f36
2015-09-01 15:55:55       INFO [09/01/15 15:55:55:08] Merge message 'Merge branch 'release-2.4'

Conflicts:
    portal/app/areas/tasks/views/task.html': 2.4.0 with commit count source ebe3a1e9b5c691d4e8588cb167c9629f71666f5f
2015-09-01 15:55:55       INFO [09/01/15 15:55:55:21] Merge message 'Merge branch 'release-2.4'': 2.4.0 with commit count source 5cc8da970fecbe3f4a2a6a2dfb4e10872d6900de
2015-09-01 15:55:55       INFO [09/01/15 15:55:55:34] Begin: Finding branch source
2015-09-01 15:55:55       INFO [09/01/15 15:55:55:53] End: Finding branch source (Took: 190.01ms)
2015-09-01 15:55:55     INFO [09/01/15 15:55:55:53] End: Calculating base versions (Took: 4,429.87ms)
2015-09-01 15:55:55     ERROR [09/01/15 15:55:55:54] 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(Branch b)
   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.VersionCalculation.BaseVersionCalculators.VersionInBranchBaseVersionStrategy.<GetVersions>d__0.MoveNext()
   at System.Linq.Enumerable.<SelectManyIterator>d__1`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersion(GitVersionContext context)
   at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion(GitVersionContext context)
   at GitVersion.GitVersionFinder.FindVersion(GitVersionContext context)
   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()
2015-09-01 15:55:55     INFO [09/01/15 15:55:55:55] 
2015-09-01 15:55:55     INFO [09/01/15 15:55:55:55] Here is the current git graph (please include in issue): 
2015-09-01 15:55:55     INFO [09/01/15 15:55:55:55] Showing max of 100 commits
2015-09-01 15:55:55     INFO [09/01/15 15:55:55:77] *   7025eb3 27 minutes ago  (HEAD, origin/release/3.1.0, release/3.1.0)
|\  
| *   3fcb35e 2 hours ago  (tag: 3.0.21, origin/master, master)
| |\  
| | * 13eca66 6 hours ago 
| | * a3850cb 23 hours ago 
| * | a58d8bb 6 hours ago 
| * | b856945 6 hours ago 
| * | e2cac48 9 hours ago 
| * | 78e9485 22 hours ago 
| * | 82f7ab6 23 hours ago 
| |/  
| * ea8a3f0 24 hours ago  (tag: 3.0.20)
| * c9eeea0 24 hours ago 
| * e5f5aca 25 hours ago 
| * 87a2628 26 hours ago 
| * 35e4ccb 26 hours ago 
| *   f9b6834 26 hours ago 
| |\  
| | * ebcf3c4 26 hours ago 
| | * b3a3fa4 26 hours ago 
* | |   c306702 27 hours ago 
|\ \ \  
| |/ /  
| * | 600a57d 27 hours ago 
* | | 92adc77 27 hours ago 
* | |   218d223 27 hours ago 
|\ \ \  
| |/ /  
| * | 84618b5 27 hours ago 
* | | a7242b6 28 hours ago 
* | | 5e07664 28 hours ago 
* | |   ac20450 29 hours ago 
|\ \ \  
| |/ /  
| * | fad02e5 29 hours ago 
* | | d56dfc5 29 hours ago 
* | |   583f944 30 hours ago  (origin/beta, beta)
|\ \ \  
| |/ /  
| * | 8d1f084 30 hours ago 
| |/  
* |   f1db9af 4 days ago 
|\ \  
| |/  
| * a1e0243 4 days ago 
| * 2f50b22 4 days ago 
* |   561dfc3 4 days ago 
|\ \  
| * \   1275b7e 4 days ago  (tag: build-3.1.0.2542)
| |\ \  
| | * \   63f1e7a 4 days ago  (origin/feature-azurePath)
| | |\ \  
| | |/ /  
| |/| |   
| | * | b2a4d6d 4 days ago 
| | * | c249918 5 days ago 
* | | |   49c10b0 4 days ago 
|\ \ \ \  
| |/ / /  
| * | |   eba1593 4 days ago  (tag: build-3.1.0.2540)
| |\ \ \  
| | * | | 3345c83 4 days ago 
| | * | |   f3e39a4 4 days ago 
| | |\ \ \  
| | |/ / /  
| |/| | |   
| | * | | abe8c5a 4 days ago 
| | * | | 048adde 4 days ago 
| | * | | c989c88 4 days ago 
| | * | | 3696a18 5 days ago 
| | * | | c674024 5 days ago 
| | * | | 40fe93b 5 days ago 
| | * | | a2b1891 5 days ago 
| | * | | cc8b669 5 days ago 
| | * | | 1fcd282 5 days ago 
| | * | | 857c47e 5 days ago 
| | |/ /  
* | | | e9f796c 4 days ago 
* | | |   b5f1c35 4 days ago 
|\ \ \ \  
| | |_|/  
| |/| |   
| * | | 7cbb46c 4 days ago  (tag: build-3.0.20.2537+35)
* | | | be6640e 4 days ago 
* | | | b174ebb 4 days ago 
* | | |   e183b9d 4 days ago 
|\ \ \ \  
| |/ / /  
| | / /   
| |/ /    
|/| |     
| * | 1700b2f 4 days ago  (tag: build-3.0.20.2536+34)
| * | 9988c4b 4 days ago  (tag: build-3.0.20.2534+33)
| * | 0e08078 4 days ago  (tag: build-3.0.20.2533+32)
| * | b5c8b5a 4 days ago  (tag: build-3.0.20.2531+31)
| * | ee6db56 4 days ago 
| * | ae31030 4 days ago 
| * | 8f9e0a1 4 days ago 
| * | c6dea64 4 days ago 
| * | e35699a 4 days ago 
| * | 663f1d8 5 days ago  (tag: build-3.0.20.2526+25)
| * | 63b9314 5 days ago  (tag: build-3.0.20.2525+24)
| * | 92ad037 5 days ago 
| * | 967f760 5 days ago 
| * | 77c9a59 5 days ago 
| * | d842233 5 days ago 
| * | 7a58539 5 days ago 
| * | 9b4b128 5 days ago 
| * | 99558dc 5 days ago 
| * | ab32462 5 days ago 
| * | 8add9d8 5 days ago 
| * | 300a8fc 5 days ago 
| * | b03beb4 5 days ago 
| * | 89dce61 5 days ago 
| * | b116646 5 days ago 
| * | 15db036 5 days ago 
* | | af9301f 4 days ago  (tag: build-3.1.0.2535)
* | |   fbc4419 5 days ago  (tag: build-3.1.0.2514)
|\ \ \  
| * \ \   05b2883 5 days ago 
| |\ \ \  
| |/ / /  
|/| | |   
* | | |   20060cc 5 days ago  (tag: build-3.1.0.2504)
|\ \ \ \  
| | |/ /  
| |/| |   
| * | |   f0cbc83 6 days ago  (tag: build-3.0.20.2501)
| |\ \ \  
| | * | | b9a8727 6 days ago 
| | * | | ce8d603 6 days ago 
| | * | | d7be2cd 6 days ago 
| | * | | 129ff47 7 days ago 
| | * | | 236624d 7 days ago 
| | * | | 4ea546a 7 days ago 
| | * | | bb68e45 7 days ago 
| | * | | 070b7c7 7 days ago 
| |/ / /  
* | | |   0362490 5 days ago 
|\ \ \ \  
| |/ / /  
| | | /   
| |_|/    
|/| |     
| * |   16713d9 8 days ago  (tag: build-3.0.19.2485, tag: 3.0.19)
| |\ \  
| | * | 8d1c533 8 days ago 
| | * | 1cb8175 2 weeks ago 
| | * | faaee26 2 weeks ago 

@michaelnoonan
Copy link
Contributor Author

A git clone later and I can reproduce the issue with the debugger attached.

b.Tip is null in if (b.Tip.Parents.Contains(branch.Tip))

if (b.Tip.Parents.Contains(branch.Tip))

All of the 20 otherBranches are OK (they all have a Tip) except one specific branch: refs/remotes/origin/HEAD => "?" which is the symbolic ref for the default branch at our origin remote.

If I checkout master gitversion.exe works OK.
If I checkout release/3.1.0 I get the NullReferenceException

git remote show origin reveals:

c:\dev\OctopusDeploy>git remote show origin
* remote origin
  Fetch URL: https://github.com/OctopusDeploy/OctopusDeploy.git
  Push  URL: https://github.com/OctopusDeploy/OctopusDeploy.git
  HEAD branch: master
  Remote branches:
    beta                    tracked
    bug-sensitivevalues     tracked
    feature-auditColumns    tracked
    feature-azurePath       tracked
    feature-azurerevert     tracked
    feature-fasterevents    tracked
    feature-reporting2      tracked
    feature-tentacleupgrade tracked
    feature-uirouter        tracked
    feature/AvSharePackages tracked
    master                  tracked
    onlyrunonteamcity       tracked
    release-2.5.13          tracked
    release-2.6.5           tracked
    release/3.1.0           tracked
    semvertentacles         tracked
  Local branches configured for 'git pull':
    BUG-SensitiveService merges with remote BUG-SensitiveService
    beta                 merges with remote beta
    master               merges with remote master
    release/3.1.0        merges with remote release/3.1.0
    semvertentacles      merges with remote semvertentacles
  Local refs configured for 'git push':
    beta            pushes to beta            (up to date)
    master          pushes to master          (up to date)
    release/3.1.0   pushes to release/3.1.0   (up to date)
    semvertentacles pushes to semvertentacles (up to date)

Without looking into the code much further I'm not sure if this method should be ignoring branches where there is no Tip - or if something underlying is wrong with this symbolic ref and a different exception should be raised to inform the person they should fix their repo.

@JakeGinnivan
Copy link
Contributor

@nulltoken what do you think?

@michaelnoonan
Copy link
Contributor Author

It turns out GetBranchesContainingCommit() has a similar problem.

INFO [09/03/15 10:53:00:36] Working directory: C:\Users\mjr\src\Octopus\OctopusDeploy
INFO [09/03/15 10:53:00:40] Project root is: C:\Users\mjr\src\Octopus\OctopusDeploy
INFO [09/03/15 10:53:00:46] Using latest commit on specified branch
INFO [09/03/15 10:53:00:47] Begin: Attempting to inherit branch configuration from parent branch
  INFO [09/03/15 10:53:00:52] Begin: Finding branch source
  INFO [09/03/15 10:53:00:79] End: Finding branch source (Took: 270.98ms)
INFO [09/03/15 10:53:00:85] End: Attempting to inherit branch configuration from parent branch (Took: 373.98ms)
ERROR [09/03/15 10:53:00:86] An unexpected error occurred:
System.NullReferenceException: Object reference not set to an instance of an object.
   at GitVersion.LibGitExtensions.<GetBranchesContainingCommit>d__20.MoveNext()
   at System.Linq.Enumerable.<ExceptIterator>d__1`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   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 [09/03/15 10:53:00:86]
INFO [09/03/15 10:53:00:86] Here is the current git graph (please include in issue):
INFO [09/03/15 10:53:00:86] Showing max of 100 commits
INFO [09/03/15 10:53:01:25] * dfbbadd 2 minutes ago  (HEAD, tag: 3.2.0-beta1, feature-branching)
* 427efef 19 hours ago  (origin/release/3.1.0, release/3.1.0)
*   b1baae1 20 hours ago
|\
| | * 0e1cba5 20 hours ago  (tag: 3.0.21, origin/master, master)
| |/
| *   b9299eb 25 hours ago
| |\
| | *   c92318a 2 days ago
| | |\
| | * | b215261 2 days ago
| | * |   595f8bb 2 days ago
| | |\ \
| | * | | 3db6594 2 days ago
| * | | | 9efd3ff 25 hours ago
| * | | | ab382f2 26 hours ago
| * | | | 57d73b7 26 hours ago
| * | | | 8fba2be 2 days ago
| * | | | 52bb634 2 days ago
| * | | | fefeea0 2 days ago
| * | | | d8f3a4e 2 days ago
| * | | | df68d1a 2 days ago
| | |_|/
| |/| |
| | | | * 4298e86 35 hours ago  (origin/semvertentacles)
| | | | * b4a832a 35 hours ago
| | | | * f55ec2c 35 hours ago
| | | | * 0a09ecb 35 hours ago
| |_|_|/
|/| | |
* | | | 52aa53c 2 days ago
* | | | 87e39f9 2 days ago
* | | |   7025eb3 2 days ago
|\ \ \ \
| |/ / /
| * | |   3fcb35e 2 days ago
| |\ \ \
| | |_|/
| |/| |
| | * | 13eca66 2 days ago
| | * | a3850cb 3 days ago
| * | | a58d8bb 2 days ago
| * | | b856945 2 days ago
| * | | e2cac48 2 days ago
| * | | 78e9485 3 days ago
| * | | 82f7ab6 3 days ago
| |/ /
| * | ea8a3f0 3 days ago  (tag: 3.0.20)
| * | c9eeea0 3 days ago
| * | e5f5aca 3 days ago
| * | 87a2628 3 days ago
| * | 35e4ccb 3 days ago
| * |   f9b6834 3 days ago
| |\ \
| | * | ebcf3c4 3 days ago
| | * | b3a3fa4 3 days ago
* | | |   c306702 3 days ago
|\ \ \ \
| |/ / /
| * | | 600a57d 3 days ago
* | | | 92adc77 3 days ago
* | | |   218d223 3 days ago
|\ \ \ \
| |/ / /
| * | | 84618b5 3 days ago
* | | | a7242b6 3 days ago
* | | | 5e07664 3 days ago
* | | |   ac20450 3 days ago
|\ \ \ \
| |/ / /
| * | | fad02e5 3 days ago
* | | | d56dfc5 3 days ago
* | | |   583f944 3 days ago  (beta)
|\ \ \ \
| |/ / /
| * | | 8d1f084 3 days ago
| |/ /
* | |   f1db9af 6 days ago
|\ \ \
| |/ /
| * | a1e0243 6 days ago
| * | 2f50b22 6 days ago
* | |   561dfc3 6 days ago
|\ \ \
| * \ \   1275b7e 6 days ago  (tag: build-3.1.0.2542)
| |\ \ \
| | * \ \   63f1e7a 6 days ago  (origin/feature-azurePath, feature-azurePath)
| | |\ \ \
| | |/ / /
| |/| | |
| | * | | b2a4d6d 6 days ago
| | * | | c249918 7 days ago
* | | | |   49c10b0 6 days ago
|\ \ \ \ \
| |/ / / /
* | | | | e9f796c 6 days ago
* | | | |   b5f1c35 6 days ago
|\ \ \ \ \
| | |_|/ /
| |/| | |
| * | | | 7cbb46c 6 days ago  (tag: build-3.0.20.2537+35)
* | | | | be6640e 6 days ago
* | | | | b174ebb 6 days ago
* | | | |   e183b9d 6 days ago
|\ \ \ \ \
| |/ / / /
| * | | | 1700b2f 6 days ago  (tag: build-3.0.20.2536+34)
| * | | | 9988c4b 6 days ago  (tag: build-3.0.20.2534+33)
| * | | | 0e08078 6 days ago  (tag: build-3.0.20.2533+32)
| * | | | b5c8b5a 6 days ago  (tag: build-3.0.20.2531+31)
| * | | | ee6db56 6 days ago
| * | | | ae31030 6 days ago
| * | | | 8f9e0a1 6 days ago
| * | | | c6dea64 6 days ago
| * | | | e35699a 6 days ago
| * | | | 663f1d8 7 days ago  (tag: build-3.0.20.2526+25)
| * | | | 63b9314 7 days ago  (tag: build-3.0.20.2525+24)
| * | | | 92ad037 7 days ago
| * | | | 967f760 7 days ago
| * | | | 77c9a59 7 days ago
| * | | | d842233 7 days ago
| * | | | 7a58539 7 days ago
| * | | | 9b4b128 7 days ago
| * | | | 99558dc 7 days ago
| * | | | ab32462 7 days ago
| * | | | 8add9d8 7 days ago
| * | | | 300a8fc 7 days ago
| * | | | b03beb4 7 days ago
| * | | | 89dce61 7 days ago
| * | | | b116646 7 days ago
| * | | | 15db036 7 days ago
| | |_|/
| |/| |
| | | | * de6345d 2 days ago  (azureApiTests)
| | | |/
| | |/|
| | * |   eba1593 6 days ago  (tag: build-3.1.0.2540)
| | |\ \
| |/ / /
|/| | |
| | * | 3345c83 6 days ago
| | * |   f3e39a4 6 days ago
| | |\ \
| |_|/ /
|/| | |
* | | | af9301f 6 days ago  (tag: build-3.1.0.2535)
* | | |   fbc4419 7 days ago  (tag: build-3.1.0.2514)
|\ \ \ \
| * \ \ \   05b2883 7 days ago
| |\ \ \ \
| |/ / / /
|/| | | |
* | | | |   20060cc 7 days ago  (tag: build-3.1.0.2504)
|\ \ \ \ \
| | |/ / /
| |/| | |

@nulltoken
Copy link
Contributor

All of the 20 otherBranches are OK (they all have a Tip) except one specific branch: refs/remotes/origin/HEAD => "?" which is the symbolic ref for the default branch at our origin remote.

@JakeGinnivan My guess is that the remote HEAD points to a commit which is unknown from the local repo. Would that make sense?

@michaelnoonan
Copy link
Contributor Author

Hi @nulltoken and @JakeGinnivan, thanks for taking a look.

I was pretty sure refs/remotes/origin/HEAD pointed to release/3.1.0 at the time. It's happening again today, but it looks for sure like my local repository has the referenced commit:

git show-ref --head --heads
520b442a07ca011741b444ec542458ba636f8d9a HEAD
0e1cba56572aebc9e51f36c9d656496557991112 refs/heads/master
520b442a07ca011741b444ec542458ba636f8d9a refs/heads/release/3.1.0

Which looks like the git graph I'd expected, especially the line here (extracted):
* 520b442 24 hours ago (HEAD, origin/release/3.1.0, release/3.1.0)

INFO [09/08/15 13:33:12:58]
INFO [09/08/15 13:33:12:58] Here is the current git graph (please include in issue):
INFO [09/08/15 13:33:12:58] Showing max of 100 commits
INFO [09/08/15 13:33:12:88] * 767af07 57 minutes ago  (origin/enh-toggleDelta)
* 46d048f 87 minutes ago
* 0e1cba5 6 days ago  (tag: 3.0.21, origin/master, master)
| * 520b442 24 hours ago  (HEAD, origin/release/3.1.0, release/3.1.0)
| *   2b1050a 25 hours ago
| |\
| | * 798592e 25 hours ago
| | * 1870f07 25 hours ago
| | *   e1eccb8 26 hours ago
| | |\
| | |/
| |/|
| * | 8b76811 28 hours ago
| * | f8bb07b 3 days ago  (tag: 3.1.0-beta.2)
| * |   3e94c54 5 days ago  (tag: 3.1.0-beta.1)
| |\ \

I'm happy to help out however I can.

@michaelnoonan
Copy link
Contributor Author

I thought of another test, since GitVersion is running as part of our CI builds from the origin. When I took a new clone from the origin GitVersion is working OK on the release/3.1.0 branch with the same commit as head.

I wonder what the difference is between the two clones?

git show-ref --head --heads
520b442a07ca011741b444ec542458ba636f8d9a HEAD
0e1cba56572aebc9e51f36c9d656496557991112 refs/heads/master
520b442a07ca011741b444ec542458ba636f8d9a refs/heads/release/3.1.0

@nulltoken
Copy link
Contributor

Could you please run $ git show-ref origin/HEAD from the non-working repository?

@michaelnoonan
Copy link
Contributor Author

Oh, interesting - thanks this does seem to be where there's a difference:

non-working repository

git show-ref origin/HEAD

working repository

git show-ref origin/HEAD
0e1cba56572aebc9e51f36c9d656496557991112 refs/remotes/origin/HEAD

@michaelnoonan
Copy link
Contributor Author

I've been able to reproduce this on another person's repository, different branch, but the same result for git show-ref origin/HEAD.

@nulltoken
Copy link
Contributor

@JakeGinnivan Now that we've got the explanation, any idea regarding how to identify the root cause? How should we guard against this? Skip, explicitly throw?

@JakeGinnivan
Copy link
Contributor

I recon just skip. It shouldn't affect the running of GitVersion if we skip?

@nulltoken
Copy link
Contributor

I recon just skip. It shouldn't affect the running of GitVersion if we skip?

I don't know any more. It's been too long since I worked on GitVersion to properly remember all the flows. However, adding a commit which skips and log an explicit warning (maybe containing a link to this issue, should maybe help us troubleshoot further the root cause).

Not having a remote tracking reference for HEAD is pretty weird and we should definitely track how this can happen.

@michaelnoonan
Copy link
Contributor Author

Hey @JakeGinnivan and @nulltoken. I think I've got a suggestion that makes sense to me.

I think the fact that git show-ref origin/HEAD is null (or empty or blank) is representative of something gone wrong with the local repository - especially since cloning the repo again fixes the problem.

I've found from researching this particular problem that once your local repo gets in this state it won't be fixed by any other process except cloning again, or manually setting the origin/HEAD. The best resource I ended up finding was http://stackoverflow.com/questions/8839958/how-does-origin-head-get-set

$ git remote set-head origin --auto
origin/HEAD set to master
$ git show-ref origin/HEAD
b1f228f5d4aee7be52d7c207516b5a5f2193ad52 refs/remotes/origin/HEAD

And GitVersion works again!

So my recommendation is:

  1. Detect origin/HEAD has a null Tip
  2. Fail with an error explaining the repository should be fixed by running git remote set-head origin --auto

What do you both think?

@JakeGinnivan
Copy link
Contributor

That sounds good to me. I think that is safer than filtering out or trying to fix on the fly

@nulltoken
Copy link
Contributor

👍 as well (although I'm curious about the how this happened in the first place)

@michaelnoonan
Copy link
Contributor Author

Curious - me too. From what I can tell neither of us (who have had this issue) are doing anything very weird, and the continual mentions that "nothing updates the origin/HEAD ref except clone and manually updating it" has me double confused.

In either case I think we've got a reasonable approach now. I'll get a PR together over the next few days @JakeGinnivan.

@michaelnoonan
Copy link
Contributor Author

Or weeks... :)

@JakeGinnivan
Copy link
Contributor

Fine by me, I am distracted on a few other things. This way I don't feel as bad :P

@aguacongas
Copy link

I've the same issue using gitversion on AppVeyor only. On my machine it works

AppVeyor log

[
log.txt
](url)

@asbjornu
Copy link
Member

asbjornu commented Aug 9, 2016

@aguacongas Which version of GitVersion are you using?

@aguacongas
Copy link

aguacongas commented Aug 9, 2016

@asbjornu GitVersion.Portable v4.0.0-beta0001

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