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
7e79d389
Commit
7e79d389
authored
May 10, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rev-parse: regex check for "git describe" output.
parent
b41384b4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
src/revparse.c
+17
-0
No files found.
src/revparse.c
View file @
7e79d389
...
@@ -37,6 +37,22 @@ static int revparse_lookup_fully_qualifed_ref(git_object **out, git_repository *
...
@@ -37,6 +37,22 @@ static int revparse_lookup_fully_qualifed_ref(git_object **out, git_repository *
return
git_object_lookup
(
out
,
repo
,
&
resolved
,
GIT_OBJ_ANY
);
return
git_object_lookup
(
out
,
repo
,
&
resolved
,
GIT_OBJ_ANY
);
}
}
/* Returns non-zero if yes */
static
int
spec_looks_like_describe_output
(
const
char
*
spec
)
{
regex_t
regex
;
int
regex_error
,
retcode
;
regex_error
=
regcomp
(
&
regex
,
".+-[0-9]+-g[0-9a-fA-F]+"
,
REG_EXTENDED
);
if
(
regex_error
!=
0
)
{
giterr_set_regex
(
&
regex
,
regex_error
);
return
1
;
/* To be safe */
}
retcode
=
regexec
(
&
regex
,
spec
,
0
,
NULL
,
0
);
regfree
(
&
regex
);
return
retcode
==
0
;
}
static
int
revparse_lookup_object
(
git_object
**
out
,
git_repository
*
repo
,
const
char
*
spec
)
static
int
revparse_lookup_object
(
git_object
**
out
,
git_repository
*
repo
,
const
char
*
spec
)
{
{
size_t
speclen
=
strlen
(
spec
);
size_t
speclen
=
strlen
(
spec
);
...
@@ -57,6 +73,7 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
...
@@ -57,6 +73,7 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
/* "git describe" output; snip everything before/including "-g" */
/* "git describe" output; snip everything before/including "-g" */
substr
=
strstr
(
spec
,
"-g"
);
substr
=
strstr
(
spec
,
"-g"
);
if
(
substr
&&
if
(
substr
&&
spec_looks_like_describe_output
(
spec
)
&&
!
revparse_lookup_object
(
out
,
repo
,
substr
+
2
))
{
!
revparse_lookup_object
(
out
,
repo
,
substr
+
2
))
{
return
0
;
return
0
;
}
}
...
...
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