diff options
author | Russell Belfer <rb@github.com> | 2013-02-11 14:35:41 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-02-11 14:35:41 -0800 |
commit | 40a605104c2060c2bc5a08dfb62cafe473baeb21 (patch) | |
tree | 90c9ae1b89aea407c34f54ad3a878f2425d186ab /src/refs.c | |
parent | 390a3c81410a219b13aa6f333949c803524c8bd2 (diff) | |
parent | 2bca5b679b9e1f7f7e5cfafa75a6a94549875197 (diff) | |
download | libgit2-40a605104c2060c2bc5a08dfb62cafe473baeb21.tar.gz |
Merge pull request #1324 from nulltoken/topic/remote_isvalidname
Topic/remote isvalidname
Diffstat (limited to 'src/refs.c')
-rw-r--r-- | src/refs.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/refs.c b/src/refs.c index e75f51001..7dabfefae 100644 --- a/src/refs.c +++ b/src/refs.c @@ -1599,6 +1599,7 @@ static int ensure_segment_validity(const char *name) { const char *current = name; char prev = '\0'; + int lock_len = strlen(GIT_FILELOCK_EXTENSION); if (*current == '.') return -1; /* Refname starts with "." */ @@ -1619,6 +1620,11 @@ static int ensure_segment_validity(const char *name) prev = *current; } + /* A refname component can not end with ".lock" */ + if (current - name >= lock_len && + !memcmp(current - lock_len, GIT_FILELOCK_EXTENSION, lock_len)) + return -1; + return (int)(current - name); } @@ -1691,11 +1697,10 @@ int git_reference__normalize_name( segments_count++; } - /* This means that there's a leading slash in the refname */ - if (segment_len == 0 && segments_count == 0) { + /* No empty segment is allowed when not normalizing */ + if (segment_len == 0 && !normalize) goto cleanup; - } - + if (current[segment_len] == '\0') break; @@ -1714,10 +1719,6 @@ int git_reference__normalize_name( if (current[segment_len - 1] == '/') goto cleanup; - /* A refname can not end with ".lock" */ - if (!git__suffixcmp(name, GIT_FILELOCK_EXTENSION)) - goto cleanup; - if ((segments_count == 1 ) && !(flags & GIT_REF_FORMAT_ALLOW_ONELEVEL)) goto cleanup; |