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
a442ed68
Commit
a442ed68
authored
Apr 17, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repository: Add `git_repository_open_bare`
parent
f124ebd4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
include/git2/repository.h
+15
-0
src/repository.c
+31
-0
No files found.
include/git2/repository.h
View file @
a442ed68
...
...
@@ -124,6 +124,21 @@ GIT_EXTERN(int) git_repository_open_ext(
const
char
*
ceiling_dirs
);
/**
* Open a bare repository on the serverside.
*
* This is a fast open for bare repositories that will come in handy
* if you're e.g. hosting git repositories and need to access them
* efficiently
*
* @param out Pointer to the repo which will be opened.
* @param bare_path Direct path to the bare repository
* @return 0 on success, or an error code
*/
GIT_EXTERN
(
int
)
git_repository_open_bare
(
git_repository
**
out
,
const
char
*
bare_path
);
/**
* Free a previously allocated repository
*
* Note that after a repository is free'd, all the objects it has spawned
...
...
src/repository.c
View file @
a442ed68
...
...
@@ -368,6 +368,37 @@ static int find_repo(
return
error
;
}
int
git_repository_open_bare
(
git_repository
**
repo_ptr
,
const
char
*
bare_path
)
{
int
error
;
git_buf
path
=
GIT_BUF_INIT
;
git_repository
*
repo
=
NULL
;
if
((
error
=
git_path_prettify_dir
(
&
path
,
bare_path
,
NULL
))
<
0
)
return
error
;
if
(
!
valid_repository_path
(
&
path
))
{
git_buf_free
(
&
path
);
giterr_set
(
GITERR_REPOSITORY
,
"Path is not a repository: %s"
,
bare_path
);
return
GIT_ENOTFOUND
;
}
repo
=
repository_alloc
();
GITERR_CHECK_ALLOC
(
repo
);
repo
->
path_repository
=
git_buf_detach
(
&
path
);
GITERR_CHECK_ALLOC
(
repo
->
path_repository
);
/* of course we're bare! */
repo
->
is_bare
=
1
;
repo
->
workdir
=
NULL
;
*
repo_ptr
=
repo
;
return
0
;
}
int
git_repository_open_ext
(
git_repository
**
repo_ptr
,
const
char
*
start_path
,
...
...
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