Skip to content

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

Closed

Description

@larsks

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

$ git config --list | grep me:
url.ssh://[email protected]/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://[email protected]/larsks/git-bug-example

Activity

  1. MichaelMure commented on Dec 8, 2022

    @MichaelMure
    Contributor

    It's likely another shortcoming of go-git, although it seems that support for that has been added? go-git/go-git#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?

  2. larsks commented on Dec 9, 2022

    @larsks
    Author

    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.

  3. MichaelMure commented on Dec 9, 2022

    @MichaelMure
    Contributor

    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.

  4. github-actions commented on Jul 23, 2024

    @github-actions

    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
  5. miwig commented on Aug 6, 2024

    @miwig

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

  6. added this to the 0.8.2 milestone on Aug 7, 2024
  7. self-assigned this
    on Aug 7, 2024
  8. added
    area/gitRelates to git operations
    priority/backlogHigher priority than priority/awaiting-more-evidence
    and removed on Aug 7, 2024
  9. sudoforge commented on Aug 7, 2024

    @sudoforge
    Contributor

    @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/[email protected], 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://[email protected]/"]
    	insteadOf = gh:
    

    this is still an issue at HEAD (3141185). 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.

  10. modified the milestones: 0.8.2, 0.8.1 on Apr 29, 2025
  11. added 4 commits that reference this issue on Apr 29, 2025
    e742ce3
    973da59
    f96836c
    8798018
  12. added a commit that references this issue on Apr 30, 2025
    a150cdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/gitRelates to git operationskind/bugRelates to an issuepriority/backlogHigher priority than priority/awaiting-more-evidencetriage/acceptedThis issue is accepted

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions