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

Re: git remote rename, why dosen't it exists?

From
VKVincent Kergonna <git@kergonna.fr>
Date
Jun 5, 2008, 08:55 UTC
Message-ID
<1666.78.153.224.34.1212656107.squirrel@mail.kergonna.fr>
In-Reply-To
<alpine.DEB.1.00.0806050529350.21190@racer>
Show 21 quoted lines
> Hi,
>
> On Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:
>
>> On Wed, 2008-06-04 at 16:51 +0100, Johannes Schindelin wrote:
>>
>> > On Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:
>> >
>> > > I trying to refactor [in builtin-remote.c] rm into rm_or_rename, but
>> > > I stumbled into a problem, how do I free a remote struct obtained
>> > > with "remote_get"?
>>
>> It seems that git-remote thinks that remote_get will return NULL if
>> there is no such remote, but in fact it does not do this, it always
>> alloc a new remote struct and returns that newly allocated.
>
> From remote.c, remote_get(), line 601--602 in my checkout:
>
>         if (!ret->url)
>                 return NULL;
>

In fact, I think Victor is right. If you do a simple test (assuming you don't have a remote named foo):

vincent:git$ git remote rm foo error: Could not remove config section 'remote.foo'

You notice that it is trying to remove the configuration section for this remote. We have hit the line 372 of builtin-remote.c:

if (git_config_rename_section(buf.buf, NULL) < 1)
    return error("Could not remove config section '%s'", buf.buf);
instead of exiting at line 364:
if (!remote)
    die("No such remote: %s", argv[1]);
-- 
Vincent
Previous: Johannes Schindelin
Message 11 of 11 in “git remote rename, why dosen't it exists?”
  1. Victor Bogado da Silva LinsJun 3, 2008
  2. Matthieu MoyJun 3, 2008
  3. Johannes SchindelinJun 3, 2008
  4. Johannes SchindelinJun 3, 2008
  5. Victor Bogado da Silva LinsJun 3, 2008
  6. Johannes SchindelinJun 3, 2008
  7. Victor Bogado da Silva LinsJun 4, 2008
  8. Johannes SchindelinJun 4, 2008
  9. Victor Bogado da Silva LinsJun 5, 2008
  10. Johannes SchindelinJun 5, 2008
  11. Vincent KergonnaJun 5, 2008

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.