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
ced8d142
Commit
ced8d142
authored
Aug 22, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
errors: deploy GIT_EBAREREPO usage
parent
bb2d305c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
9 deletions
+24
-9
src/blob.c
+3
-1
src/iterator.c
+2
-5
src/repository.h
+15
-0
src/reset.c
+3
-2
tests-clar/reset/mixed.c
+1
-1
No files found.
src/blob.c
View file @
ced8d142
...
...
@@ -212,8 +212,10 @@ int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *pat
const
char
*
workdir
;
int
error
;
if
((
error
=
git_repository__ensure_not_bare
(
repo
,
"create blob from file"
))
<
0
)
return
error
;
workdir
=
git_repository_workdir
(
repo
);
assert
(
workdir
);
/* error to call this on bare repo */
if
(
git_buf_joinpath
(
&
full_path
,
workdir
,
path
)
<
0
)
{
git_buf_free
(
&
full_path
);
...
...
src/iterator.c
View file @
ced8d142
...
...
@@ -659,11 +659,8 @@ int git_iterator_for_workdir_range(
assert
(
iter
&&
repo
);
if
(
git_repository_is_bare
(
repo
))
{
giterr_set
(
GITERR_INVALID
,
"Cannot scan working directory for bare repo"
);
return
-
1
;
}
if
((
error
=
git_repository__ensure_not_bare
(
repo
,
"scan working directory"
))
<
0
)
return
error
;
ITERATOR_BASE_INIT
(
wi
,
workdir
,
WORKDIR
);
...
...
src/repository.h
View file @
ced8d142
...
...
@@ -149,4 +149,19 @@ void git_repository__cvar_cache_clear(git_repository *repo);
*/
extern
void
git_submodule_config_free
(
git_repository
*
repo
);
GIT_INLINE
(
int
)
git_repository__ensure_not_bare
(
git_repository
*
repo
,
const
char
*
operation_name
)
{
if
(
!
git_repository_is_bare
(
repo
))
return
0
;
giterr_set
(
GITERR_REPOSITORY
,
"Cannot %s. This operation is not allowed against bare repositories."
,
operation_name
);
return
GIT_EBAREREPO
;
}
#endif
src/reset.c
View file @
ced8d142
...
...
@@ -34,8 +34,9 @@ int git_reset(
if
(
git_object_owner
(
target
)
!=
repo
)
return
reset_error_invalid
(
"The given target does not belong to this repository."
);
if
(
reset_type
==
GIT_RESET_MIXED
&&
git_repository_is_bare
(
repo
))
return
reset_error_invalid
(
"Mixed reset is not allowed in a bare repository."
);
if
(
reset_type
==
GIT_RESET_MIXED
&&
git_repository__ensure_not_bare
(
repo
,
"reset mixed"
)
<
0
)
return
GIT_EBAREREPO
;
if
(
git_object_peel
(
&
commit
,
target
,
GIT_OBJ_COMMIT
)
<
0
)
{
reset_error_invalid
(
"The given target does not resolve to a commit"
);
...
...
tests-clar/reset/mixed.c
View file @
ced8d142
...
...
@@ -27,7 +27,7 @@ void test_reset_mixed__cannot_reset_in_a_bare_repository(void)
retrieve_target_from_oid
(
&
target
,
bare
,
KNOWN_COMMIT_IN_BARE_REPO
);
cl_
git_fail
(
git_reset
(
bare
,
target
,
GIT_RESET_MIXED
));
cl_
assert_equal_i
(
GIT_EBAREREPO
,
git_reset
(
bare
,
target
,
GIT_RESET_MIXED
));
git_repository_free
(
bare
);
}
...
...
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