Skip to content

Commit c82efaf

Browse files
drafnelgitster
authored andcommitted
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 <[email protected]> Acked-by: Daniel Barkalow <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4e6d4bc commit c82efaf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

remote.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,14 @@ static int handle_config(const char *key, const char *value, void *cb)
342342
if (prefixcmp(key, "remote."))
343343
return 0;
344344
name = key + 7;
345+
if (*name == '/') {
346+
warning("Config remote shorthand cannot begin with '/': %s",
347+
name);
348+
return 0;
349+
}
345350
subkey = strrchr(name, '.');
346351
if (!subkey)
347352
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-
}
352353
remote = make_remote(name, subkey - name);
353354
if (!strcmp(subkey, ".mirror"))
354355
remote->mirror = git_config_bool(key, value);

0 commit comments

Comments
 (0)