git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Git bug report git remote get-url
@ 2022-01-05 17:22 Nanekrangsan, Sucheela (NYC-GIS)
  2022-01-06  0:22 ` Taylor Blau
  0 siblings, 1 reply; 2+ messages in thread
From: Nanekrangsan, Sucheela (NYC-GIS) @ 2022-01-05 17:22 UTC (permalink / raw)
  To: git@vger.kernel.org; +Cc: Frank, Carson (OMA-GIS)

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
2. `git config --get remote.xxx.url` returns the correct URL. I can `git pull` from this remote.
3. `git remote get-url xxx` returns "error: No such remote 'xxx'"
4. After `git remote add xxx`, I can get the URL from `git remote get-url`.
What did you expect to happen? (Expected behavior)
I expected `git-remote get-url` to give me the URL I added in /etc/gitconfig. 

What happened instead? (Actual behavior)
`git remote get-url` did not recognize the report I added in /etc/gitconfig.

What's different between what you expected and what actually happened?
I expected the URL from /etc/gitconfig from `git remote get-url` but got error.

Anything else you want to add:
These give me the correct results
`git config --get remote.xxx.url`
`git ls-remote --get-url xxx`

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.34.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 3.10.0-1160.49.1.el7.x86_64 #1 SMP Tue Nov 30 15:51:32 UTC 2021 x86_64
compiler info: gnuc: 4.8
libc info: glibc: 2.17
$SHELL (typically, interactive shell): /bin/bash



This message contains information which may be confidential and privileged. Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message.  If you have received the message in error, please advise the sender by reply e-mail, and delete the message.  Thank you very much.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Git bug report git remote get-url
  2022-01-05 17:22 Git bug report git remote get-url Nanekrangsan, Sucheela (NYC-GIS)
@ 2022-01-06  0:22 ` Taylor Blau
  0 siblings, 0 replies; 2+ messages in thread
From: Taylor Blau @ 2022-01-06  0:22 UTC (permalink / raw)
  To: Nanekrangsan, Sucheela (NYC-GIS)
  Cc: git@vger.kernel.org, Frank, Carson (OMA-GIS)

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-06  0:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 17:22 Git bug report git remote get-url Nanekrangsan, Sucheela (NYC-GIS)
2022-01-06  0:22 ` Taylor Blau

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).