{"thread":{"id":"15898","subject":"[PATCH] remote.c: correct the check for a leading '/' in a remote name","startedAt":"2008-10-14T20:30:21Z","lastAt":"2008-10-14T20:35:58Z","messageCount":2,"participants":["Brandon Casey","Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"93027","messageId":"J-KL1Cgc2b78Lced5uBNDhP0MHdg91do73K_0waicFQYbDZHjYkocw@cipher.nrlssc.navy.mil","threadId":"15898","inReplyTo":null,"subject":"[PATCH] remote.c: correct the check for a leading '/' in a remote name","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-10-14T20:30:21Z","receivedAt":"2008-10-14T20:30:21Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"This test is supposed to disallow remote entries in the config file of the\nform:\n\n   [remote \"/foobar\"]\n      ...\n\nThe leading slash in '/foobar' is not acceptable.\n\nInstead it was incorrectly testing that the subkey had no leading '/', which\nhad no effect since the subkey pointer was made to point at a '.' in the\npreceding lines.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nI stumbled across this code which looks like a mistake.\nThis patch seems like the correct fix.\n\n-brandon\n\n\n remote.c |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex d5efadd..8a04066 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -341,13 +341,14 @@ static int handle_config(const char *key, const char *value, void *cb)\n \tif (prefixcmp(key,  \"remote.\"))\n \t\treturn 0;\n \tname = key + 7;\n+\tif (*name == '/') {\n+\t\twarning(\"Config remote shorthand cannot begin with '/': %s\",\n+\t\t\tname);\n+\t\treturn 0;\n+\t}\n \tsubkey = strrchr(name, '.');\n \tif (!subkey)\n \t\treturn error(\"Config with no key for remote %s\", name);\n-\tif (*subkey == '/') {\n-\t\twarning(\"Config remote shorthand cannot begin with '/': %s\", name);\n-\t\treturn 0;\n-\t}\n \tremote = make_remote(name, subkey - name);\n \tif (!strcmp(subkey, \".mirror\"))\n \t\tremote->mirror = git_config_bool(key, value);\n-- \n1.6.0.2.468.gd5b83\n"},{"id":"93028","messageId":"alpine.LNX.1.00.0810141633321.19665@iabervon.org","threadId":"15898","inReplyTo":"J-KL1Cgc2b78Lced5uBNDhP0MHdg91do73K_0waicFQYbDZHjYkocw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH] remote.c: correct the check for a leading '/' in a remote name","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-10-14T20:35:58Z","receivedAt":"2008-10-14T20:35:58Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Tue, 14 Oct 2008, Brandon Casey wrote:\n\n> This test is supposed to disallow remote entries in the config file of the\n> form:\n> \n>    [remote \"/foobar\"]\n>       ...\n> \n> The leading slash in '/foobar' is not acceptable.\n> \n> Instead it was incorrectly testing that the subkey had no leading '/', which\n> had no effect since the subkey pointer was made to point at a '.' in the\n> preceding lines.\n> \n> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n\nGood catch; looks like I was checking for a mistake that nobody ever \nmakes, but it's still good to check.\n\nAcked-by: Daniel Barkalow <barkalow@iabervon.org>\n"}]}