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
a025907e
Commit
a025907e
authored
Sep 17, 2013
by
Linquize
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Can load default template directory
parent
b99b10f2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
src/fileops.c
+8
-1
src/fileops.h
+8
-0
src/repository.c
+8
-4
No files found.
src/fileops.c
View file @
a025907e
...
...
@@ -763,7 +763,8 @@ static int git_futils_find_in_dirlist(
continue
;
GITERR_CHECK_ERROR
(
git_buf_set
(
path
,
scan
,
len
));
GITERR_CHECK_ERROR
(
git_buf_joinpath
(
path
,
path
->
ptr
,
name
));
if
(
name
)
GITERR_CHECK_ERROR
(
git_buf_joinpath
(
path
,
path
->
ptr
,
name
));
if
(
git_path_exists
(
path
->
ptr
))
return
0
;
...
...
@@ -792,6 +793,12 @@ int git_futils_find_xdg_file(git_buf *path, const char *filename)
path
,
filename
,
GIT_FUTILS_DIR_XDG
,
"global/xdg"
);
}
int
git_futils_find_template_dir
(
git_buf
*
path
)
{
return
git_futils_find_in_dirlist
(
path
,
NULL
,
GIT_FUTILS_DIR_TEMPLATE
,
"template"
);
}
int
git_futils_fake_symlink
(
const
char
*
old
,
const
char
*
new
)
{
int
retcode
=
GIT_ERROR
;
...
...
src/fileops.h
View file @
a025907e
...
...
@@ -306,6 +306,14 @@ extern int git_futils_find_xdg_file(git_buf *path, const char *filename);
*/
extern
int
git_futils_find_system_file
(
git_buf
*
path
,
const
char
*
filename
);
/**
* Find template directory.
*
* @param path buffer to write the full path into
* @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error
*/
extern
int
git_futils_find_template_dir
(
git_buf
*
path
);
typedef
enum
{
GIT_FUTILS_DIR_SYSTEM
=
0
,
GIT_FUTILS_DIR_GLOBAL
=
1
,
...
...
src/repository.c
View file @
a025907e
...
...
@@ -33,8 +33,6 @@
#define GIT_REPO_VERSION 0
#define GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
static
void
set_odb
(
git_repository
*
repo
,
git_odb
*
odb
)
{
if
(
odb
)
{
...
...
@@ -1136,6 +1134,9 @@ static int repo_init_structure(
if
(
external_tpl
)
{
git_config
*
cfg
;
const
char
*
tdir
;
git_buf
template_buf
=
GIT_BUF_INIT
;
git_futils_find_template_dir
(
&
template_buf
);
if
(
opts
->
template_path
)
tdir
=
opts
->
template_path
;
...
...
@@ -1150,7 +1151,7 @@ static int repo_init_structure(
return
error
;
giterr_clear
();
tdir
=
GIT_TEMPLATE_DIR
;
tdir
=
template_buf
.
ptr
;
}
error
=
git_futils_cp_r
(
tdir
,
repo_dir
,
...
...
@@ -1158,14 +1159,17 @@ static int repo_init_structure(
GIT_CPDIR_SIMPLE_TO_MODE
,
dmode
);
if
(
error
<
0
)
{
if
(
strcmp
(
tdir
,
GIT_TEMPLATE_DIR
)
!=
0
)
if
(
strcmp
(
tdir
,
template_buf
.
ptr
)
!=
0
)
{
git_buf_free
(
&
template_buf
);
return
error
;
}
/* if template was default, ignore error and use internal */
giterr_clear
();
external_tpl
=
false
;
error
=
0
;
}
git_buf_free
(
&
template_buf
);
}
/* Copy internal template
...
...
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