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
c081f0d0
Commit
c081f0d0
authored
Dec 26, 2017
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetch: go over FETCH_HEAD just once when counting the prefixes in test
parent
1b4fbf2e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
19 deletions
+24
-19
tests/fetchhead/nonetwork.c
+24
-19
No files found.
tests/fetchhead/nonetwork.c
View file @
c081f0d0
...
...
@@ -407,20 +407,28 @@ void test_fetchhead_nonetwork__create_when_refpecs_given(void)
git_buf_free
(
&
path
);
}
static
int
nrefs_found
;
static
bool
count_refs_called
;
struct
prefix_count
{
const
char
*
prefix
;
int
count
;
int
expected
;
};
int
count_refs
(
const
char
*
ref_name
,
const
char
*
remote_url
,
const
git_oid
*
oid
,
unsigned
int
is_merge
,
void
*
payload
)
{
const
char
*
pfix
=
(
const
char
*
)
payload
;
int
i
;
struct
prefix_count
*
prefix_counts
=
(
struct
prefix_count
*
)
payload
;
GIT_UNUSED
(
remote_url
);
GIT_UNUSED
(
oid
);
GIT_UNUSED
(
is_merge
);
count_refs_called
=
true
;
if
(
!
git__prefixcmp
(
ref_name
,
pfix
))
nrefs_found
++
;
for
(
i
=
0
;
prefix_counts
[
i
].
prefix
;
i
++
)
{
if
(
!
git__prefixcmp
(
ref_name
,
prefix_counts
[
i
].
prefix
))
prefix_counts
[
i
].
count
++
;
}
return
0
;
}
...
...
@@ -444,23 +452,20 @@ void test_fetchhead_nonetwork__create_with_multiple_refspecs(void)
cl_git_pass
(
git_remote_fetch
(
remote
,
NULL
,
NULL
,
NULL
));
cl_assert
(
git_path_exists
(
path
.
ptr
));
count_refs_called
=
0
;
nrefs_found
=
0
;
cl_git_pass
(
git_repository_fetchhead_foreach
(
g_repo
,
count_refs
,
"refs/notes/"
));
cl_assert
(
count_refs_called
);
cl_assert_equal_i
(
1
,
nrefs_found
);
count_refs_called
=
0
;
nrefs_found
=
0
;
cl_git_pass
(
git_repository_fetchhead_foreach
(
g_repo
,
count_refs
,
"refs/heads/"
));
cl_assert
(
count_refs_called
);
cl_assert_equal_i
(
12
,
nrefs_found
);
{
int
i
;
struct
prefix_count
prefix_counts
[]
=
{
{
"refs/notes/"
,
0
,
1
},
{
"refs/heads/"
,
0
,
12
},
{
"refs/tags/"
,
0
,
7
},
{
NULL
,
0
,
0
},
};
count_refs_called
=
0
;
nrefs_found
=
0
;
cl_git_pass
(
git_repository_fetchhead_foreach
(
g_repo
,
count_refs
,
"refs/tags/"
));
cl_git_pass
(
git_repository_fetchhead_foreach
(
g_repo
,
count_refs
,
&
prefix_counts
));
cl_assert
(
count_refs_called
);
cl_assert_equal_i
(
7
,
nrefs_found
);
for
(
i
=
0
;
prefix_counts
[
i
].
prefix
;
i
++
)
cl_assert_equal_i
(
prefix_counts
[
i
].
expected
,
prefix_counts
[
i
].
count
);
}
git_remote_free
(
remote
);
git_buf_free
(
&
path
);
...
...
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