Skip to content

"Repository has no commit" error in case of worktree + packed-refs #1290

@vikukush

Description

@vikukush

After git decided to pack my repo with several worktrees and a bunch of local branches, my builds started failing with following error:

D:\Corextroot\microsoft.build.tasks.git\8.0.0\build\Microsoft.Build.Tasks.Git.targets(25,5): Repository has no commit. [D:\Pl3\Test\UnitTests\Common\Tools.UnitTests.Common\Tools.UT.Common.csproj]

  • D:\Pl3 is a worktree of D:\Platform.
  • D:\Platform\.git\worktrees\Pl3\refs is empty.
  • D:\Platform\.git\refs\heads doesn't have a ref of a branch that's checked out in D:\Pl3 either
  • The only reference to the commit ID of a branch specified in D:\Platform\.git\worktrees\Pl3\HEAD is in D:\Platform\.git\packed-refs

Sourcelink task is unable to handle this situation.

I have worked to add a unit test that covers my scenario: #1289

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions