diff options
author | Russell Belfer <rb@github.com> | 2013-02-26 13:15:06 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-02-26 13:15:06 -0800 |
commit | 0d1b094b07d836a657ad9e458e04490d1e72d365 (patch) | |
tree | 418248c23ebf7705164460704412980de509ef5e /src/refs.c | |
parent | 3c42e4ef7428de18784e04c9cac18de3613144cb (diff) | |
download | libgit2-0d1b094b07d836a657ad9e458e04490d1e72d365.tar.gz |
Fix portability issues on Windows
The new tests were not taking core.filemode into account when
testing file modes after repo initialization. Fixed that and some
other Windows warnings that have crept in.
Diffstat (limited to 'src/refs.c')
-rw-r--r-- | src/refs.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/refs.c b/src/refs.c index cca3f3ec8..113cadad5 100644 --- a/src/refs.c +++ b/src/refs.c @@ -1599,7 +1599,8 @@ static int ensure_segment_validity(const char *name) { const char *current = name; char prev = '\0'; - int lock_len = strlen(GIT_FILELOCK_EXTENSION); + const int lock_len = (int)strlen(GIT_FILELOCK_EXTENSION); + int segment_len; if (*current == '.') return -1; /* Refname starts with "." */ @@ -1620,12 +1621,14 @@ static int ensure_segment_validity(const char *name) prev = *current; } + segment_len = (int)(current - name); + /* A refname component can not end with ".lock" */ - if (current - name >= lock_len && + if (segment_len >= lock_len && !memcmp(current - lock_len, GIT_FILELOCK_EXTENSION, lock_len)) return -1; - return (int)(current - name); + return segment_len; } static bool is_all_caps_and_underscore(const char *name, size_t len) @@ -1700,7 +1703,7 @@ int git_reference__normalize_name( /* No empty segment is allowed when not normalizing */ if (segment_len == 0 && !normalize) goto cleanup; - + if (current[segment_len] == '\0') break; |