libgit2 / libgit2/libgit2sharp

Remotes are sometimes not returned for worktree

Open
#1,678 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

Reproduction steps
  1. Create repository with remote and commit.
  2. Create branch and create a worktree from that branch.
  3. Copy the path to worktree and run the following code:
var worktreePath = "Here is your worktree path";
var repositoryPath = Repository.Discover(worktreePath);
var repo = new Repository(repositoryPath);

var before = repo.Network.Remotes.ToArray();
_ = repo.Head.RemoteName;
var after = repo.Network.Remotes.ToArray();
Expected behavior

Both before and after variable contain remote.

Actual behavior

The before variable contains remote, after is empty.

Version of LibGit2Sharp (release number or SHA1)

Latest master: 7f59d22c4fdb7b3d14511aca567e64eefaa43ab2

Operating system(s) tested; .NET runtime tested

Windows, .NET Framework 462 and .NET Core 2.1. I believe it doesn't matter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported C# reproduction on the latest master, focusing on Repository.Discover, repo.Network.Remotes, and repo.Head.RemoteName with a linked worktree. Trace why accessing Head.RemoteName changes the remotes result; done when both before and after contain the repository remote.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.