Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2008-02-15 22:14:18 +0300
committerJunio C Hamano <gitster@pobox.com>2008-02-16 01:23:22 +0300
commitdf93e33c8bc8c79751a45d8005c6a92b18d4ba6d (patch)
tree465e998c4c34a36b8344b2e09152f65fa3220647 /remote.c
parent8ca496e97d100195c9015f4da8ddaad693e91961 (diff)
Validate nicknames of remote branches to prohibit confusing ones
The original problem was that the parsers for configuration files were getting confused by seeing as nicknames remotes that involved directory-changing characters. In particular, the branches config file for ".." was particularly mystifying on platforms that can open directories and read odd data from them. The validation function was written by Junio Hamano (with a typo corrected). Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/remote.c b/remote.c
index 20abbc07ac..6b56473f5b 100644
--- a/remote.c
+++ b/remote.c
@@ -343,6 +343,16 @@ struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
return rs;
}
+static int valid_remote_nick(const char *name)
+{
+ if (!name[0] || /* not empty */
+ (name[0] == '.' && /* not "." */
+ (!name[1] || /* not ".." */
+ (name[1] == '.' && !name[2]))))
+ return 0;
+ return !strchr(name, '/'); /* no slash */
+}
+
struct remote *remote_get(const char *name)
{
struct remote *ret;
@@ -351,7 +361,7 @@ struct remote *remote_get(const char *name)
if (!name)
name = default_remote_name;
ret = make_remote(name, 0);
- if (name[0] != '/') {
+ if (valid_remote_nick(name)) {
if (!ret->url)
read_remotes_file(ret);
if (!ret->url)