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
05752700
Commit
05752700
authored
Aug 27, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #899 from schu/revwalk-push
revwalk: refuse push of non-commit objects
parents
0b9174c6
4e323ef0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
src/revwalk.c
+14
-6
tests-clar/revwalk/basic.c
+8
-0
No files found.
src/revwalk.c
View file @
05752700
...
...
@@ -264,12 +264,7 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
if
((
error
=
git_odb_read
(
&
obj
,
walk
->
odb
,
&
commit
->
oid
))
<
0
)
return
error
;
if
(
obj
->
raw
.
type
!=
GIT_OBJ_COMMIT
)
{
git_odb_object_free
(
obj
);
giterr_set
(
GITERR_INVALID
,
"Failed to parse commit. Object is no commit object"
);
return
-
1
;
}
assert
(
obj
->
raw
.
type
==
GIT_OBJ_COMMIT
);
error
=
commit_quick_parse
(
walk
,
commit
,
&
obj
->
raw
);
git_odb_object_free
(
obj
);
...
...
@@ -515,8 +510,21 @@ static int process_commit_parents(git_revwalk *walk, commit_object *commit)
static
int
push_commit
(
git_revwalk
*
walk
,
const
git_oid
*
oid
,
int
uninteresting
)
{
git_object
*
obj
;
git_otype
type
;
commit_object
*
commit
;
if
(
git_object_lookup
(
&
obj
,
walk
->
repo
,
oid
,
GIT_OBJ_ANY
)
<
0
)
return
-
1
;
type
=
git_object_type
(
obj
);
git_object_free
(
obj
);
if
(
type
!=
GIT_OBJ_COMMIT
)
{
giterr_set
(
GITERR_INVALID
,
"Object is no commit object"
);
return
-
1
;
}
commit
=
commit_lookup
(
walk
,
oid
);
if
(
commit
==
NULL
)
return
-
1
;
/* error already reported by failed lookup */
...
...
tests-clar/revwalk/basic.c
View file @
05752700
...
...
@@ -179,3 +179,11 @@ void test_revwalk_basic__push_head_hide_ref_nobase(void)
/* git log HEAD --oneline --not refs/heads/packed | wc -l => 7 */
cl_assert
(
i
==
7
);
}
void
test_revwalk_basic__disallow_non_commit
(
void
)
{
git_oid
oid
;
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
"521d87c1ec3aef9824daf6d96cc0ae3710766d91"
));
cl_git_fail
(
git_revwalk_push
(
_walk
,
&
oid
));
}
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