Skip to content

git_remote_create without insteadof rewrite rules #4658

Description

@vors

You are opening a bug report against the libgit2 project. If you have a
question about an API or usage, please ask on StackOverflow:
http://stackoverflow.com/questions/tagged/libgit2. Please fill out the
reproduction steps (below) and delete this introductory paragraph. Thanks!

Prelude

Apoligies in advance for openning an issue that could be viewed more like an API question and not a bug report. I asked on stackoverflow as suggested, but didn't get any replies.
It's unclear to me that this is even possible to achive with the current public APIs at all. Hence, I think it's appropriate to open an issue in this repo.

Question

This is somewhat similar to #2923 .

I'd like to use an equivalent of git_remote_create_anonymous function, but without applying insteadof url substitutions. This is similar to git_remote_create_detached which explicitly says that it doesn't apply insteadof substitues.

I could not find an equivalent API or combination of APIs that would get me a fetchable repo without the global config substitutes applied.

Am I missing something? If not, would it be reasonable to add such API?

Motivation

The use-case of it is to bypass any users global ~/.gitconfig settings.
For example, it's common to have

[url "ssh://[email protected]/"]
    insteadOf = https://github.com/

CircleCI uses this approach.

That causes somewhat unpredictable behavior for tools that use github repos for their online indexes, like cargo. Users find workaround for it, but it would be really nice to put more control in the hands of tools authors, so they can bypass the rewrite rules. libgit2 already does it for git ls-remote functionality with detached repos.

Activity

  1. tiennou commented on May 29, 2018

    @tiennou
    Contributor

    I'm not really against adding API for that, I'm just wondering about this (after having written the code 🤷‍♂️) :

    If your ultimate goal is to ignore the user's .gitconfig, what prevents you from manually building a git_config instance and switching the repository to that instead of using the default ? See git_repository_set_config and git_config_open_ondisk.

    AFAIU, your repoes are not really user-accessible ?

    On the subject of API changes, this can bring down the 4 git_remote_create* functions we have down to 2. If this is deemed a worthy goal, I can PR the code I have.

  2. pks-t commented on Jun 1, 2018

    @pks-t
    Member

    I think it's sensible to provide a way of creating remotes without paying attention to insteadof rules.

    The current design of our creation functions is a bit unfortunate, as none of these functions is able to accept an opts structure. But changing existing public API to fix that is a no-go, unfortunately, so that we make sure to not break our users. One way to fix this situation is to just provide a new set of functions git_remote_create_*_with_opts, which would allow us to do future changes without breaking the API. Yeah, it is ugly, but I don't see a better way to do this while keeping our API.

  3. vors commented on Jun 1, 2018

    @vors
    Author

    Yes, making it extensible for the future is a great idea. @tiennou just used a name git_remote_create_ext in the #4667 , which I think a consistent C name for such cases (I'm very far from C expert, don't quote me on it).

  4. vors commented on Nov 13, 2018

    @vors
    Author

    This is merged now!

  5. pks-t commented on Nov 14, 2018

    @pks-t
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions