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
faaa7c51
Commit
faaa7c51
authored
Jun 27, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revparse: return trees through the "colon" syntax
parent
e28dd29b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
src/revparse.c
+12
-4
tests-clar/refs/revparse.c
+6
-1
No files found.
src/revparse.c
View file @
faaa7c51
...
...
@@ -533,16 +533,24 @@ static int handle_linear_syntax(git_object **out, git_object *obj, const char *m
static
int
oid_for_tree_path
(
git_oid
*
out
,
git_tree
*
tree
,
git_repository
*
repo
,
const
char
*
path
)
{
char
*
str
=
git__strdup
(
path
);
char
*
tok
;
void
*
alloc
=
str
;
char
*
str
,
*
tok
;
void
*
alloc
;
git_tree
*
tree2
=
tree
;
const
git_tree_entry
*
entry
=
NULL
;
if
(
*
path
==
'\0'
)
{
git_oid_cpy
(
out
,
git_object_id
((
git_object
*
)
tree
));
return
0
;
}
alloc
=
str
=
git__strdup
(
path
);
while
((
tok
=
git__strtok
(
&
str
,
"/
\\
"
))
!=
NULL
)
{
entry
=
git_tree_entry_byname
(
tree2
,
tok
);
if
(
tree2
!=
tree
)
git_tree_free
(
tree2
);
if
(
git_tree_entry__is_tree
(
entry
))
{
if
(
str
==
'\0'
)
break
;
if
(
git_tree_lookup
(
&
tree2
,
repo
,
&
entry
->
oid
)
<
0
)
{
git__free
(
alloc
);
return
GIT_ERROR
;
...
...
@@ -576,7 +584,7 @@ static int handle_colon_syntax(git_object **out,
}
tree
=
(
git_tree
*
)
obj
;
/* Find the blob at the given path. */
/* Find the blob
or tree
at the given path. */
error
=
oid_for_tree_path
(
&
oid
,
tree
,
repo
,
path
);
git_tree_free
(
tree
);
...
...
tests-clar/refs/revparse.c
View file @
faaa7c51
...
...
@@ -166,8 +166,13 @@ void test_refs_revparse__colon(void)
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
":/"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
":/not found in any commit"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
":2:README"
));
cl_git_fail
(
git_revparse_single
(
&
g_obj
,
g_repo
,
"master:"
));
/* Trees */
test_object
(
"master:"
,
"944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"
);
test_object
(
"subtrees:"
,
"ae90f12eea699729ed24555e40b9fd669da12a12"
);
test_object
(
"subtrees:ab"
,
"f1425cef211cc08caa31e7b545ffb232acb098c3"
);
/* Blobs */
test_object
(
"subtrees:ab/4.txt"
,
"d6c93164c249c8000205dd4ec5cbca1b516d487f"
);
test_object
(
"subtrees:ab/de/fgh/1.txt"
,
"1f67fc4386b2d171e0d21be1c447e12660561f9b"
);
test_object
(
"master:README"
,
"a8233120f6ad708f843d861ce2b7228ec4e3dec6"
);
...
...
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