summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-02-26 13:15:06 -0800
committerRussell Belfer <rb@github.com>2013-02-26 13:15:06 -0800
commit0d1b094b07d836a657ad9e458e04490d1e72d365 (patch)
tree418248c23ebf7705164460704412980de509ef5e /src
parent3c42e4ef7428de18784e04c9cac18de3613144cb (diff)
downloadlibgit2-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')
-rw-r--r--src/refs.c11
-rw-r--r--src/repository.c5
2 files changed, 11 insertions, 5 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;
diff --git a/src/repository.c b/src/repository.c
index 5279d8f63..e120c5836 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1043,8 +1043,11 @@ static int repo_init_structure(
static int mkdir_parent(git_buf *buf, uint32_t mode, bool skip2)
{
+ /* When making parent directories during repository initialization
+ * don't try to set gid or grant world write access
+ */
return git_futils_mkdir(
- buf->ptr, NULL, mode & ~(S_ISGID | S_IWOTH),
+ buf->ptr, NULL, mode & ~(S_ISGID | 0002),
GIT_MKDIR_PATH | GIT_MKDIR_VERIFY_DIR |
(skip2 ? GIT_MKDIR_SKIP_LAST2 : GIT_MKDIR_SKIP_LAST));
}