libgit2 / libgit2/pygit2

branch upstream_name InvalidRefSpec error on literal remote values for branch

Open
#865 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

libgit2
Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

when using hub (https://hub.github.com) to checkout pull requests, it generates a config entry for the branch with the direct reference to the remote git url instead of adding in a remote. This seems to cause some confusion for pygit, specifically iy will end up throwing an InvalidSpecError as pygit tries to follow the remote as a name instead of being to handle a literal git repo value. I'd suggest in such a case pygit simply return the remote name.

https://github.com/libgit2/pygit2/blob/master/src/branch.c#L245

$ branch
<_pygit2.Branch object at 0x10d1197b0>
$ branch.upstream_name
*** _pygit2.InvalidSpecError: 'https://github.com/steveparker-1984/cloud-custodian.git' is not a valid remote name.

entry in .git/config

[branch "fail-on-assume-role-error"]
        remote = https://github.com/steveparker-1984/cloud-custodian.git
        merge = refs/heads/fail-on-assume-role-error

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 inspecting src/branch.c around line 245 and reproduce the shown configuration with a literal HTTPS value in branch.remote. Trace branch.upstream_name handling for that value; done means it no longer raises InvalidSpecError and follows the requested remote-name behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.