{"thread":{"id":"13778","subject":"git remote rename, why dosen't it exists?","startedAt":"2008-06-03T12:49:50Z","lastAt":"2008-06-05T08:55:07Z","messageCount":11,"participants":["Victor Bogado da Silva Lins","Matthieu Moy","Johannes Schindelin","Vincent Kergonna"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"78490","messageId":"1212497390.30731.3.camel@omicron.ep.petrobras.com.br","threadId":"13778","inReplyTo":null,"subject":"git remote rename, why dosen't it exists?","fromName":"Victor Bogado da Silva Lins","fromEmail":"victor@bogado.net","sentAt":"2008-06-03T12:49:50Z","receivedAt":"2008-06-03T12:49:50Z","isPatch":false,"sender":{"key":"victor@bogado.net","avatar":"https://gravatar.com/avatar/4ad1d046d4c1a5673a65aac199e2113f4e2d2ffe88d095cb3e17c1f20126cfac?d=mp&s=160"},"body":"Well, that's about it, I need to rename my remotes. Mainly to move the\norigin to another repository and I miss the feature. Since many time\nthere is a reason for a missing feature, I fought that maybe I should\nask here, before nosing around the sources... :)\n"},{"id":"78496","messageId":"vpq8wxmsl6q.fsf@bauges.imag.fr","threadId":"13778","inReplyTo":"1212497390.30731.3.camel@omicron.ep.petrobras.com.br","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2008-06-03T13:27:25Z","receivedAt":"2008-06-03T13:27:25Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Victor Bogado da Silva Lins <victor@bogado.net> writes:\n\n> Well, that's about it, I need to rename my remotes. Mainly to move the\n> origin to another repository and I miss the feature. Since many time\n> there is a reason for a missing feature, I fought that maybe I should\n> ask here, before nosing around the sources... :)\n\nI think editing .git/config to change the name of the remote would do\nit.\n\n-- \nMatthieu\n"},{"id":"78499","messageId":"alpine.DEB.1.00.0806031449010.13507@racer.site.net","threadId":"13778","inReplyTo":"1212497390.30731.3.camel@omicron.ep.petrobras.com.br","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-03T13:49:45Z","receivedAt":"2008-06-03T13:49:45Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 3 Jun 2008, Victor Bogado da Silva Lins wrote:\n\n> Well, that's about it, I need to rename my remotes. Mainly to move the \n> origin to another repository and I miss the feature. Since many time \n> there is a reason for a missing feature, I fought that maybe I should \n> ask here, before nosing around the sources... :)\n\nThe reason is easy to find: nobody cared enough about this feature to \nimplement it.\n\nJust tell me if you want to do it, I'll provide you with the necessary \ndetails.\n\nCiao,\nDscho\n"},{"id":"78500","messageId":"alpine.DEB.1.00.0806031452450.13507@racer.site.net","threadId":"13778","inReplyTo":"vpq8wxmsl6q.fsf@bauges.imag.fr","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-03T13:52:56Z","receivedAt":"2008-06-03T13:52:56Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 3 Jun 2008, Matthieu Moy wrote:\n\n> Victor Bogado da Silva Lins <victor@bogado.net> writes:\n> \n> > Well, that's about it, I need to rename my remotes. Mainly to move the\n> > origin to another repository and I miss the feature. Since many time\n> > there is a reason for a missing feature, I fought that maybe I should\n> > ask here, before nosing around the sources... :)\n> \n> I think editing .git/config to change the name of the remote would do\n> it.\n\nNo, that's not enough.\n\nCiao,\nDscho\n"},{"id":"78507","messageId":"1212503641.30731.11.camel@omicron.ep.petrobras.com.br","threadId":"13778","inReplyTo":"alpine.DEB.1.00.0806031449010.13507@racer.site.net","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Victor Bogado da Silva Lins","fromEmail":"victor@bogado.net","sentAt":"2008-06-03T14:34:01Z","receivedAt":"2008-06-03T14:34:01Z","isPatch":false,"sender":{"key":"victor@bogado.net","avatar":"https://gravatar.com/avatar/4ad1d046d4c1a5673a65aac199e2113f4e2d2ffe88d095cb3e17c1f20126cfac?d=mp&s=160"},"body":"I don't mind trying. :P Pointers would help me, I already found that the\ngit-remote source is on the file builtin-remote.c, bu I have not yet\nfound the main function of it.\n\nOn Tue, 2008-06-03 at 14:49 +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> On Tue, 3 Jun 2008, Victor Bogado da Silva Lins wrote:\n> \n> > Well, that's about it, I need to rename my remotes. Mainly to move the \n> > origin to another repository and I miss the feature. Since many time \n> > there is a reason for a missing feature, I fought that maybe I should \n> > ask here, before nosing around the sources... :)\n> \n> The reason is easy to find: nobody cared enough about this feature to \n> implement it.\n> \n> Just tell me if you want to do it, I'll provide you with the necessary \n> details.\n> \n> Ciao,\n> Dscho\n> \n"},{"id":"78538","messageId":"alpine.DEB.1.00.0806032102350.13507@racer.site.net","threadId":"13778","inReplyTo":"1212503641.30731.11.camel@omicron.ep.petrobras.com.br","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-03T20:12:13Z","receivedAt":"2008-06-03T20:12:13Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n[please do not top-post: it makes it very hard to follow the flow, \nespecially on a high-volume mailing list like this.]\n\nOn Tue, 3 Jun 2008, Victor Bogado da Silva Lins wrote:\n\n> On Tue, 2008-06-03 at 14:49 +0100, Johannes Schindelin wrote:\n> \n> > On Tue, 3 Jun 2008, Victor Bogado da Silva Lins wrote:\n> > \n> > > Well, that's about it, I need to rename my remotes. Mainly to move \n> > > the origin to another repository and I miss the feature. Since many \n> > > time there is a reason for a missing feature, I fought that maybe I \n> > > should ask here, before nosing around the sources... :)\n> > \n> > The reason is easy to find: nobody cared enough about this feature to \n> > implement it.\n> > \n> > Just tell me if you want to do it, I'll provide you with the necessary \n> > details.\n>\n> I don't mind trying. :P Pointers would help me, I already found that the\n> git-remote source is on the file builtin-remote.c, bu I have not yet\n> found the main function of it.\n\nThere is no main function, since it is a builtin.  The \"main\" function is \ncalled cmd_remote().\n\nYou might find inspiration with the rm() function, or might even be able \nto refactor the rm() function into an rm(), and an rm_or_rename() which\ndoes both rm() and rename() depending on a second parameter being NULL or \nnot.\n\nHth,\nDscho\n"},{"id":"78627","messageId":"1212591245.30731.17.camel@omicron.ep.petrobras.com.br","threadId":"13778","inReplyTo":"alpine.DEB.1.00.0806032102350.13507@racer.site.net","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Victor Bogado da Silva Lins","fromEmail":"victor@bogado.net","sentAt":"2008-06-04T14:54:05Z","receivedAt":"2008-06-04T14:54:05Z","isPatch":false,"sender":{"key":"victor@bogado.net","avatar":"https://gravatar.com/avatar/4ad1d046d4c1a5673a65aac199e2113f4e2d2ffe88d095cb3e17c1f20126cfac?d=mp&s=160"},"body":"On Tue, 2008-06-03 at 21:12 +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> [please do not top-post: it makes it very hard to follow the flow, \n> especially on a high-volume mailing list like this.]\n> \nsorry about that. :-/ \n\n> On Tue, 3 Jun 2008, Victor Bogado da Silva Lins wrote:\n> \n> > On Tue, 2008-06-03 at 14:49 +0100, Johannes Schindelin wrote:\n> > \n> > > On Tue, 3 Jun 2008, Victor Bogado da Silva Lins wrote:\n> > > \n> > > > Well, that's about it, I need to rename my remotes. Mainly to move \n> > > > the origin to another repository and I miss the feature. Since many \n> > > > time there is a reason for a missing feature, I fought that maybe I \n> > > > should ask here, before nosing around the sources... :)\n> > > \n> > > The reason is easy to find: nobody cared enough about this feature to \n> > > implement it.\n> > > \n> > > Just tell me if you want to do it, I'll provide you with the necessary \n> > > details.\n> >\n> > I don't mind trying. :P Pointers would help me, I already found that the\n> > git-remote source is on the file builtin-remote.c, bu I have not yet\n> > found the main function of it.\n> \n> There is no main function, since it is a builtin.  The \"main\" function is \n> called cmd_remote().\n> \n> You might find inspiration with the rm() function, or might even be able \n> to refactor the rm() function into an rm(), and an rm_or_rename() which\n> does both rm() and rename() depending on a second parameter being NULL or \n> not.\n\nI trying to refactor rm into rm_or_rename, but I stumbled into a\nproblem, how do I free a remote struct obtained with \"remote_get\"?\nAnother possibility would be another way to check if a remote already\nexists without allocating it in case it does. The need comes from\ntesting whether the destination name already exists, if it does exists I\nmust free the remote_get and bail_out. \n"},{"id":"78632","messageId":"alpine.DEB.1.00.0806041649270.13507@racer.site.net","threadId":"13778","inReplyTo":"1212591245.30731.17.camel@omicron.ep.petrobras.com.br","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-04T15:51:04Z","receivedAt":"2008-06-04T15:51:04Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:\n\n> I trying to refactor [in builtin-remote.c] rm into rm_or_rename, but I \n> stumbled into a problem, how do I free a remote struct obtained with \n> \"remote_get\"?\n\nAt the moment, there is no way to do that.\n\n> Another possibility would be another way to check if a remote already \n> exists without allocating it in case it does. The need comes from \n> testing whether the destination name already exists, if it does exists I \n> must free the remote_get and bail_out.\n\nI think in the first step, you can just _not_ free() it, just die().\n\nCiao,\nDscho\n"},{"id":"78687","messageId":"1212634394.13109.10.camel@mithrandir.bogado.net","threadId":"13778","inReplyTo":"alpine.DEB.1.00.0806041649270.13507@racer.site.net","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Victor Bogado da Silva Lins","fromEmail":"victor@bogado.net","sentAt":"2008-06-05T02:53:14Z","receivedAt":"2008-06-05T02:53:14Z","isPatch":false,"sender":{"key":"victor@bogado.net","avatar":"https://gravatar.com/avatar/4ad1d046d4c1a5673a65aac199e2113f4e2d2ffe88d095cb3e17c1f20126cfac?d=mp&s=160"},"body":"On Wed, 2008-06-04 at 16:51 +0100, Johannes Schindelin wrote:\n> Hi,\n> \n> On Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:\n> \n> > I trying to refactor [in builtin-remote.c] rm into rm_or_rename, but I \n> > stumbled into a problem, how do I free a remote struct obtained with \n> > \"remote_get\"?\n\nIt seems that git-remote thinks that remote_get will return NULL if\nthere is no such remote, but in fact it does not do this, it always\nalloc a new remote struct and returns that newly allocated. This makes\nthe check useless. In fact that check always succeed, and if you feed a\nnon-existent remote name, the remote-rm will fail later when it tries to\nremove a non-existent configuration.\n\nThe problem now is, how to reliably check if a remote exists or not. The\nobvious exit is checking if the git configuration has the appropriated\nkey, but I was not able to find out how, the internal git api have no\ndocumentation :P. Is there a simple way to check the existence of a key\nin the git configuration? \n"},{"id":"78696","messageId":"alpine.DEB.1.00.0806050529350.21190@racer","threadId":"13778","inReplyTo":"1212634394.13109.10.camel@mithrandir.bogado.net","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-05T04:30:41Z","receivedAt":"2008-06-05T04:30:41Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:\n\n> On Wed, 2008-06-04 at 16:51 +0100, Johannes Schindelin wrote:\n>\n> > On Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:\n> > \n> > > I trying to refactor [in builtin-remote.c] rm into rm_or_rename, but \n> > > I stumbled into a problem, how do I free a remote struct obtained \n> > > with \"remote_get\"?\n> \n> It seems that git-remote thinks that remote_get will return NULL if\n> there is no such remote, but in fact it does not do this, it always\n> alloc a new remote struct and returns that newly allocated.\n\n>From remote.c, remote_get(), line 601--602 in my checkout:\n\n        if (!ret->url)\n                return NULL;\n\nHth,\nDscho\n"},{"id":"78730","messageId":"1666.78.153.224.34.1212656107.squirrel@mail.kergonna.fr","threadId":"13778","inReplyTo":"alpine.DEB.1.00.0806050529350.21190@racer","subject":"Re: git remote rename, why dosen't it exists?","fromName":"Vincent Kergonna","fromEmail":"git@kergonna.fr","sentAt":"2008-06-05T08:55:07Z","receivedAt":"2008-06-05T08:55:07Z","isPatch":false,"sender":{"key":"git@kergonna.fr","avatar":null},"body":"> Hi,\n>\n> On Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:\n>\n>> On Wed, 2008-06-04 at 16:51 +0100, Johannes Schindelin wrote:\n>>\n>> > On Wed, 4 Jun 2008, Victor Bogado da Silva Lins wrote:\n>> >\n>> > > I trying to refactor [in builtin-remote.c] rm into rm_or_rename, but\n>> > > I stumbled into a problem, how do I free a remote struct obtained\n>> > > with \"remote_get\"?\n>>\n>> It seems that git-remote thinks that remote_get will return NULL if\n>> there is no such remote, but in fact it does not do this, it always\n>> alloc a new remote struct and returns that newly allocated.\n>\n> From remote.c, remote_get(), line 601--602 in my checkout:\n>\n>         if (!ret->url)\n>                 return NULL;\n>\n\nIn fact, I think Victor is right. If you do a simple test (assuming you\ndon't have a remote named foo):\n\nvincent:git$ git remote rm foo\nerror: Could not remove config section 'remote.foo'\n\nYou notice that it is trying to remove the configuration section for this\nremote. We have hit the line 372 of builtin-remote.c:\n\nif (git_config_rename_section(buf.buf, NULL) < 1)\n    return error(\"Could not remove config section '%s'\", buf.buf);\n\ninstead of exiting at line 364:\n\nif (!remote)\n    die(\"No such remote: %s\", argv[1]);\n\n\n-- \nVincent\n"}]}