"git bug push" fails with "Error: repository not found" when using insteadOf

Labels: area/git kind/bug lifecycle/pinned priority/backlog triage/accepted

Timeline

Lars Kellogg-Stedman (larsks) opened

I have insteadOf aliases in my git configuration, like this:

$ git config --list | grep me:
url.ssh://git@github.com/larsks/.insteadof=me:

If I configure a repository with a remote using that alias, as in:

git remote set-url origin me:git-bug-example

Then when I attempt to git bug push with this configuration, it fails with an error:

$ git bug push
Error: repository not found

It looks like git bug is performing git operations with something that doesn't parse git configuration files. Aliases like this can be expanded using the git remote get-url command:

$ git remote get-url origin
ssh://git@github.com/larsks/git-bug-example

Michael Muré (MichaelMure) added label area/dependencies

Michael Muré (MichaelMure) added label go-git

Michael Muré (MichaelMure) added label kind/bug

Michael Muré (MichaelMure) commented

It's likely another shortcoming of go-git, although it seems that support for that has been added? https://github.com/go-git/go-git/pull/79

Unfortunately, it's unlikely I can do anything about it. Maybe try to see if go-git (the minimal command they have) is able to understand your config?

Lars Kellogg-Stedman (larsks) commented (edited)

Stepping through things with dlv debug, it looks like go-git isn't reading the global configuration: if I move the url configuration into .git/config, it seems to work as expected. That is, with the url configuration only in the global config, c.URLS is empty when we get to https://github.com/go-git/go-git/blob/master/config/config.go#L338; if I put the url configuration into .git/config, that variable gets populated as expected and insteadOf aliases are expanded.

The weird thing is that running git-bug under strace I can see that it's clearly reading the global configuration, so not entirely clear what's going on here.

This is probably a go-git issue, but to verify that I'll have to create a reproducer.

Michael Muré (MichaelMure) commented

Those are two very different code path, as git-bug is reading the local+global config on its own. On the other hand when push/pull is done, it's pure go-git. It does look like a go-git bug.

github-actions (github-actions) commented

This bot triages untriaged issues and PRs according to the following rules:

  • After 90 days of inactivity, the lifecycle/stale label is applied
  • After 30 days of inactivity since lifecycle/stale was applied, the issue is closed

To remove the stale status, you can:

  • Remove the lifecycle/stale label
  • Comment on this issue

github-actions (github-actions) added label lifecycle/stale

sudoforge removed label go-git

Michael Wigard (miwig) commented

I got this problem with a repository URL containing ~ to refer to the home directory. Using an absolute path fixed it.

sudoforge removed label area/dependencies

sudoforge removed label lifecycle/stale

sudoforge added label triage/accepted

sudoforge added label area/git

sudoforge added label priority/backlog

sudoforge commented (edited)

@larsks said earlier:

it looks like go-git isn't reading the global configuration: if I move the url configuration into .git/config, it seems to work as expected

i know it's been a while, but thanks for running the debugger. having used go-git in some other projects, i can confirm indeed that they do not parse the url.<base>.insteadOf configuration (or even, last i checked, configuration via includeIf or other mechanisms).

support for this was (supposedly) added in go-git/go-git@v3.0, but it doesn't seem to actually work, with the url.<base>.insteadOf configuration in either the global or local scope, for example, using the following configuration:

[remote "origin"]
	url = gh:git-bug/git-bug.git
	fetch = +refs/heads/*:refs/remotes/origin/*

[url "ssh://git@github.com/"]
	insteadOf = gh:

this is still an issue at HEAD (314118502b154c1fbd34e9f94cc49deed084c858). it looks like we'll need to manually account for this using the default configuration chain (local > global > system, following any includes). i've accepted this bug and have slotted it in for the 0.8.2 release.


@miwig said earlier:

I got this problem with a repository URL containing ~ to refer to the home directory. Using an absolute path fixed it.

are you able to share your url.<base>.insteadOf config(s) for the remote you specified, and remote.<name>.url configuration for the repository? please be sure to redact anything you wish, such as paths on your local filesystem or details from the remote configuration that you don't want to share.

github-actions (github-actions) added label lifecycle/pinned

sudoforge closed the bug

sudoforge closed the bug