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
46035d98
Commit
46035d98
authored
Sep 06, 2016
by
Patrick Steinhardt
Committed by
GitHub
Sep 06, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3882 from pks-t/pks/fix-fetch-refspec-dst-parsing
refspec: do not set empty rhs for fetch refspecs
parents
ce54e77c
1eee631d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
src/refspec.c
+4
-2
tests/online/fetchhead.c
+51
-0
No files found.
src/refspec.c
View file @
46035d98
...
...
@@ -53,8 +53,10 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
if
(
rhs
)
{
size_t
rlen
=
strlen
(
++
rhs
);
is_glob
=
(
1
<=
rlen
&&
strchr
(
rhs
,
'*'
));
refspec
->
dst
=
git__strndup
(
rhs
,
rlen
);
if
(
rlen
||
!
is_fetch
)
{
is_glob
=
(
1
<=
rlen
&&
strchr
(
rhs
,
'*'
));
refspec
->
dst
=
git__strndup
(
rhs
,
rlen
);
}
}
llen
=
(
rhs
?
(
size_t
)(
rhs
-
lhs
-
1
)
:
strlen
(
lhs
));
...
...
tests/online/fetchhead.c
View file @
46035d98
...
...
@@ -35,6 +35,19 @@ static void fetchhead_test_clone(void)
cl_git_pass
(
git_clone
(
&
g_repo
,
LIVE_REPO_URL
,
"./foo"
,
&
g_options
));
}
static
int
count_references
(
void
)
{
git_strarray
array
;
int
refs
;
cl_git_pass
(
git_reference_list
(
&
array
,
g_repo
));
refs
=
array
.
count
;
git_strarray_free
(
&
array
);
return
refs
;
}
static
void
fetchhead_test_fetch
(
const
char
*
fetchspec
,
const
char
*
expected_fetchhead
)
{
git_remote
*
remote
;
...
...
@@ -101,3 +114,41 @@ void test_online_fetchhead__no_merges(void)
cl_git_pass
(
git_tag_delete
(
g_repo
,
"commit_tree"
));
fetchhead_test_fetch
(
NULL
,
FETCH_HEAD_NO_MERGE_DATA3
);
}
void
test_online_fetchhead__explicit_dst_refspec_creates_branch
(
void
)
{
git_reference
*
ref
;
int
refs
;
fetchhead_test_clone
();
refs
=
count_references
();
fetchhead_test_fetch
(
"refs/heads/first-merge:refs/heads/explicit-refspec"
,
FETCH_HEAD_EXPLICIT_DATA
);
cl_git_pass
(
git_branch_lookup
(
&
ref
,
g_repo
,
"explicit-refspec"
,
GIT_BRANCH_ALL
));
cl_assert_equal_i
(
refs
+
1
,
count_references
());
}
void
test_online_fetchhead__empty_dst_refspec_creates_no_branch
(
void
)
{
git_reference
*
ref
;
int
refs
;
fetchhead_test_clone
();
refs
=
count_references
();
fetchhead_test_fetch
(
"refs/heads/first-merge"
,
FETCH_HEAD_EXPLICIT_DATA
);
cl_git_fail
(
git_branch_lookup
(
&
ref
,
g_repo
,
"first-merge"
,
GIT_BRANCH_ALL
));
cl_assert_equal_i
(
refs
,
count_references
());
}
void
test_online_fetchhead__colon_only_dst_refspec_creates_no_branch
(
void
)
{
int
refs
;
fetchhead_test_clone
();
refs
=
count_references
();
fetchhead_test_fetch
(
"refs/heads/first-merge:"
,
FETCH_HEAD_EXPLICIT_DATA
);
cl_assert_equal_i
(
refs
,
count_references
());
}
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