{"thread":{"id":"12117","subject":"[PATCH] Validate nicknames of remote branches to prohibit confusing ones","startedAt":"2008-02-15T19:14:18Z","lastAt":"2008-02-16T08:08:37Z","messageCount":4,"participants":["Daniel Barkalow","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"68833","messageId":"alpine.LNX.1.00.0802151412390.13593@iabervon.org","threadId":"12117","inReplyTo":null,"subject":"[PATCH] Validate nicknames of remote branches to prohibit confusing ones","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-15T19:14:18Z","receivedAt":"2008-02-15T19:14:18Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"The original problem was that the parsers for configuration files were\ngetting confused by seeing as nicknames remotes that involved\ndirectory-changing characters. In particular, the branches config file\nfor \"..\" was particularly mystifying on platforms that can open\ndirectories and read odd data from them.\n\nThe validation function was written by Junio Hamano (with a typo\ncorrected).\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\nI was sort of expecting you to just put this in yourself, but since you \nhaven't, I wrote it up as an actual patch and fixed the polarity of the \ntest for slashes.\n\n remote.c |   12 +++++++++++-\n 1 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex 20abbc0..6b56473 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -343,6 +343,16 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)\n \treturn rs;\n }\n \n+static int valid_remote_nick(const char *name)\n+{\n+\tif (!name[0] || /* not empty */\n+\t    (name[0] == '.' && /* not \".\" */\n+\t     (!name[1] || /* not \"..\" */\n+\t      (name[1] == '.' && !name[2]))))\n+\t\treturn 0;\n+\treturn !strchr(name, '/'); /* no slash */\n+}\n+\n struct remote *remote_get(const char *name)\n {\n \tstruct remote *ret;\n@@ -351,7 +361,7 @@ struct remote *remote_get(const char *name)\n \tif (!name)\n \t\tname = default_remote_name;\n \tret = make_remote(name, 0);\n-\tif (name[0] != '/') {\n+\tif (valid_remote_nick(name)) {\n \t\tif (!ret->url)\n \t\t\tread_remotes_file(ret);\n \t\tif (!ret->url)\n-- \n1.5.4\n"},{"id":"68848","messageId":"7vskztg8rr.fsf@gitster.siamese.dyndns.org","threadId":"12117","inReplyTo":"alpine.LNX.1.00.0802151412390.13593@iabervon.org","subject":"Re: [PATCH] Validate nicknames of remote branches to prohibit confusing ones","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-15T22:22:16Z","receivedAt":"2008-02-15T22:22:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> The original problem was that the parsers for configuration files were\n> getting confused by seeing as nicknames remotes that involved\n> directory-changing characters. In particular, the branches config file\n> for \"..\" was particularly mystifying on platforms that can open\n> directories and read odd data from them.\n>\n> The validation function was written by Junio Hamano (with a typo\n> corrected).\n>\n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> ---\n> I was sort of expecting you to just put this in yourself, but since you \n> haven't, I wrote it up as an actual patch and fixed the polarity of the \n> test for slashes.\n\nThanks.  I am bogged down in day-job these days and have been\ndown-sick for the past 36 hours.\n"},{"id":"68859","messageId":"alpine.LNX.1.00.0802152209560.13593@iabervon.org","threadId":"12117","inReplyTo":"7vskztg8rr.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Validate nicknames of remote branches to prohibit confusing ones","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-02-16T03:11:38Z","receivedAt":"2008-02-16T03:11:38Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 15 Feb 2008, Junio C Hamano wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > The original problem was that the parsers for configuration files were\n> > getting confused by seeing as nicknames remotes that involved\n> > directory-changing characters. In particular, the branches config file\n> > for \"..\" was particularly mystifying on platforms that can open\n> > directories and read odd data from them.\n> >\n> > The validation function was written by Junio Hamano (with a typo\n> > corrected).\n> >\n> > Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> > ---\n> > I was sort of expecting you to just put this in yourself, but since you \n> > haven't, I wrote it up as an actual patch and fixed the polarity of the \n> > test for slashes.\n> \n> Thanks.  I am bogged down in day-job these days and have been\n> down-sick for the past 36 hours.\n\nNo problem. It's an easy enough patch, and the test suite found the bug in \nthe original version. I just wanted to make sure it didn't get forgotten \non account of never getting a patch emailled to the list.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"68884","messageId":"7v1w7dcohm.fsf@gitster.siamese.dyndns.org","threadId":"12117","inReplyTo":"alpine.LNX.1.00.0802152209560.13593@iabervon.org","subject":"Re: [PATCH] Validate nicknames of remote branches to prohibit confusing ones","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-16T08:08:37Z","receivedAt":"2008-02-16T08:08:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> On Fri, 15 Feb 2008, Junio C Hamano wrote:\n>\n>> Daniel Barkalow <barkalow@iabervon.org> writes:\n>> ...\n>> > I was sort of expecting you to just put this in yourself, but since you \n>> > haven't, I wrote it up as an actual patch and fixed the polarity of the \n>> > test for slashes.\n>> \n>> Thanks.  I am bogged down in day-job these days and have been\n>> down-sick for the past 36 hours.\n>\n> No problem. It's an easy enough patch, and the test suite found the bug in \n> the original version. I just wanted to make sure it didn't get forgotten \n> on account of never getting a patch emailled to the list.\n\nActually I have been slowly trying to give up on being in the\nbusiness of tying up loose ends left by everybody.  I used to\ntouch-up and finish obvious loose ends and add tests myself to\npatches from many people, and I still try to do so when able,\nbut as contributor base gets larger, doing so to all incoming\npatches is starting to become unfeasible, and it is not quite\nfair to me (and my wife ;-)).\n\nSo in that sense, yes it was getting forgotten, waiting for a\n\"this is the final revision, apply it\" message from you.\n"}]}