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
1573acbb
Commit
1573acbb
authored
Aug 12, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3372 from libgit2/cmn/mirror-refspec
remote: don't confuse tag auto-follow rules with refspec matching
parents
bbbd0cbd
e3e017d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
9 deletions
+44
-9
src/remote.c
+10
-4
tests/network/fetchlocal.c
+34
-5
No files found.
src/remote.c
View file @
1573acbb
...
@@ -1334,11 +1334,13 @@ static int update_tips_for_spec(
...
@@ -1334,11 +1334,13 @@ static int update_tips_for_spec(
for
(;
i
<
refs
->
length
;
++
i
)
{
for
(;
i
<
refs
->
length
;
++
i
)
{
head
=
git_vector_get
(
refs
,
i
);
head
=
git_vector_get
(
refs
,
i
);
autotag
=
0
;
autotag
=
0
;
git_buf_clear
(
&
refname
);
/* Ignore malformed ref names (which also saves us from tag^{} */
/* Ignore malformed ref names (which also saves us from tag^{} */
if
(
!
git_reference_is_valid_name
(
head
->
name
))
if
(
!
git_reference_is_valid_name
(
head
->
name
))
continue
;
continue
;
/* If we have a tag, see if the auto-follow rules say to update it */
if
(
git_refspec_src_matches
(
&
tagspec
,
head
->
name
))
{
if
(
git_refspec_src_matches
(
&
tagspec
,
head
->
name
))
{
if
(
tagopt
!=
GIT_REMOTE_DOWNLOAD_TAGS_NONE
)
{
if
(
tagopt
!=
GIT_REMOTE_DOWNLOAD_TAGS_NONE
)
{
...
@@ -1348,10 +1350,11 @@ static int update_tips_for_spec(
...
@@ -1348,10 +1350,11 @@ static int update_tips_for_spec(
git_buf_clear
(
&
refname
);
git_buf_clear
(
&
refname
);
if
(
git_buf_puts
(
&
refname
,
head
->
name
)
<
0
)
if
(
git_buf_puts
(
&
refname
,
head
->
name
)
<
0
)
goto
on_error
;
goto
on_error
;
}
else
{
continue
;
}
}
}
else
if
(
git_refspec_src_matches
(
spec
,
head
->
name
))
{
}
/* If we didn't want to auto-follow the tag, check if the refspec matches */
if
(
!
autotag
&&
git_refspec_src_matches
(
spec
,
head
->
name
))
{
if
(
spec
->
dst
)
{
if
(
spec
->
dst
)
{
if
(
git_refspec_transform
(
&
refname
,
spec
,
head
->
name
)
<
0
)
if
(
git_refspec_transform
(
&
refname
,
spec
,
head
->
name
)
<
0
)
goto
on_error
;
goto
on_error
;
...
@@ -1365,7 +1368,10 @@ static int update_tips_for_spec(
...
@@ -1365,7 +1368,10 @@ static int update_tips_for_spec(
continue
;
continue
;
}
}
}
else
{
}
/* If we still don't have a refname, we don't want it */
if
(
git_buf_len
(
&
refname
)
==
0
)
{
continue
;
continue
;
}
}
...
...
tests/network/fetchlocal.c
View file @
1573acbb
...
@@ -369,17 +369,46 @@ void test_network_fetchlocal__clone_into_mirror(void)
...
@@ -369,17 +369,46 @@ void test_network_fetchlocal__clone_into_mirror(void)
{
{
git_clone_options
opts
=
GIT_CLONE_OPTIONS_INIT
;
git_clone_options
opts
=
GIT_CLONE_OPTIONS_INIT
;
git_repository
*
repo
;
git_repository
*
repo
;
git_reference
*
head
;
git_reference
*
ref
;
opts
.
bare
=
true
;
opts
.
bare
=
true
;
opts
.
remote_cb
=
remote_mirror_cb
;
opts
.
remote_cb
=
remote_mirror_cb
;
cl_git_pass
(
git_clone
(
&
repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo.git"
,
&
opts
));
cl_git_pass
(
git_clone
(
&
repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo.git"
,
&
opts
));
cl_git_pass
(
git_reference_lookup
(
&
head
,
repo
,
"HEAD"
));
cl_git_pass
(
git_reference_lookup
(
&
ref
,
repo
,
"HEAD"
));
cl_assert_equal_i
(
GIT_REF_SYMBOLIC
,
git_reference_type
(
head
));
cl_assert_equal_i
(
GIT_REF_SYMBOLIC
,
git_reference_type
(
ref
));
cl_assert_equal_s
(
"refs/heads/master"
,
git_reference_symbolic_target
(
head
));
cl_assert_equal_s
(
"refs/heads/master"
,
git_reference_symbolic_target
(
ref
));
git_reference_free
(
ref
);
cl_git_pass
(
git_reference_lookup
(
&
ref
,
repo
,
"refs/remotes/test/master"
));
git_reference_free
(
ref
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"./foo.git"
);
}
git_reference_free
(
head
);
void
test_network_fetchlocal__all_refs
(
void
)
{
git_repository
*
repo
;
git_remote
*
remote
;
git_reference
*
ref
;
char
*
allrefs
=
"+refs/*:refs/*"
;
git_strarray
refspecs
=
{
&
allrefs
,
1
,
};
cl_git_pass
(
git_repository_init
(
&
repo
,
"./foo.git"
,
true
));
cl_git_pass
(
git_remote_create_anonymous
(
&
remote
,
repo
,
cl_git_fixture_url
(
"testrepo.git"
)));
cl_git_pass
(
git_remote_fetch
(
remote
,
&
refspecs
,
NULL
,
NULL
));
cl_git_pass
(
git_reference_lookup
(
&
ref
,
repo
,
"refs/remotes/test/master"
));
git_reference_free
(
ref
);
cl_git_pass
(
git_reference_lookup
(
&
ref
,
repo
,
"refs/tags/test"
));
git_reference_free
(
ref
);
git_remote_free
(
remote
);
git_repository_free
(
repo
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"./foo.git"
);
cl_fixture_cleanup
(
"./foo.git"
);
}
}
...
...
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