Commit 3ad052218cd03fe58b254f878825e3f0fd4b3054

nulltoken 2013-02-05T16:52:56

Fix MSVC compilation warnings Fix #1308

diff --git a/src/branch.c b/src/branch.c
index 3959409..975a43d 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -348,7 +348,7 @@ int git_branch_tracking_name(
 	if (tracking_branch_name_out)
 		git_buf_copy_cstr(tracking_branch_name_out, buffer_size, &buf);
 
-	error = buf.size + 1;
+	error = (int)buf.size + 1;
 
 cleanup:
 	git_buf_free(&buf);
diff --git a/src/diff_output.c b/src/diff_output.c
index 4f1064b..c2c2591 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -1603,8 +1603,8 @@ int git_diff_patch_get_line_in_hunk(
 	if (line_origin) *line_origin = line->origin;
 	if (content) *content = line->ptr;
 	if (content_len) *content_len = line->len;
-	if (old_lineno) *old_lineno = line->oldno;
-	if (new_lineno) *new_lineno = line->newno;
+	if (old_lineno) *old_lineno = (int)line->oldno;
+	if (new_lineno) *new_lineno = (int)line->newno;
 
 	return 0;
 
diff --git a/src/diff_output.h b/src/diff_output.h
index ae1a491..0833556 100644
--- a/src/diff_output.h
+++ b/src/diff_output.h
@@ -42,7 +42,7 @@ typedef struct diff_patch_line diff_patch_line;
 struct diff_patch_line {
 	const char *ptr;
 	size_t len;
-	int lines, oldno, newno;
+	size_t lines, oldno, newno;
 	char origin;
 };
 
diff --git a/src/tree.c b/src/tree.c
index e05105a..59bd92a 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -355,7 +355,7 @@ size_t git_tree_entrycount(const git_tree *tree)
 unsigned int git_treebuilder_entrycount(git_treebuilder *bld)
 {
 	assert(bld);
-	return bld->entries.length;
+	return (int)bld->entries.length;
 }
 
 static int tree_error(const char *str, const char *path)
diff --git a/tests-clar/clone/empty.c b/tests-clar/clone/empty.c
index 4e53557..e611bc2 100644
--- a/tests-clar/clone/empty.c
+++ b/tests-clar/clone/empty.c
@@ -46,7 +46,7 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
 	cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned, local_name));
 
 	/* ...one can still retrieve the name of the remote tracking reference */
-	cl_assert_equal_i(strlen("refs/remotes/origin/master") + 1, 
+	cl_assert_equal_i((int)strlen("refs/remotes/origin/master") + 1U, 
 		git_branch_tracking_name(tracking_name, 1024, g_repo_cloned, local_name));
 }
 
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index affa761..18e90f9 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -251,13 +251,13 @@ static void check_single_patch_stats(
 	cl_git_pass(git_diff_get_patch(&patch, &delta, diff, 0));
 	cl_assert_equal_i(GIT_DELTA_MODIFIED, (int)delta->status);
 
-	cl_assert_equal_i(hunks, (int)git_diff_patch_num_hunks(patch));
+	cl_assert_equal_sz(hunks, git_diff_patch_num_hunks(patch));
 
 	cl_git_pass(
 		git_diff_patch_line_stats(NULL, &actual_adds, &actual_dels, patch));
 
-	cl_assert_equal_i(adds, actual_adds);
-	cl_assert_equal_i(dels, actual_dels);
+	cl_assert_equal_sz(adds, actual_adds);
+	cl_assert_equal_sz(dels, actual_dels);
 
 	git_diff_patch_free(patch);
 	git_diff_list_free(diff);
diff --git a/tests-clar/refs/branches/trackingname.c b/tests-clar/refs/branches/trackingname.c
index ea90583..5aee333 100644
--- a/tests-clar/refs/branches/trackingname.c
+++ b/tests-clar/refs/branches/trackingname.c
@@ -37,6 +37,6 @@ void test_refs_branches_trackingname__can_retrieve_the_local_tracking_reference_
 
 void test_refs_branches_trackingname__can_return_the_size_of_thelocal_tracking_reference_name_of_a_local_branch(void)
 {
-	cl_assert_equal_i(strlen("refs/heads/master") + 1,
+	cl_assert_equal_i((int)strlen("refs/heads/master") + 1,
 		git_branch_tracking_name(NULL, 0, repo, "refs/heads/track-local"));
 }