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
55ededfd
Commit
55ededfd
authored
Jul 01, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make refspec_transform paranoid about arguments
parent
278ce746
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
16 deletions
+22
-16
src/clone.c
+2
-2
src/refspec.c
+20
-14
No files found.
src/clone.c
View file @
55ededfd
...
...
@@ -204,7 +204,7 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
/* Get the remote's HEAD. This is always the first ref in remote->refs. */
remote_head
=
NULL
;
if
(
!
remote
->
transport
->
ls
(
remote
->
transport
,
get_head_callback
,
&
remote_head
))
return
-
1
;
...
...
@@ -220,7 +220,7 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
memset
(
&
dummy_spec
,
0
,
sizeof
(
git_refspec
));
head_info
.
refspec
=
&
dummy_spec
;
}
/* Determine the remote tracking reference name from the local master */
if
(
git_refspec_transform_r
(
&
remote_master_name
,
...
...
src/refspec.c
View file @
55ededfd
...
...
@@ -225,25 +225,31 @@ int git_refspec_rtransform(char *out, size_t outlen, const git_refspec *spec, co
return
refspec_transform_internal
(
out
,
outlen
,
spec
->
dst
,
spec
->
src
,
name
);
}
static
int
refspec_transform
(
git_buf
*
out
,
const
char
*
from
,
const
char
*
to
,
const
char
*
name
)
static
int
refspec_transform
(
git_buf
*
out
,
const
char
*
from
,
const
char
*
to
,
const
char
*
name
)
{
if
(
git_buf_sets
(
out
,
to
)
<
0
)
return
-
1
;
size_t
to_len
=
to
?
strlen
(
to
)
:
0
;
size_t
from_len
=
from
?
strlen
(
from
)
:
0
;
size_t
name_len
=
name
?
strlen
(
name
)
:
0
;
/*
* No '*' at the end means that it's mapped to one specific
* branch, so no actual transformation is needed.
*/
if
(
git_buf_len
(
out
)
>
0
&&
out
->
ptr
[
git_buf_len
(
out
)
-
1
]
!=
'*'
)
return
0
;
if
(
git_buf_set
(
out
,
to
,
to_len
)
<
0
)
return
-
1
;
git_buf_truncate
(
out
,
git_buf_len
(
out
)
-
1
);
/* remove trailing '*' */
git_buf_puts
(
out
,
name
+
strlen
(
from
)
-
1
);
if
(
to_len
>
0
)
{
/* No '*' at the end of 'to' means that refspec is mapped to one
* specific branch, so no actual transformation is needed.
*/
if
(
out
->
ptr
[
to_len
-
1
]
!=
'*'
)
return
0
;
git_buf_shorten
(
out
,
1
);
/* remove trailing '*' copied from 'to' */
}
if
(
git_buf_oom
(
out
))
return
-
1
;
if
(
from_len
>
0
)
/* ignore trailing '*' from 'from' */
from_len
--
;
if
(
from_len
>
name_len
)
from_len
=
name_len
;
return
0
;
return
git_buf_put
(
out
,
name
+
from_len
,
name_len
-
from_len
)
;
}
int
git_refspec_transform_r
(
git_buf
*
out
,
const
git_refspec
*
spec
,
const
char
*
name
)
...
...
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