Re: Git bug report git remote get-url

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 05, 2022 at 05:22:06PM +0000, Nanekrangsan, Sucheela (NYC-GIS) wrote:
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
> 1. I put [remote] entries in /etc/gitconfig

This is almost certainly the culprit.

`git remote get-url` doesn't output anything (except the error message
included in your report) when `remote->configured_in_repo` is zero.
Indeed, looking at remote.c:handle_config() where we actually add a new
remote:

    remote = make_remote(remote_state, name, namelen);
    remote->origin = REMOTE_CONFIG;
    if (current_config_scope() == CONFIG_SCOPE_LOCAL ||
        current_config_scope() == CONFIG_SCOPE_WORKTREE)
            remote->configured_in_repo = 1;

we only set configured_in_repo when we're looking at local or
worktree configuration. Since $(prefix)/etc/gitconfig isn't either of
those, we'll avoid setting configured_in_repo, hence we'll end up inside
of this if-statement in builtin/remote.c:get_url():

    remote = remote_get(remotename);
    if (!remote_is_configured(remote, 1)) {
            error(_("No such remote '%s'"), remotename);
            exit(2);
    }

...producing the error message in your report.

> 4. After `git remote add xxx`, I can get the URL from `git remote get-url`.

This makes sense, since `git remote add` will configure the remote `xxx`
in your repository-local configuration, not the system-wide one.

Thanks,
Taylor



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux