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
cfcdbc10
Commit
cfcdbc10
authored
May 01, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1523 from libgit2/vmg/namespaces
Namespace support
parents
5e2261ac
bade5194
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
2 deletions
+50
-2
include/git2/repository.h
+22
-0
src/refdb_fs.c
+9
-2
src/repository.c
+18
-0
src/repository.h
+1
-0
No files found.
include/git2/repository.h
View file @
cfcdbc10
...
@@ -626,6 +626,28 @@ typedef enum {
...
@@ -626,6 +626,28 @@ typedef enum {
*/
*/
GIT_EXTERN
(
int
)
git_repository_state
(
git_repository
*
repo
);
GIT_EXTERN
(
int
)
git_repository_state
(
git_repository
*
repo
);
/**
* Sets the active namespace for this Git Repository
*
* This namespace affects all reference operations for the repo.
* See `man gitnamespaces`
*
* @param repo The repo
* @param nmspace The namespace. This should not include the refs
* folder, e.g. to namespace all references under `refs/namespaces/foo/`,
* use `foo` as the namespace.
* @return 0 on success, -1 on error
*/
GIT_EXTERN
(
int
)
git_repository_set_namespace
(
git_repository
*
repo
,
const
char
*
nmspace
);
/**
* Get the currently active namespace for this repository
*
* @param repo The repo
* @return the active namespace, or NULL if there isn't one
*/
GIT_EXTERN
(
const
char
*
)
git_repository_get_namespace
(
git_repository
*
repo
);
/** @} */
/** @} */
GIT_END_DECL
GIT_END_DECL
#endif
#endif
src/refdb_fs.c
View file @
cfcdbc10
...
@@ -41,7 +41,7 @@ typedef struct refdb_fs_backend {
...
@@ -41,7 +41,7 @@ typedef struct refdb_fs_backend {
git_refdb_backend
parent
;
git_refdb_backend
parent
;
git_repository
*
repo
;
git_repository
*
repo
;
c
onst
c
har
*
path
;
char
*
path
;
git_refcache
refcache
;
git_refcache
refcache
;
}
refdb_fs_backend
;
}
refdb_fs_backend
;
...
@@ -993,6 +993,7 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
...
@@ -993,6 +993,7 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
backend
=
(
refdb_fs_backend
*
)
_backend
;
backend
=
(
refdb_fs_backend
*
)
_backend
;
refcache_free
(
&
backend
->
refcache
);
refcache_free
(
&
backend
->
refcache
);
git__free
(
backend
->
path
);
git__free
(
backend
);
git__free
(
backend
);
}
}
...
@@ -1000,13 +1001,19 @@ int git_refdb_backend_fs(
...
@@ -1000,13 +1001,19 @@ int git_refdb_backend_fs(
git_refdb_backend
**
backend_out
,
git_refdb_backend
**
backend_out
,
git_repository
*
repository
)
git_repository
*
repository
)
{
{
git_buf
path
=
GIT_BUF_INIT
;
refdb_fs_backend
*
backend
;
refdb_fs_backend
*
backend
;
backend
=
git__calloc
(
1
,
sizeof
(
refdb_fs_backend
));
backend
=
git__calloc
(
1
,
sizeof
(
refdb_fs_backend
));
GITERR_CHECK_ALLOC
(
backend
);
GITERR_CHECK_ALLOC
(
backend
);
backend
->
repo
=
repository
;
backend
->
repo
=
repository
;
backend
->
path
=
repository
->
path_repository
;
git_buf_puts
(
&
path
,
repository
->
path_repository
);
if
(
repository
->
namespace
!=
NULL
)
git_buf_printf
(
&
path
,
"refs/%s/"
,
repository
->
namespace
);
backend
->
path
=
git_buf_detach
(
&
path
);
backend
->
parent
.
exists
=
&
refdb_fs_backend__exists
;
backend
->
parent
.
exists
=
&
refdb_fs_backend__exists
;
backend
->
parent
.
lookup
=
&
refdb_fs_backend__lookup
;
backend
->
parent
.
lookup
=
&
refdb_fs_backend__lookup
;
...
...
src/repository.c
View file @
cfcdbc10
...
@@ -111,6 +111,7 @@ void git_repository_free(git_repository *repo)
...
@@ -111,6 +111,7 @@ void git_repository_free(git_repository *repo)
git__free
(
repo
->
path_repository
);
git__free
(
repo
->
path_repository
);
git__free
(
repo
->
workdir
);
git__free
(
repo
->
workdir
);
git__free
(
repo
->
namespace
);
git__free
(
repo
);
git__free
(
repo
);
}
}
...
@@ -764,6 +765,23 @@ void git_repository_set_index(git_repository *repo, git_index *index)
...
@@ -764,6 +765,23 @@ void git_repository_set_index(git_repository *repo, git_index *index)
set_index
(
repo
,
index
);
set_index
(
repo
,
index
);
}
}
int
git_repository_set_namespace
(
git_repository
*
repo
,
const
char
*
namespace
)
{
git__free
(
repo
->
namespace
);
if
(
namespace
==
NULL
)
{
repo
->
namespace
=
NULL
;
return
0
;
}
return
(
repo
->
namespace
=
git__strdup
(
namespace
))
?
0
:
-
1
;
}
const
char
*
git_repository_get_namespace
(
git_repository
*
repo
)
{
return
repo
->
namespace
;
}
static
int
check_repositoryformatversion
(
git_config
*
config
)
static
int
check_repositoryformatversion
(
git_config
*
config
)
{
{
int
version
;
int
version
;
...
...
src/repository.h
View file @
cfcdbc10
...
@@ -111,6 +111,7 @@ struct git_repository {
...
@@ -111,6 +111,7 @@ struct git_repository {
char
*
path_repository
;
char
*
path_repository
;
char
*
workdir
;
char
*
workdir
;
char
*
namespace
;
unsigned
is_bare
:
1
;
unsigned
is_bare
:
1
;
unsigned
int
lru_counter
;
unsigned
int
lru_counter
;
...
...
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