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
3e012fca
Commit
3e012fca
authored
Sep 26, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refspec: introduce git_refspec_transform_l()
parent
70edc1b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
src/refspec.c
+14
-4
src/refspec.h
+11
-0
No files found.
src/refspec.c
View file @
3e012fca
...
...
@@ -194,20 +194,20 @@ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, con
return
0
;
}
int
git_refspec_transform_r
(
git_buf
*
out
,
const
git_refspec
*
spec
,
const
char
*
name
)
static
int
refspec_transform
(
git_buf
*
out
,
const
char
*
from
,
const
char
*
to
,
const
char
*
name
)
{
if
(
git_buf_sets
(
out
,
spec
->
dst
)
<
0
)
if
(
git_buf_sets
(
out
,
to
)
<
0
)
return
-
1
;
/*
* No '*' at the end means that it's mapped to one specific
local
* 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
;
git_buf_truncate
(
out
,
git_buf_len
(
out
)
-
1
);
/* remove trailing '*' */
git_buf_puts
(
out
,
name
+
strlen
(
spec
->
src
)
-
1
);
git_buf_puts
(
out
,
name
+
strlen
(
from
)
-
1
);
if
(
git_buf_oom
(
out
))
return
-
1
;
...
...
@@ -215,3 +215,13 @@ int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *n
return
0
;
}
int
git_refspec_transform_r
(
git_buf
*
out
,
const
git_refspec
*
spec
,
const
char
*
name
)
{
return
refspec_transform
(
out
,
spec
->
src
,
spec
->
dst
,
name
);
}
int
git_refspec_transform_l
(
git_buf
*
out
,
const
git_refspec
*
spec
,
const
char
*
name
)
{
return
refspec_transform
(
out
,
spec
->
dst
,
spec
->
src
,
name
);
}
src/refspec.h
View file @
3e012fca
...
...
@@ -40,4 +40,15 @@ void git_refspec__free(git_refspec *refspec);
*/
int
git_refspec_transform_r
(
git_buf
*
out
,
const
git_refspec
*
spec
,
const
char
*
name
);
/**
* Transform a reference from its target following the refspec's rules,
* and writes the results into a git_buf.
*
* @param out where to store the source name
* @param spec the refspec
* @param name the name of the reference to transform
* @return 0 or error if buffer allocation fails
*/
int
git_refspec_transform_l
(
git_buf
*
out
,
const
git_refspec
*
spec
,
const
char
*
name
);
#endif
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