remote.c: correct the check for a leading '/' in a remote name
This test is supposed to disallow remote entries in the config file of the form: [remote "/foobar"] ... The leading slash in '/foobar' is not acceptable. Instead it was incorrectly testing that the subkey had no leading '/', which had no effect since the subkey pointer was made to point at a '.' in the preceding lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Casey committed
Oct 14, 2008 at 15:30 UTC
c82efafcfa741cdddbc68379c1905953f58ef21d
1 file changed
+5
-4
remote.c
+5
-4
@@ -342,13 +342,14 @@ static int handle_config(const char *key, const char *value, void *cb)
342
if (prefixcmp(key, "remote."))
343
return 0;
344
name = key + 7;
345
+ if (*name == '/') {
346
+ warning("Config remote shorthand cannot begin with '/': %s",
347
+ name);
348
+ return 0;
349
+ }
350
subkey = strrchr(name, '.');
351
if (!subkey)
352
return error("Config with no key for remote %s", name);
348
- if (*subkey == '/') {
349
- warning("Config remote shorthand cannot begin with '/': %s", name);
350
- return 0;
351
- }
353
remote = make_remote(name, subkey - name);
354
if (!strcmp(subkey, ".mirror"))
355
remote->mirror = git_config_bool(key, value);