Fix warnings and merge issues on Win64
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
diff --git a/include/git2/repository.h b/include/git2/repository.h
index a986859..f520d54 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -466,6 +466,11 @@ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index
*
* Use this function to get the contents of this file. Don't forget to
* remove the file after you create the commit.
+ *
+ * @param buffer Buffer to write data into or NULL to just read required size
+ * @param len Length of buffer in bytes
+ * @param repo Repository to read prepared message from
+ * @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
*/
GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository *repo);
diff --git a/src/message.c b/src/message.c
index e6dedc9..791b694 100644
--- a/src/message.c
+++ b/src/message.c
@@ -82,5 +82,5 @@ int git_message_prettify(char *message_out, size_t buffer_size, const char *mess
done:
git_buf_free(&buf);
- return out_size;
+ return (int)out_size;
}
diff --git a/src/repository.c b/src/repository.c
index 8005797..bf19d07 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1328,39 +1328,27 @@ int git_repository_message(char *buffer, size_t len, git_repository *repo)
{
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
struct stat st;
- ssize_t size;
int error;
if (git_buf_joinpath(&path, repo->path_repository, MERGE_MSG_FILE) < 0)
return -1;
- error = p_stat(git_buf_cstr(&path), &st);
- if (error < 0) {
+ if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) {
if (errno == ENOENT)
error = GIT_ENOTFOUND;
-
- git_buf_free(&path);
- return error;
}
-
- if (buffer == NULL) {
- git_buf_free(&path);
- return (int)st.st_size;
+ else if (buffer != NULL) {
+ error = git_futils_readbuffer(&buf, git_buf_cstr(&path));
+ git_buf_copy_cstr(buffer, len, &buf);
}
- if (git_futils_readbuffer(&buf, git_buf_cstr(&path)) < 0)
- goto on_error;
-
- memcpy(buffer, git_buf_cstr(&buf), len);
- size = git_buf_len(&buf);
-
git_buf_free(&path);
git_buf_free(&buf);
- return size;
-on_error:
- git_buf_free(&path);
- return -1;
+ if (!error)
+ error = (int)st.st_size + 1; /* add 1 for NUL byte */
+
+ return error;
}
int git_repository_message_remove(git_repository *repo)
diff --git a/src/transports/http.c b/src/transports/http.c
index 85fec41..ce382c3 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -233,7 +233,7 @@ static int http_recv_cb(gitno_buffer *buf)
if (t->error < 0)
return t->error;
- return buf->offset - old_len;
+ return (int)(buf->offset - old_len);
}
/* Set up the gitno_buffer so calling gitno_recv() grabs data from the HTTP response */
diff --git a/src/win32/posix.h b/src/win32/posix.h
index def3a76..14caae4 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -19,14 +19,6 @@ GIT_INLINE(int) p_link(const char *old, const char *new)
return -1;
}
-GIT_INLINE(int) p_symlink(const char *old, const char *new)
-{
- GIT_UNUSED(old);
- GIT_UNUSED(new);
- errno = ENOSYS;
- return -1;
-}
-
GIT_INLINE(int) p_mkdir(const char *path, mode_t mode)
{
wchar_t* buf = gitwin_to_utf16(path);
diff --git a/tests-clar/checkout/checkout.c b/tests-clar/checkout/checkout.c
index d6b79b4..ba14194 100644
--- a/tests-clar/checkout/checkout.c
+++ b/tests-clar/checkout/checkout.c
@@ -33,7 +33,7 @@ static void test_file_contents(const char *path, const char *expectedcontents)
actuallen = p_read(fd, buffer, 1024);
cl_git_pass(p_close(fd));
- cl_assert_equal_i(actuallen, expectedlen);
+ cl_assert_equal_sz(actuallen, expectedlen);
cl_assert_equal_s(buffer, expectedcontents);
}
diff --git a/tests-clar/clar_libgit2.h b/tests-clar/clar_libgit2.h
index eab6c3d..b4ee74c 100644
--- a/tests-clar/clar_libgit2.h
+++ b/tests-clar/clar_libgit2.h
@@ -25,6 +25,8 @@
*/
#define cl_git_fail(expr) cl_must_fail(expr)
+#define cl_assert_equal_sz(sz1,sz2) cl_assert((sz1) == (sz2))
+
/*
* Some utility macros for building long strings
*/
diff --git a/tests-clar/core/buffer.c b/tests-clar/core/buffer.c
index b6274b0..972567e 100644
--- a/tests-clar/core/buffer.c
+++ b/tests-clar/core/buffer.c
@@ -665,7 +665,7 @@ static void assert_unescape(char *expected, char *to_unescape) {
cl_git_pass(git_buf_sets(&buf, to_unescape));
git_buf_unescape(&buf);
cl_assert_equal_s(expected, buf.ptr);
- cl_assert_equal_i(strlen(expected), buf.size);
+ cl_assert_equal_sz(strlen(expected), buf.size);
git_buf_free(&buf);
}
diff --git a/tests-clar/refs/list.c b/tests-clar/refs/list.c
index ac3cc00..f92bf48 100644
--- a/tests-clar/refs/list.c
+++ b/tests-clar/refs/list.c
@@ -36,7 +36,7 @@ void test_refs_list__all(void)
/* We have exactly 9 refs in total if we include the packed ones:
* there is a reference that exists both in the packfile and as
* loose, but we only list it once */
- cl_assert_equal_i(ref_list.count, 10);
+ cl_assert_equal_i((int)ref_list.count, 10);
git_strarray_free(&ref_list);
}
diff --git a/tests-clar/status/status_data.h b/tests-clar/status/status_data.h
index 043b830..85a7cd6 100644
--- a/tests-clar/status/status_data.h
+++ b/tests-clar/status/status_data.h
@@ -44,7 +44,7 @@ static const unsigned int entry_statuses0[] = {
GIT_STATUS_WT_NEW,
};
-static const size_t entry_count0 = 16;
+static const int entry_count0 = 16;
/* entries for a copy of tests/resources/status with all content
* deleted from the working directory
@@ -86,7 +86,7 @@ static const unsigned int entry_statuses2[] = {
GIT_STATUS_WT_DELETED,
};
-static const size_t entry_count2 = 15;
+static const int entry_count2 = 15;
/* entries for a copy of tests/resources/status with some mods */
@@ -140,7 +140,7 @@ static const unsigned int entry_statuses3[] = {
GIT_STATUS_WT_NEW,
};
-static const size_t entry_count3 = 22;
+static const int entry_count3 = 22;
/* entries for a copy of tests/resources/status with some mods
@@ -199,4 +199,4 @@ static const unsigned int entry_statuses4[] = {
GIT_STATUS_WT_NEW,
};
-static const size_t entry_count4 = 23;
+static const int entry_count4 = 23;
diff --git a/tests-clar/status/status_helpers.h b/tests-clar/status/status_helpers.h
index cffca66..3f9c1f5 100644
--- a/tests-clar/status/status_helpers.h
+++ b/tests-clar/status/status_helpers.h
@@ -2,12 +2,12 @@
#define INCLUDE_cl_status_helpers_h__
typedef struct {
- size_t wrong_status_flags_count;
- size_t wrong_sorted_path;
- size_t entry_count;
+ int wrong_status_flags_count;
+ int wrong_sorted_path;
+ int entry_count;
const unsigned int* expected_statuses;
const char** expected_paths;
- size_t expected_entry_count;
+ int expected_entry_count;
} status_entry_counts;
/* cb_status__normal takes payload of "status_entry_counts *" */
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index 2abf368..75975c9 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -683,7 +683,7 @@ static unsigned int filemode_statuses[] = {
GIT_STATUS_WT_NEW
};
-static const size_t filemode_count = 8;
+static const int filemode_count = 8;
void test_status_worktree__filemode_changes(void)
{
@@ -697,7 +697,7 @@ void test_status_worktree__filemode_changes(void)
if (cl_is_chmod_supported())
cl_git_pass(git_config_set_bool(cfg, "core.filemode", true));
else {
- unsigned int i;
+ int i;
cl_git_pass(git_config_set_bool(cfg, "core.filemode", false));
/* won't trust filesystem mode diffs, so these will appear unchanged */