*
* 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);
done:
git_buf_free(&buf);
- return out_size;
+ return (int)out_size;
}
{
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)
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 */
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);
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);
}
*/
#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
*/
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);
}
/* 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);
}
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
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 */
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
GIT_STATUS_WT_NEW,
};
-static const size_t entry_count4 = 23;
+static const int entry_count4 = 23;
#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 *" */
GIT_STATUS_WT_NEW
};
-static const size_t filemode_count = 8;
+static const int filemode_count = 8;
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 */