diff options
author | Ben Straub <bs@github.com> | 2014-01-28 10:44:33 -0800 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2014-01-30 15:52:13 -0800 |
commit | 540c1809f40c1bb3cf08627a85921309852fa963 (patch) | |
tree | 09b2925d0733e0033768dff846ecf22bf5a19e49 | |
parent | 48110f67e4a21caac1b8157d8239d16cd9781e51 (diff) | |
download | libgit2-540c1809f40c1bb3cf08627a85921309852fa963.tar.gz |
Add reflog parameters to git_branch_move
-rw-r--r-- | include/git2/branch.h | 8 | ||||
-rw-r--r-- | src/branch.c | 4 | ||||
-rw-r--r-- | tests/refs/branches/move.c | 26 |
3 files changed, 23 insertions, 15 deletions
diff --git a/include/git2/branch.h b/include/git2/branch.h index 28ca6b23..e653077d 100644 --- a/include/git2/branch.h +++ b/include/git2/branch.h @@ -121,13 +121,19 @@ GIT_EXTERN(void) git_branch_iterator_free(git_branch_iterator *iter); * * @param force Overwrite existing branch. * + * @param signature The identity that will used to populate the reflog entry + * + * @param log_message The one line long message to be appended to the reflog + * * @return 0 on success, GIT_EINVALIDSPEC or an error code. */ GIT_EXTERN(int) git_branch_move( git_reference **out, git_reference *branch, const char *new_branch_name, - int force); + int force, + const git_signature *signature, + const char *log_message); /** * Lookup a branch by its name in a repository. diff --git a/src/branch.c b/src/branch.c index 531101f8..4658d3bd 100644 --- a/src/branch.c +++ b/src/branch.c @@ -190,7 +190,9 @@ int git_branch_move( git_reference **out, git_reference *branch, const char *new_branch_name, - int force) + int force, + const git_signature *signature, + const char *log_message) { git_buf new_reference_name = GIT_BUF_INIT, old_config_section = GIT_BUF_INIT, diff --git a/tests/refs/branches/move.c b/tests/refs/branches/move.c index 9d233de1..bea93b9b 100644 --- a/tests/refs/branches/move.c +++ b/tests/refs/branches/move.c @@ -22,7 +22,7 @@ void test_refs_branches_move__can_move_a_local_branch(void) cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); - cl_git_pass(git_branch_move(&new_ref, original_ref, NEW_BRANCH_NAME, 0)); + cl_git_pass(git_branch_move(&new_ref, original_ref, NEW_BRANCH_NAME, 0, NULL, NULL)); cl_assert_equal_s(GIT_REFS_HEADS_DIR NEW_BRANCH_NAME, git_reference_name(new_ref)); git_reference_free(original_ref); @@ -36,11 +36,11 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_different_namespace(v cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ - cl_git_pass(git_branch_move(&new_ref, original_ref, "somewhere/" NEW_BRANCH_NAME, 0)); + cl_git_pass(git_branch_move(&new_ref, original_ref, "somewhere/" NEW_BRANCH_NAME, 0, NULL, NULL)); git_reference_free(original_ref); /* Upward */ - cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); + cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0, NULL, NULL)); git_reference_free(new_ref); git_reference_free(newer_ref); @@ -53,11 +53,11 @@ void test_refs_branches_move__can_move_a_local_branch_to_a_partially_colliding_n cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); /* Downward */ - cl_git_pass(git_branch_move(&new_ref, original_ref, "br2/" NEW_BRANCH_NAME, 0)); + cl_git_pass(git_branch_move(&new_ref, original_ref, "br2/" NEW_BRANCH_NAME, 0, NULL, NULL)); git_reference_free(original_ref); /* Upward */ - cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0)); + cl_git_pass(git_branch_move(&newer_ref, new_ref, "br2", 0, NULL, NULL)); git_reference_free(new_ref); git_reference_free(newer_ref); @@ -81,7 +81,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); cl_assert_equal_i(GIT_EEXISTS, - git_branch_move(&new_ref, original_ref, "master", 0)); + git_branch_move(&new_ref, original_ref, "master", 0, NULL, NULL)); cl_assert(giterr_last()->message != NULL); cl_git_pass(git_config_get_entry(&ce, config, "branch.master.remote")); @@ -91,7 +91,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_assert_equal_i(GIT_EEXISTS, - git_branch_move(&new_ref, original_ref, "cannot-fetch", 0)); + git_branch_move(&new_ref, original_ref, "cannot-fetch", 0, NULL, NULL)); cl_assert(giterr_last()->message != NULL); cl_git_pass(git_config_get_entry(&ce, config, "branch.master.remote")); @@ -103,7 +103,7 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/track-local")); cl_assert_equal_i(GIT_EEXISTS, - git_branch_move(&new_ref, original_ref, "master", 0)); + git_branch_move(&new_ref, original_ref, "master", 0, NULL, NULL)); cl_assert(giterr_last()->message != NULL); cl_git_pass(git_config_get_entry(&ce, config, "branch.master.remote")); @@ -122,7 +122,7 @@ void test_refs_branches_move__moving_a_branch_with_an_invalid_name_returns_EINVA cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); - cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_move(&new_ref, original_ref, "Inv@{id", 0)); + cl_assert_equal_i(GIT_EINVALIDSPEC, git_branch_move(&new_ref, original_ref, "Inv@{id", 0, NULL, NULL)); git_reference_free(original_ref); } @@ -132,7 +132,7 @@ void test_refs_branches_move__can_not_move_a_non_branch(void) git_reference *tag, *new_ref; cl_git_pass(git_reference_lookup(&tag, repo, "refs/tags/e90810b")); - cl_git_fail(git_branch_move(&new_ref, tag, NEW_BRANCH_NAME, 0)); + cl_git_fail(git_branch_move(&new_ref, tag, NEW_BRANCH_NAME, 0, NULL, NULL)); git_reference_free(tag); } @@ -143,7 +143,7 @@ void test_refs_branches_move__can_force_move_over_an_existing_branch(void) cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2")); - cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1)); + cl_git_pass(git_branch_move(&new_ref, original_ref, "master", 1, NULL, NULL)); git_reference_free(original_ref); git_reference_free(new_ref); @@ -161,7 +161,7 @@ void test_refs_branches_move__moving_a_branch_moves_related_configuration_data(v assert_config_entry_existence(repo, "branch.moved.remote", false); assert_config_entry_existence(repo, "branch.moved.merge", false); - cl_git_pass(git_branch_move(&new_branch, branch, "moved", 0)); + cl_git_pass(git_branch_move(&new_branch, branch, "moved", 0, NULL, NULL)); git_reference_free(branch); assert_config_entry_existence(repo, "branch.track-local.remote", false); @@ -178,7 +178,7 @@ void test_refs_branches_move__moving_the_branch_pointed_at_by_HEAD_updates_HEAD( git_reference *new_branch; cl_git_pass(git_reference_lookup(&branch, repo, "refs/heads/master")); - cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0)); + cl_git_pass(git_branch_move(&new_branch, branch, "master2", 0, NULL, NULL)); git_reference_free(branch); git_reference_free(new_branch); |