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
80fd31fa
Commit
80fd31fa
authored
Jul 13, 2013
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revparse: Don't return a reference when asked for a git object
Fix #1722
parent
1662158c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
src/revparse.c
+13
-0
tests-clar/refs/revparse.c
+41
-0
No files found.
src/revparse.c
View file @
80fd31fa
...
@@ -685,6 +685,8 @@ int revparse__ext(
...
@@ -685,6 +685,8 @@ int revparse__ext(
git_reference
*
reference
=
NULL
;
git_reference
*
reference
=
NULL
;
git_object
*
base_rev
=
NULL
;
git_object
*
base_rev
=
NULL
;
bool
should_return_reference
=
true
;
assert
(
object_out
&&
reference_out
&&
repo
&&
spec
);
assert
(
object_out
&&
reference_out
&&
repo
&&
spec
);
*
object_out
=
NULL
;
*
object_out
=
NULL
;
...
@@ -693,6 +695,8 @@ int revparse__ext(
...
@@ -693,6 +695,8 @@ int revparse__ext(
while
(
spec
[
pos
])
{
while
(
spec
[
pos
])
{
switch
(
spec
[
pos
])
{
switch
(
spec
[
pos
])
{
case
'^'
:
case
'^'
:
should_return_reference
=
false
;
if
((
error
=
ensure_base_rev_loaded
(
&
base_rev
,
&
reference
,
spec
,
identifier_len
,
repo
,
false
))
<
0
)
if
((
error
=
ensure_base_rev_loaded
(
&
base_rev
,
&
reference
,
spec
,
identifier_len
,
repo
,
false
))
<
0
)
goto
cleanup
;
goto
cleanup
;
...
@@ -725,6 +729,8 @@ int revparse__ext(
...
@@ -725,6 +729,8 @@ int revparse__ext(
{
{
git_object
*
temp_object
=
NULL
;
git_object
*
temp_object
=
NULL
;
should_return_reference
=
false
;
if
((
error
=
extract_how_many
(
&
n
,
spec
,
&
pos
))
<
0
)
if
((
error
=
extract_how_many
(
&
n
,
spec
,
&
pos
))
<
0
)
goto
cleanup
;
goto
cleanup
;
...
@@ -743,6 +749,8 @@ int revparse__ext(
...
@@ -743,6 +749,8 @@ int revparse__ext(
{
{
git_object
*
temp_object
=
NULL
;
git_object
*
temp_object
=
NULL
;
should_return_reference
=
false
;
if
((
error
=
extract_path
(
&
buf
,
spec
,
&
pos
))
<
0
)
if
((
error
=
extract_path
(
&
buf
,
spec
,
&
pos
))
<
0
)
goto
cleanup
;
goto
cleanup
;
...
@@ -807,6 +815,11 @@ int revparse__ext(
...
@@ -807,6 +815,11 @@ int revparse__ext(
if
((
error
=
ensure_base_rev_loaded
(
&
base_rev
,
&
reference
,
spec
,
identifier_len
,
repo
,
false
))
<
0
)
if
((
error
=
ensure_base_rev_loaded
(
&
base_rev
,
&
reference
,
spec
,
identifier_len
,
repo
,
false
))
<
0
)
goto
cleanup
;
goto
cleanup
;
if
(
!
should_return_reference
)
{
git_reference_free
(
reference
);
reference
=
NULL
;
}
*
object_out
=
base_rev
;
*
object_out
=
base_rev
;
*
reference_out
=
reference
;
*
reference_out
=
reference
;
*
identifier_len_out
=
identifier_len
;
*
identifier_len_out
=
identifier_len
;
...
...
tests-clar/refs/revparse.c
View file @
80fd31fa
...
@@ -738,4 +738,45 @@ void test_refs_revparse__ext_can_expand_short_reference_names(void)
...
@@ -738,4 +738,45 @@ void test_refs_revparse__ext_can_expand_short_reference_names(void)
"master"
,
"master"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
"refs/heads/master"
);
"refs/heads/master"
);
test_object_and_ref
(
"HEAD"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
"refs/heads/master"
);
test_object_and_ref
(
"tags/test"
,
"b25fa35b38051e4ae45d4222e795f9df2e43f1d1"
,
"refs/tags/test"
);
}
void
test_refs_revparse__ext_returns_NULL_reference_when_expression_points_at_a_revision
(
void
)
{
test_object_and_ref
(
"HEAD~3"
,
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045"
,
NULL
);
test_object_and_ref
(
"HEAD~0"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
NULL
);
test_object_and_ref
(
"HEAD^0"
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
,
NULL
);
test_object_and_ref
(
"@{-1}@{0}"
,
"a4a7dce85cf63874e984719f4fdd239f5145052f"
,
NULL
);
}
void
test_refs_revparse__ext_returns_NULL_reference_when_expression_points_at_a_tree_content
(
void
)
{
test_object_and_ref
(
"tags/test:readme.txt"
,
"0266163a49e280c4f5ed1e08facd36a2bd716bcf"
,
NULL
);
}
}
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