Commit 96447d24f32052bf2755085eaab491e8f3ec9f56

Congyi Wu 2013-01-28T16:13:19

Fix 2 bugs in online::push tests. - Fix stack corruption introduced in 9bccf33c due to passing pointer to local variable _cred_acquire_called. - Fix strcmp in do_verify_push_status when expected or actual push_status is NULL

diff --git a/tests-clar/online/push.c b/tests-clar/online/push.c
index 3e2e334..8f92cdd 100644
--- a/tests-clar/online/push.c
+++ b/tests-clar/online/push.c
@@ -14,6 +14,7 @@ static char *_remote_user;
 static char *_remote_pass;
 
 static git_remote *_remote;
+static bool _cred_acquire_called;
 static record_callbacks_data _record_cbs_data = {{ 0 }};
 static git_remote_callbacks _record_cbs = RECORD_CALLBACKS_INIT(&_record_cbs_data);
 
@@ -79,7 +80,9 @@ static void do_verify_push_status(git_push *push, const push_status expected[], 
 	else
 		git_vector_foreach(&actual, i, iter)
 			if (strcmp(expected[i].ref, iter->ref) ||
-				(expected[i].msg && strcmp(expected[i].msg, iter->msg))) {
+				(expected[i].msg && !iter->msg) ||
+				(!expected[i].msg && iter->msg) ||
+				(expected[i].msg && iter->msg && strcmp(expected[i].msg, iter->msg))) {
 				failed = true;
 				break;
 			}
@@ -231,7 +234,7 @@ void test_online_push__initialize(void)
 	git_vector delete_specs = GIT_VECTOR_INIT;
 	size_t i;
 	char *curr_del_spec;
-	bool cred_acquire_called = false;
+	_cred_acquire_called = false;
 
 	_repo = cl_git_sandbox_init("push_src");
 
@@ -272,7 +275,7 @@ void test_online_push__initialize(void)
 	if (_remote_url) {
 		cl_git_pass(git_remote_create(&_remote, _repo, "test", _remote_url));
 
-		git_remote_set_cred_acquire_cb(_remote, cred_acquire_cb, &cred_acquire_called);
+		git_remote_set_cred_acquire_cb(_remote, cred_acquire_cb, &_cred_acquire_called);
 		record_callbacks_data_clear(&_record_cbs_data);
 		git_remote_set_callbacks(_remote, &_record_cbs);