summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2014-02-04 20:13:50 -0800
committerBen Straub <bs@github.com>2014-02-04 20:27:44 -0800
commit491cecfe8ce4c6fbee3357248c7b688b6e1aaab4 (patch)
tree05ce6c4474e668044a8c08225c960f274e58b097
parent0adb06065b944e755933e11ed9ac7ce544b55d33 (diff)
downloadlibgit2-491cecfe8ce4c6fbee3357248c7b688b6e1aaab4.tar.gz
Add reflog parameters to git_push_update_tips
-rw-r--r--include/git2/push.h8
-rw-r--r--src/push.c9
-rw-r--r--tests/online/push.c16
3 files changed, 29 insertions, 4 deletions
diff --git a/include/git2/push.h b/include/git2/push.h
index 12f0e7f2c..c98c6d96e 100644
--- a/include/git2/push.h
+++ b/include/git2/push.h
@@ -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
diff --git a/src/push.c b/src/push.c
index d39a27182..c2947808e 100644
--- a/src/push.c
+++ b/src/push.c
@@ -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;
}
diff --git a/tests/online/push.c b/tests/online/push.c
index 8efe21e0e..c0ff2f22c 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -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)