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
a1710a28
Commit
a1710a28
authored
Jan 29, 2014
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhance testing of signature parameters
parent
a1b07dca
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
13 deletions
+51
-13
src/clone.c
+1
-1
src/refs.c
+2
-1
tests/clone/nonetwork.c
+10
-4
tests/refs/branches/create.c
+11
-1
tests/refs/branches/move.c
+11
-2
tests/refs/rename.c
+6
-1
tests/repo/head.c
+10
-3
No files found.
src/clone.c
View file @
a1710a28
...
...
@@ -246,7 +246,7 @@ static int update_head_to_remote(
signature
,
reflog_message
);
}
else
{
error
=
git_repository_set_head_detached
(
repo
,
&
head_info
.
remote_head_oid
,
NULL
,
reflog_message
);
repo
,
&
head_info
.
remote_head_oid
,
signature
,
reflog_message
);
}
cleanup:
...
...
src/refs.c
View file @
a1710a28
...
...
@@ -574,7 +574,8 @@ int git_reference_rename(
error
=
reference__rename
(
out
,
ref
,
new_name
,
force
,
who
,
log_message
);
git_signature_free
(
who
);
if
(
!
signature
)
git_signature_free
(
who
);
return
error
;
}
...
...
tests/clone/nonetwork.c
View file @
a1710a28
...
...
@@ -24,6 +24,7 @@ void test_clone_nonetwork__initialize(void)
g_options
.
checkout_opts
=
dummy_opts
;
g_options
.
checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE_CREATE
;
g_options
.
remote_callbacks
=
dummy_callbacks
;
cl_git_pass
(
git_signature_now
(
&
g_options
.
signature
,
"Me"
,
"foo@example.com"
));
}
void
test_clone_nonetwork__cleanup
(
void
)
...
...
@@ -43,6 +44,7 @@ void test_clone_nonetwork__cleanup(void)
g_remote
=
NULL
;
}
git_signature_free
(
g_options
.
signature
);
cl_fixture_cleanup
(
"./foo"
);
}
...
...
@@ -213,6 +215,8 @@ void test_clone_nonetwork__can_detached_head(void)
git_object
*
obj
;
git_repository
*
cloned
;
git_reference
*
cloned_head
;
git_reflog
*
log
;
const
git_reflog_entry
*
entry
;
cl_git_pass
(
git_clone
(
&
g_repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo"
,
&
g_options
));
...
...
@@ -226,8 +230,13 @@ void test_clone_nonetwork__can_detached_head(void)
cl_git_pass
(
git_repository_head
(
&
cloned_head
,
cloned
));
cl_assert
(
!
git_oid_cmp
(
git_object_id
(
obj
),
git_reference_target
(
cloned_head
)));
cl_git_pass
(
git_reflog_read
(
&
log
,
cloned
,
"HEAD"
));
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry
)
->
email
);
git_object_free
(
obj
);
git_reference_free
(
cloned_head
);
git_reflog_free
(
log
);
git_repository_free
(
cloned
);
cl_fixture_cleanup
(
"./foo1"
);
...
...
@@ -252,12 +261,9 @@ static void assert_correct_reflog(const char *name)
void
test_clone_nonetwork__clone_updates_reflog_properly
(
void
)
{
cl_git_pass
(
git_signature_now
(
&
g_options
.
signature
,
"Me"
,
"foo@example.com"
));
cl_git_pass
(
git_clone
(
&
g_repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo"
,
&
g_options
));
assert_correct_reflog
(
"HEAD"
);
assert_correct_reflog
(
"refs/heads/master"
);
git_signature_free
(
g_options
.
signature
);
}
void
test_clone_nonetwork__clone_into_updates_reflog_properly
(
void
)
...
...
@@ -274,5 +280,5 @@ void test_clone_nonetwork__clone_into_updates_reflog_properly(void)
assert_correct_reflog
(
"refs/heads/master"
);
git_remote_free
(
remote
);
git_signature_free
(
g_options
.
signature
);
git_signature_free
(
sig
);
}
tests/refs/branches/create.c
View file @
a1710a28
...
...
@@ -78,22 +78,30 @@ void test_refs_branches_create__creation_creates_new_reflog(void)
{
git_reflog
*
log
;
const
git_reflog_entry
*
entry
;
git_signature
*
sig
;
cl_git_pass
(
git_signature_now
(
&
sig
,
"me"
,
"foo@example.com"
));
retrieve_known_commit
(
&
target
,
repo
);
cl_git_pass
(
git_branch_create
(
&
branch
,
repo
,
NEW_BRANCH_NAME
,
target
,
false
,
NULL
,
"create!"
));
cl_git_pass
(
git_branch_create
(
&
branch
,
repo
,
NEW_BRANCH_NAME
,
target
,
false
,
sig
,
"create!"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
"refs/heads/"
NEW_BRANCH_NAME
));
cl_assert_equal_i
(
1
,
git_reflog_entrycount
(
log
));
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"create!"
,
git_reflog_entry_message
(
entry
));
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry
)
->
email
);
git_reflog_free
(
log
);
git_signature_free
(
sig
);
}
void
test_refs_branches_create__default_reflog_message
(
void
)
{
git_reflog
*
log
;
const
git_reflog_entry
*
entry
;
git_signature
*
sig
;
cl_git_pass
(
git_signature_default
(
&
sig
,
repo
));
retrieve_known_commit
(
&
target
,
repo
);
cl_git_pass
(
git_branch_create
(
&
branch
,
repo
,
NEW_BRANCH_NAME
,
target
,
false
,
NULL
,
NULL
));
...
...
@@ -101,6 +109,8 @@ void test_refs_branches_create__default_reflog_message(void)
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"Branch: created"
,
git_reflog_entry_message
(
entry
));
cl_assert_equal_s
(
sig
->
email
,
git_reflog_entry_committer
(
entry
)
->
email
);
git_reflog_free
(
log
);
git_signature_free
(
sig
);
}
tests/refs/branches/move.c
View file @
a1710a28
...
...
@@ -193,17 +193,22 @@ void test_refs_branches_move__updates_the_reflog(void)
git_reference
*
new_branch
;
git_reflog
*
log
;
const
git_reflog_entry
*
entry
;
git_signature
*
sig
;
cl_git_pass
(
git_signature_now
(
&
sig
,
"me"
,
"foo@example.com"
));
cl_git_pass
(
git_reference_lookup
(
&
branch
,
repo
,
"refs/heads/master"
));
cl_git_pass
(
git_branch_move
(
&
new_branch
,
branch
,
"master2"
,
0
,
NULL
,
"message"
));
cl_git_pass
(
git_branch_move
(
&
new_branch
,
branch
,
"master2"
,
0
,
sig
,
"message"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
git_reference_name
(
new_branch
)));
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"message"
,
git_reflog_entry_message
(
entry
));
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry
)
->
email
);
git_reference_free
(
branch
);
git_reference_free
(
new_branch
);
git_reflog_free
(
log
);
git_signature_free
(
sig
);
}
void
test_refs_branches_move__default_reflog_message
(
void
)
...
...
@@ -212,6 +217,9 @@ void test_refs_branches_move__default_reflog_message(void)
git_reference
*
new_branch
;
git_reflog
*
log
;
const
git_reflog_entry
*
entry
;
git_signature
*
sig
;
cl_git_pass
(
git_signature_default
(
&
sig
,
repo
));
cl_git_pass
(
git_reference_lookup
(
&
branch
,
repo
,
"refs/heads/master"
));
cl_git_pass
(
git_branch_move
(
&
new_branch
,
branch
,
"master2"
,
0
,
NULL
,
NULL
));
...
...
@@ -220,9 +228,10 @@ void test_refs_branches_move__default_reflog_message(void)
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"Branch: renamed refs/heads/master to refs/heads/master2"
,
git_reflog_entry_message
(
entry
));
cl_assert_equal_s
(
sig
->
email
,
git_reflog_entry_committer
(
entry
)
->
email
);
git_reference_free
(
branch
);
git_reference_free
(
new_branch
);
git_reflog_free
(
log
);
git_signature_free
(
sig
);
}
tests/refs/rename.c
View file @
a1710a28
...
...
@@ -371,15 +371,20 @@ void test_refs_rename__writes_to_reflog(void)
git_reference
*
ref
,
*
new_ref
;
git_reflog
*
log
;
const
git_reflog_entry
*
entry
;
git_signature
*
sig
;
cl_git_pass
(
git_signature_now
(
&
sig
,
"me"
,
"foo@example.com"
));
cl_git_pass
(
git_reference_lookup
(
&
ref
,
g_repo
,
ref_master_name
));
cl_git_pass
(
git_reference_rename
(
&
new_ref
,
ref
,
ref_one_name_new
,
false
,
NULL
,
"message"
));
sig
,
"message"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
g_repo
,
git_reference_name
(
new_ref
)));
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"message"
,
git_reflog_entry_message
(
entry
));
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry
)
->
email
);
git_reflog_free
(
log
);
git_reference_free
(
ref
);
git_reference_free
(
new_ref
);
git_signature_free
(
sig
);
}
tests/repo/head.c
View file @
a1710a28
...
...
@@ -200,11 +200,14 @@ void test_repo_head__setting_head_updates_reflog(void)
git_reflog
*
log
;
const
git_reflog_entry
*
entry1
,
*
entry2
,
*
entry3
;
git_object
*
tag
;
git_signature
*
sig
;
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/haacked"
,
NULL
,
"message1"
));
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/unborn"
,
NULL
,
"message2"
));
cl_git_pass
(
git_signature_now
(
&
sig
,
"me"
,
"foo@example.com"
));
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/haacked"
,
sig
,
"message1"
));
cl_git_pass
(
git_repository_set_head
(
repo
,
"refs/heads/unborn"
,
sig
,
"message2"
));
cl_git_pass
(
git_revparse_single
(
&
tag
,
repo
,
"tags/test"
));
cl_git_pass
(
git_repository_set_head_detached
(
repo
,
git_object_id
(
tag
),
NULL
,
"message3"
));
cl_git_pass
(
git_repository_set_head_detached
(
repo
,
git_object_id
(
tag
),
sig
,
"message3"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
"HEAD"
));
entry1
=
git_reflog_entry_byindex
(
log
,
2
);
...
...
@@ -213,9 +216,13 @@ void test_repo_head__setting_head_updates_reflog(void)
cl_assert_equal_s
(
"message1"
,
git_reflog_entry_message
(
entry1
));
cl_assert_equal_s
(
"message2"
,
git_reflog_entry_message
(
entry2
));
cl_assert_equal_s
(
"message3"
,
git_reflog_entry_message
(
entry3
));
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry1
)
->
email
);
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry2
)
->
email
);
cl_assert_equal_s
(
"foo@example.com"
,
git_reflog_entry_committer
(
entry3
)
->
email
);
git_reflog_free
(
log
);
git_object_free
(
tag
);
git_signature_free
(
sig
);
}
void
test_repo_head__setting_creates_head_ref
(
void
)
...
...
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