Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
540c1809
Commit
540c1809
authored
Jan 28, 2014
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reflog parameters to git_branch_move
parent
48110f67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
+23
-15
include/git2/branch.h
+7
-1
src/branch.c
+3
-1
tests/refs/branches/move.c
+13
-13
No files found.
include/git2/branch.h
View file @
540c1809
...
...
@@ -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.
...
...
src/branch.c
View file @
540c1809
...
...
@@ -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
,
...
...
tests/refs/branches/move.c
View file @
540c1809
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment