git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] remote: allow adding remote w same name as alias

From
Anastas Dancha <anapsix@random.io>
Date
Dec 20, 2014, 20:57 UTC
Message-ID
<CAChhagCrGB1Jq=qZdQnW1EMzw=OPSHzQvXO=jVSnZ2DCEmvAaA@mail.gmail.com>
In-Reply-To
<54945297.3010409@drmicha.warpmail.net>

On Fri, Dec 19, 2014 at 11:30 AM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 43 quoted lines
> Anastas Dancha schrieb am 19.12.2014 um 16:44:
>> Hello Johannes,
>>
>> On Fri, Dec 19, 2014 at 4:37 AM, Johannes Schindelin
>> <Johannes.Schindelin@gmx.de> wrote:
>>> [...]
>>> There is one bit left to clarify: let me guess, you have a $HOME/.gitconfig
>>> like this:
>>>
>>>         [url "anastas@company.com"]
>>>                 insteadOf = backup
>>>                 pushInsteadOf = backup
>>>
>>> and then you want to add the "backup" remote in a Git working directory
>>> like this:
>>>
>>>         git remote add backup me@my-laptop.local
>>>
>>> but my suggested fix will still disallow this because the URL does not
>>> match the url.anastas@company.com.insteadOf?
>>>
>>> Ciao,
>>> Johannes
>>
>> Precisely that. In fact, it will not work even if you do any of these:
>>
>>     git remote add backup anastas@company.com
>>     git remote add backup anything@anyhost.com
>>     git remote add backup backup
>>
>> The original / current code and your suggested fix - both exhibit
>> similar behaviour with the use cases I've described above.
>>
>> Thanks,
>> Anastas
>>
>
> OK, I'll repeat it again: We cannot allow that.
>
> "git push" can take a url or a remote as a parameter. Which one is it if
> you have a remote and a url (alias) with the same name?
>
> Michael

I suppose it could be either. A string can be checked if there is a remote with such name first, and if not, it could be attempted to be used as a url. In fact, my current workaround involves the following:

    git remote add tempname backup:product/repo.git
    git remote rename tempname backup
    git push backup

This seems to work just fine right now with no code changes. Michael, could you explain in more detail what will break in **git push backup** if code changes are made to eliminate the necessity of the add/remote workaround.

Regards, Anastas

Previous: Michael J GruberNext: Johannes Schindelin
Message 7 of 19 in “remote: allow adding remote w same name as alias”
  1. remote: allow adding remote w same name as aliasAnastas Dancha, Dec 16, 2014
  2. Johannes SchindelinDec 16, 2014
  3. Anastas DanchaDec 16, 2014
  4. Johannes SchindelinDec 19, 2014
  5. Anastas DanchaDec 19, 2014
  6. Michael J GruberDec 19, 2014
  7. Anastas DanchaDec 20, 2014
  8. Johannes SchindelinDec 21, 2014
  9. Michael J GruberDec 16, 2014
  10. 0/2 Let `git remote add` play nicer with url.<url>.insteadOfJohannes Schindelin, Dec 22, 2014
  11. 1/2 git remote add: allow re-adding remotes with the same URLJohannes Schindelin, Dec 22, 2014
  12. Junio C HamanoDec 22, 2014
  13. Johannes SchindelinDec 23, 2014
  14. 2/2 Add a regression test for 'git remote add <existing> <same-url>'Johannes Schindelin, Dec 22, 2014
  15. 0/2 Let `git remote add` play nicer with url.<url>.insteadOfJohannes Schindelin, Dec 23, 2014
  16. 1/2 git remote: allow adding remotes agreeing with url.<...>.insteadOfJohannes Schindelin, Dec 23, 2014
  17. 2/2 Add a regression test for 'git remote add <existing> <same-url>'Johannes Schindelin, Dec 23, 2014
  18. Johannes SchindelinDec 23, 2014
  19. Junio C HamanoDec 23, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.