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
8cddf9b8
Commit
8cddf9b8
authored
May 01, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refdb: Properly load namespaces
parent
e1807113
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
3 deletions
+41
-3
src/refdb_fs.c
+41
-3
No files found.
src/refdb_fs.c
View file @
8cddf9b8
...
...
@@ -997,6 +997,43 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
git__free
(
backend
);
}
static
int
setup_namespace
(
git_buf
*
path
,
git_repository
*
repo
)
{
char
*
parts
,
*
start
,
*
end
;
/* Load the path to the repo first */
git_buf_puts
(
path
,
repo
->
path_repository
);
/* if the repo is not namespaced, nothing else to do */
if
(
repo
->
namespace
==
NULL
)
return
0
;
parts
=
end
=
git__strdup
(
repo
->
namespace
);
if
(
parts
==
NULL
)
return
-
1
;
/**
* From `man gitnamespaces`:
* namespaces which include a / will expand to a hierarchy
* of namespaces; for example, GIT_NAMESPACE=foo/bar will store
* refs under refs/namespaces/foo/refs/namespaces/bar/
*/
while
((
start
=
git__strsep
(
&
end
,
"/"
))
!=
NULL
)
{
git_buf_printf
(
path
,
"refs/namespaces/%s/"
,
start
);
}
git_buf_printf
(
path
,
"refs/namespaces/%s/refs"
,
end
);
free
(
parts
);
/* Make sure that the folder with the namespace exists */
if
(
git_futils_mkdir_r
(
git_buf_cstr
(
path
),
repo
->
path_repository
,
0777
)
<
0
)
return
-
1
;
/* Return the root of the namespaced path, i.e. without the trailing '/refs' */
git_buf_rtruncate_at_char
(
path
,
'/'
);
return
0
;
}
int
git_refdb_backend_fs
(
git_refdb_backend
**
backend_out
,
git_repository
*
repository
)
...
...
@@ -1009,9 +1046,10 @@ int git_refdb_backend_fs(
backend
->
repo
=
repository
;
git_buf_puts
(
&
path
,
repository
->
path_repository
);
if
(
repository
->
namespace
!=
NULL
)
git_buf_printf
(
&
path
,
"refs/namespaces/%s/"
,
repository
->
namespace
);
if
(
setup_namespace
(
&
path
,
repository
)
<
0
)
{
git__free
(
backend
);
return
-
1
;
}
backend
->
path
=
git_buf_detach
(
&
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