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
c8a33547
Commit
c8a33547
authored
May 10, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rev-parse: now capturing and reporting regex errors.
parent
2b35c45f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
src/revparse.c
+14
-5
tests-clar/refs/revparse.c
+2
-0
No files found.
src/revparse.c
View file @
c8a33547
...
@@ -145,6 +145,7 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
...
@@ -145,6 +145,7 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
/* "@{-N}" form means walk back N checkouts. That means the HEAD log. */
/* "@{-N}" form means walk back N checkouts. That means the HEAD log. */
if
(
refspeclen
==
0
&&
!
git__prefixcmp
(
reflogspec
,
"@{-"
))
{
if
(
refspeclen
==
0
&&
!
git__prefixcmp
(
reflogspec
,
"@{-"
))
{
regex_t
regex
;
regex_t
regex
;
int
regex_error
;
if
(
git__strtol32
(
&
n
,
reflogspec
+
3
,
NULL
,
0
)
<
0
||
if
(
git__strtol32
(
&
n
,
reflogspec
+
3
,
NULL
,
0
)
<
0
||
n
<
1
)
{
n
<
1
)
{
...
@@ -155,7 +156,10 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
...
@@ -155,7 +156,10 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
git_reflog_read
(
&
reflog
,
ref
);
git_reflog_read
(
&
reflog
,
ref
);
git_reference_free
(
ref
);
git_reference_free
(
ref
);
if
(
!
regcomp
(
&
regex
,
"checkout: moving from (.*) to .*"
,
REG_EXTENDED
))
{
regex_error
=
regcomp
(
&
regex
,
"checkout: moving from (.*) to .*"
,
REG_EXTENDED
);
if
(
regex_error
!=
0
)
{
giterr_set_regex
(
&
regex
,
regex_error
);
}
else
{
regmatch_t
regexmatches
[
2
];
regmatch_t
regexmatches
[
2
];
refloglen
=
git_reflog_entrycount
(
reflog
);
refloglen
=
git_reflog_entrycount
(
reflog
);
...
@@ -173,6 +177,7 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
...
@@ -173,6 +177,7 @@ static int walk_ref_history(git_object **out, git_repository *repo, const char *
}
}
}
}
}
}
regfree
(
&
regex
);
}
}
}
else
{
}
else
{
git_buf
datebuf
=
GIT_BUF_INIT
;
git_buf
datebuf
=
GIT_BUF_INIT
;
...
@@ -385,6 +390,7 @@ static int handle_caret_syntax(git_object **out, git_repository *repo, git_objec
...
@@ -385,6 +390,7 @@ static int handle_caret_syntax(git_object **out, git_repository *repo, git_objec
if
(
!
git_revwalk_new
(
&
walk
,
repo
))
{
if
(
!
git_revwalk_new
(
&
walk
,
repo
))
{
git_oid
oid
;
git_oid
oid
;
regex_t
preg
;
regex_t
preg
;
int
reg_error
;
git_buf
buf
=
GIT_BUF_INIT
;
git_buf
buf
=
GIT_BUF_INIT
;
git_revwalk_sorting
(
walk
,
GIT_SORT_TIME
);
git_revwalk_sorting
(
walk
,
GIT_SORT_TIME
);
...
@@ -393,7 +399,10 @@ static int handle_caret_syntax(git_object **out, git_repository *repo, git_objec
...
@@ -393,7 +399,10 @@ static int handle_caret_syntax(git_object **out, git_repository *repo, git_objec
/* Extract the regex from the movement string */
/* Extract the regex from the movement string */
git_buf_put
(
&
buf
,
movement
+
2
,
strlen
(
movement
)
-
3
);
git_buf_put
(
&
buf
,
movement
+
2
,
strlen
(
movement
)
-
3
);
if
(
!
regcomp
(
&
preg
,
git_buf_cstr
(
&
buf
),
REG_EXTENDED
))
{
reg_error
=
regcomp
(
&
preg
,
git_buf_cstr
(
&
buf
),
REG_EXTENDED
);
if
(
reg_error
!=
0
)
{
giterr_set_regex
(
&
preg
,
reg_error
);
}
else
{
while
(
!
git_revwalk_next
(
&
oid
,
walk
))
{
while
(
!
git_revwalk_next
(
&
oid
,
walk
))
{
git_object
*
walkobj
;
git_object
*
walkobj
;
char
str
[
41
];
char
str
[
41
];
...
@@ -415,15 +424,15 @@ static int handle_caret_syntax(git_object **out, git_repository *repo, git_objec
...
@@ -415,15 +424,15 @@ static int handle_caret_syntax(git_object **out, git_repository *repo, git_objec
git_object_free
(
walkobj
);
git_object_free
(
walkobj
);
}
}
}
}
if
(
retcode
<
0
)
{
giterr_set
(
GITERR_REFERENCE
,
"Couldn't find a match for %s"
,
movement
);
}
regfree
(
&
preg
);
regfree
(
&
preg
);
}
}
git_buf_free
(
&
buf
);
git_buf_free
(
&
buf
);
git_revwalk_free
(
walk
);
git_revwalk_free
(
walk
);
}
}
if
(
retcode
<
0
)
{
giterr_set
(
GITERR_REFERENCE
,
"Couldn't find a match for %s"
,
movement
);
}
return
retcode
;
return
retcode
;
}
}
...
...
tests-clar/refs/revparse.c
View file @
c8a33547
...
@@ -130,6 +130,8 @@ void test_refs_revparse__revwalk(void)
...
@@ -130,6 +130,8 @@ void test_refs_revparse__revwalk(void)
{
{
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master^{/not found in any commit}"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master^{/not found in any commit}"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master^{/merge}"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master^{/merge}"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master^{/((}"
));
cl_assert
(
strstr
(
git_lasterror
(),
"parentheses not balanced"
)
!=
NULL
);
test_object
(
"master^{/anoth}"
,
"5b5b025afb0b4c913b4c338a42934a3863bf3644"
);
test_object
(
"master^{/anoth}"
,
"5b5b025afb0b4c913b4c338a42934a3863bf3644"
);
test_object
(
"master^{/Merge}"
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
);
test_object
(
"master^{/Merge}"
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
);
...
...
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