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
6ab68290
Commit
6ab68290
authored
Aug 09, 2012
by
Joshua Peek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse ref oids without trailing newline
parent
e4607392
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
10 deletions
+27
-10
src/refs.c
+6
-3
tests-clar/network/remotelocal.c
+2
-2
tests-clar/refs/branches/foreach.c
+2
-2
tests-clar/refs/foreachglob.c
+3
-3
tests-clar/refs/read.c
+12
-0
tests-clar/resources/testrepo.git/refs/heads/chomped
+2
-0
No files found.
src/refs.c
View file @
6ab68290
...
@@ -173,8 +173,8 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
...
@@ -173,8 +173,8 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
buffer
=
(
char
*
)
file_content
->
ptr
;
buffer
=
(
char
*
)
file_content
->
ptr
;
/* File format: 40 chars (OID)
+ newline
*/
/* File format: 40 chars (OID) */
if
(
git_buf_len
(
file_content
)
<
GIT_OID_HEXSZ
+
1
)
if
(
git_buf_len
(
file_content
)
<
GIT_OID_HEXSZ
)
goto
corrupt
;
goto
corrupt
;
if
(
git_oid_fromstr
(
oid
,
buffer
)
<
0
)
if
(
git_oid_fromstr
(
oid
,
buffer
)
<
0
)
...
@@ -184,7 +184,10 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
...
@@ -184,7 +184,10 @@ static int loose_parse_oid(git_oid *oid, git_buf *file_content)
if
(
*
buffer
==
'\r'
)
if
(
*
buffer
==
'\r'
)
buffer
++
;
buffer
++
;
if
(
*
buffer
!=
'\n'
)
if
(
*
buffer
==
'\n'
)
buffer
++
;
if
(
*
buffer
!=
'\0'
)
goto
corrupt
;
goto
corrupt
;
return
0
;
return
0
;
...
...
tests-clar/network/remotelocal.c
View file @
6ab68290
...
@@ -107,7 +107,7 @@ void test_network_remotelocal__retrieve_advertised_references(void)
...
@@ -107,7 +107,7 @@ void test_network_remotelocal__retrieve_advertised_references(void)
cl_git_pass
(
git_remote_ls
(
remote
,
&
count_ref__cb
,
&
how_many_refs
));
cl_git_pass
(
git_remote_ls
(
remote
,
&
count_ref__cb
,
&
how_many_refs
));
cl_assert_equal_i
(
how_many_refs
,
2
3
);
cl_assert_equal_i
(
how_many_refs
,
2
4
);
}
}
void
test_network_remotelocal__retrieve_advertised_references_from_spaced_repository
(
void
)
void
test_network_remotelocal__retrieve_advertised_references_from_spaced_repository
(
void
)
...
@@ -121,7 +121,7 @@ void test_network_remotelocal__retrieve_advertised_references_from_spaced_reposi
...
@@ -121,7 +121,7 @@ void test_network_remotelocal__retrieve_advertised_references_from_spaced_reposi
cl_git_pass
(
git_remote_ls
(
remote
,
&
count_ref__cb
,
&
how_many_refs
));
cl_git_pass
(
git_remote_ls
(
remote
,
&
count_ref__cb
,
&
how_many_refs
));
cl_assert_equal_i
(
how_many_refs
,
2
3
);
cl_assert_equal_i
(
how_many_refs
,
2
4
);
git_remote_free
(
remote
);
/* Disconnect from the "spaced repo" before the cleanup */
git_remote_free
(
remote
);
/* Disconnect from the "spaced repo" before the cleanup */
remote
=
NULL
;
remote
=
NULL
;
...
...
tests-clar/refs/branches/foreach.c
View file @
6ab68290
...
@@ -47,7 +47,7 @@ static void assert_retrieval(unsigned int flags, unsigned int expected_count)
...
@@ -47,7 +47,7 @@ static void assert_retrieval(unsigned int flags, unsigned int expected_count)
void
test_refs_branches_foreach__retrieve_all_branches
(
void
)
void
test_refs_branches_foreach__retrieve_all_branches
(
void
)
{
{
assert_retrieval
(
GIT_BRANCH_LOCAL
|
GIT_BRANCH_REMOTE
,
1
1
);
assert_retrieval
(
GIT_BRANCH_LOCAL
|
GIT_BRANCH_REMOTE
,
1
2
);
}
}
void
test_refs_branches_foreach__retrieve_remote_branches
(
void
)
void
test_refs_branches_foreach__retrieve_remote_branches
(
void
)
...
@@ -57,7 +57,7 @@ void test_refs_branches_foreach__retrieve_remote_branches(void)
...
@@ -57,7 +57,7 @@ void test_refs_branches_foreach__retrieve_remote_branches(void)
void
test_refs_branches_foreach__retrieve_local_branches
(
void
)
void
test_refs_branches_foreach__retrieve_local_branches
(
void
)
{
{
assert_retrieval
(
GIT_BRANCH_LOCAL
,
9
);
assert_retrieval
(
GIT_BRANCH_LOCAL
,
10
);
}
}
struct
expectations
{
struct
expectations
{
...
...
tests-clar/refs/foreachglob.c
View file @
6ab68290
...
@@ -45,8 +45,8 @@ static void assert_retrieval(const char *glob, unsigned int flags, int expected_
...
@@ -45,8 +45,8 @@ static void assert_retrieval(const char *glob, unsigned int flags, int expected_
void
test_refs_foreachglob__retrieve_all_refs
(
void
)
void
test_refs_foreachglob__retrieve_all_refs
(
void
)
{
{
/*
7
heads (including one packed head) + 1 note + 2 remotes + 6 tags */
/*
8
heads (including one packed head) + 1 note + 2 remotes + 6 tags */
assert_retrieval
(
"*"
,
GIT_REF_LISTALL
,
1
8
);
assert_retrieval
(
"*"
,
GIT_REF_LISTALL
,
1
9
);
}
}
void
test_refs_foreachglob__retrieve_remote_branches
(
void
)
void
test_refs_foreachglob__retrieve_remote_branches
(
void
)
...
@@ -56,7 +56,7 @@ void test_refs_foreachglob__retrieve_remote_branches(void)
...
@@ -56,7 +56,7 @@ void test_refs_foreachglob__retrieve_remote_branches(void)
void
test_refs_foreachglob__retrieve_local_branches
(
void
)
void
test_refs_foreachglob__retrieve_local_branches
(
void
)
{
{
assert_retrieval
(
"refs/heads/*"
,
GIT_REF_LISTALL
,
9
);
assert_retrieval
(
"refs/heads/*"
,
GIT_REF_LISTALL
,
10
);
}
}
void
test_refs_foreachglob__retrieve_partially_named_references
(
void
)
void
test_refs_foreachglob__retrieve_partially_named_references
(
void
)
...
...
tests-clar/refs/read.c
View file @
6ab68290
...
@@ -193,6 +193,18 @@ void test_refs_read__loose_first(void)
...
@@ -193,6 +193,18 @@ void test_refs_read__loose_first(void)
git_reference_free
(
reference
);
git_reference_free
(
reference
);
}
}
void
test_refs_read__chomped
(
void
)
{
git_reference
*
test
,
*
chomped
;
cl_git_pass
(
git_reference_lookup
(
&
test
,
g_repo
,
"refs/heads/test"
));
cl_git_pass
(
git_reference_lookup
(
&
chomped
,
g_repo
,
"refs/heads/chomped"
));
cl_git_pass
(
git_oid_cmp
(
git_reference_oid
(
test
),
git_reference_oid
(
chomped
)));
git_reference_free
(
test
);
git_reference_free
(
chomped
);
}
void
test_refs_read__unfound_return_ENOTFOUND
(
void
)
void
test_refs_read__unfound_return_ENOTFOUND
(
void
)
{
{
git_reference
*
reference
;
git_reference
*
reference
;
...
...
tests-clar/resources/testrepo.git/refs/heads/chomped
0 → 100644
View file @
6ab68290
e90810b8df3e80c413d903f631643c716887138d
\ No newline at end of file
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