Commit 491cecfe by Ben Straub

Add reflog parameters to git_push_update_tips

parent 0adb0606
......@@ -103,10 +103,16 @@ GIT_EXTERN(int) git_push_add_refspec(git_push *push, const char *refspec);
* Update remote tips after a push
*
* @param push The push object
* @param signature The identity to use when updating reflogs
* @param reflog_message The message to insert into the reflogs. If NULL, the
* default is "update by push".
*
* @return 0 or an error code
*/
GIT_EXTERN(int) git_push_update_tips(git_push *push);
GIT_EXTERN(int) git_push_update_tips(
git_push *push,
const git_signature *signature,
const char *reflog_message);
/**
* Actually push all given refspecs
......
......@@ -194,7 +194,10 @@ int git_push_add_refspec(git_push *push, const char *refspec)
return 0;
}
int git_push_update_tips(git_push *push)
int git_push_update_tips(
git_push *push,
const git_signature *signature,
const char *reflog_message)
{
git_buf remote_ref_name = GIT_BUF_INIT;
size_t i, j;
......@@ -241,7 +244,9 @@ int git_push_update_tips(git_push *push)
giterr_clear();
else
goto on_error;
} else if ((error = git_reference_create(NULL, push->remote->repo, git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, NULL, NULL)) < 0)
} else if ((error = git_reference_create(NULL, push->remote->repo,
git_buf_cstr(&remote_ref_name), &push_spec->loid, 1, signature,
reflog_message ? reflog_message : "update by push")) < 0)
goto on_error;
}
......
......@@ -414,11 +414,13 @@ static void do_push(
git_push_options opts = GIT_PUSH_OPTIONS_INIT;
size_t i;
int pack_progress_calls = 0, transfer_progress_calls = 0;
git_signature *pusher;
if (_remote) {
/* Auto-detect the number of threads to use */
opts.pb_parallelism = 0;
cl_git_pass(git_signature_now(&pusher, "Foo Bar", "foo@example.com"));
cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH));
cl_git_pass(git_push_new(&push, _remote));
......@@ -455,13 +457,15 @@ static void do_push(
verify_refs(_remote, expected_refs, expected_refs_len);
cl_git_pass(git_push_update_tips(push));
cl_git_pass(git_push_update_tips(push, pusher, "test push"));
verify_tracking_branches(_remote, expected_refs, expected_refs_len);
git_push_free(push);
git_remote_disconnect(_remote);
git_signature_free(pusher);
}
}
/* Call push_finish() without ever calling git_push_add_refspec() */
......@@ -528,6 +532,9 @@ void test_online_push__b5_cancel(void)
void test_online_push__multi(void)
{
git_reflog *log;
const git_reflog_entry *entry;
const char *specs[] = {
"refs/heads/b1:refs/heads/b1",
"refs/heads/b2:refs/heads/b2",
......@@ -552,6 +559,13 @@ void test_online_push__multi(void)
do_push(specs, ARRAY_SIZE(specs),
exp_stats, ARRAY_SIZE(exp_stats),
exp_refs, ARRAY_SIZE(exp_refs), 0, 1);
cl_git_pass(git_reflog_read(&log, _repo, "refs/remotes/test/b1"));
entry = git_reflog_entry_byindex(log, 0);
cl_assert_equal_s("test push", git_reflog_entry_message(entry));
cl_assert_equal_s("foo@example.com", git_reflog_entry_committer(entry)->email);
git_reflog_free(log);
}
void test_online_push__implicit_tgt(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment