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
fccadba2
Commit
fccadba2
authored
Dec 29, 2013
by
Linquize
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept 'submodule.*.fetchRecurseSubmodules' config 'on-demand' value
parent
868563cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
14 deletions
+54
-14
include/git2/submodule.h
+15
-2
src/submodule.c
+38
-11
src/submodule.h
+1
-1
No files found.
include/git2/submodule.h
View file @
fccadba2
...
@@ -105,6 +105,19 @@ typedef enum {
...
@@ -105,6 +105,19 @@ typedef enum {
GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0)
GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0)
/**
/**
* Options for submodule recurse.
*
* * GIT_SUBMODULE_RECURSE_NO - do no recurse into submodules
* * GIT_SUBMODULE_RECURSE_YES - recurse into submodules
* * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when commit not already in local clone
*/
typedef
enum
{
GIT_SUBMODULE_RECURSE_NO
=
0
,
GIT_SUBMODULE_RECURSE_YES
=
1
,
GIT_SUBMODULE_RECURSE_ONDEMAND
=
2
,
}
git_submodule_recurse_t
;
/**
* Lookup submodule information by name or path.
* Lookup submodule information by name or path.
*
*
* Given either the submodule name or path (they are usually the same), this
* Given either the submodule name or path (they are usually the same), this
...
@@ -410,7 +423,7 @@ GIT_EXTERN(git_submodule_update_t) git_submodule_set_update(
...
@@ -410,7 +423,7 @@ GIT_EXTERN(git_submodule_update_t) git_submodule_set_update(
*
*
* @return 0 if fetchRecurseSubmodules is false, 1 if true
* @return 0 if fetchRecurseSubmodules is false, 1 if true
*/
*/
GIT_EXTERN
(
in
t
)
git_submodule_fetch_recurse_submodules
(
GIT_EXTERN
(
git_submodule_recurse_
t
)
git_submodule_fetch_recurse_submodules
(
git_submodule
*
submodule
);
git_submodule
*
submodule
);
/**
/**
...
@@ -426,7 +439,7 @@ GIT_EXTERN(int) git_submodule_fetch_recurse_submodules(
...
@@ -426,7 +439,7 @@ GIT_EXTERN(int) git_submodule_fetch_recurse_submodules(
*/
*/
GIT_EXTERN
(
int
)
git_submodule_set_fetch_recurse_submodules
(
GIT_EXTERN
(
int
)
git_submodule_set_fetch_recurse_submodules
(
git_submodule
*
submodule
,
git_submodule
*
submodule
,
in
t
fetch_recurse_submodules
);
git_submodule_recurse_
t
fetch_recurse_submodules
);
/**
/**
* Copy submodule info into ".git/config" file.
* Copy submodule info into ".git/config" file.
...
...
src/submodule.c
View file @
fccadba2
...
@@ -43,6 +43,12 @@ static git_cvar_map _sm_ignore_map[] = {
...
@@ -43,6 +43,12 @@ static git_cvar_map _sm_ignore_map[] = {
{
GIT_CVAR_TRUE
,
NULL
,
GIT_SUBMODULE_IGNORE_ALL
},
{
GIT_CVAR_TRUE
,
NULL
,
GIT_SUBMODULE_IGNORE_ALL
},
};
};
static
git_cvar_map
_sm_recurse_map
[]
=
{
{
GIT_CVAR_STRING
,
"on-demand"
,
GIT_SUBMODULE_RECURSE_ONDEMAND
},
{
GIT_CVAR_FALSE
,
NULL
,
GIT_SUBMODULE_RECURSE_NO
},
{
GIT_CVAR_TRUE
,
NULL
,
GIT_SUBMODULE_RECURSE_YES
},
};
static
kh_inline
khint_t
str_hash_no_trailing_slash
(
const
char
*
s
)
static
kh_inline
khint_t
str_hash_no_trailing_slash
(
const
char
*
s
)
{
{
khint_t
h
;
khint_t
h
;
...
@@ -428,6 +434,15 @@ const char *git_submodule_update_to_str(git_submodule_update_t update)
...
@@ -428,6 +434,15 @@ const char *git_submodule_update_to_str(git_submodule_update_t update)
return
NULL
;
return
NULL
;
}
}
const
char
*
git_submodule_recurse_to_str
(
git_submodule_recurse_t
recurse
)
{
int
i
;
for
(
i
=
0
;
i
<
(
int
)
ARRAY_SIZE
(
_sm_recurse_map
);
++
i
)
if
(
_sm_recurse_map
[
i
].
map_value
==
recurse
)
return
_sm_recurse_map
[
i
].
str_match
;
return
NULL
;
}
int
git_submodule_save
(
git_submodule
*
submodule
)
int
git_submodule_save
(
git_submodule
*
submodule
)
{
{
int
error
=
0
;
int
error
=
0
;
...
@@ -469,10 +484,10 @@ int git_submodule_save(git_submodule *submodule)
...
@@ -469,10 +484,10 @@ int git_submodule_save(git_submodule *submodule)
if
(
error
<
0
)
if
(
error
<
0
)
goto
cleanup
;
goto
cleanup
;
if
(
(
error
=
submodule_config_key_trunc_puts
(
if
(
!
(
error
=
submodule_config_key_trunc_puts
(
&
key
,
"fetchRecurseSubmodules"
))
&&
&
key
,
"fetchRecurseSubmodules"
))
<
0
||
(
val
=
git_submodule_recurse_to_str
(
submodule
->
fetch_recurse
))
!=
NULL
)
(
error
=
git_config_file_set_string
(
error
=
git_config_file_set_string
(
mods
,
key
.
ptr
,
val
);
mods
,
key
.
ptr
,
submodule
->
fetch_recurse
?
"true"
:
"false"
))
<
0
)
if
(
error
<
0
)
goto
cleanup
;
goto
cleanup
;
/* update internal defaults */
/* update internal defaults */
...
@@ -610,7 +625,7 @@ git_submodule_update_t git_submodule_set_update(
...
@@ -610,7 +625,7 @@ git_submodule_update_t git_submodule_set_update(
return
old
;
return
old
;
}
}
in
t
git_submodule_fetch_recurse_submodules
(
git_submodule_recurse_
t
git_submodule_fetch_recurse_submodules
(
git_submodule
*
submodule
)
git_submodule
*
submodule
)
{
{
assert
(
submodule
);
assert
(
submodule
);
...
@@ -619,14 +634,14 @@ int git_submodule_fetch_recurse_submodules(
...
@@ -619,14 +634,14 @@ int git_submodule_fetch_recurse_submodules(
int
git_submodule_set_fetch_recurse_submodules
(
int
git_submodule_set_fetch_recurse_submodules
(
git_submodule
*
submodule
,
git_submodule
*
submodule
,
in
t
fetch_recurse_submodules
)
git_submodule_recurse_
t
fetch_recurse_submodules
)
{
{
int
old
;
int
old
;
assert
(
submodule
);
assert
(
submodule
);
old
=
submodule
->
fetch_recurse
;
old
=
submodule
->
fetch_recurse
;
submodule
->
fetch_recurse
=
(
fetch_recurse_submodules
!=
0
)
;
submodule
->
fetch_recurse
=
fetch_recurse_submodules
;
return
old
;
return
old
;
}
}
...
@@ -1080,6 +1095,20 @@ int git_submodule_parse_update(git_submodule_update_t *out, const char *value)
...
@@ -1080,6 +1095,20 @@ int git_submodule_parse_update(git_submodule_update_t *out, const char *value)
return
0
;
return
0
;
}
}
int
git_submodule_parse_recurse
(
git_submodule_recurse_t
*
out
,
const
char
*
value
)
{
int
val
;
if
(
git_config_lookup_map_value
(
&
val
,
_sm_recurse_map
,
ARRAY_SIZE
(
_sm_recurse_map
),
value
)
<
0
)
{
*
out
=
GIT_SUBMODULE_RECURSE_YES
;
return
submodule_config_error
(
"recurse"
,
value
);
}
*
out
=
(
git_submodule_recurse_t
)
val
;
return
0
;
}
static
int
submodule_load_from_config
(
static
int
submodule_load_from_config
(
const
git_config_entry
*
entry
,
void
*
payload
)
const
git_config_entry
*
entry
,
void
*
payload
)
{
{
...
@@ -1166,10 +1195,8 @@ static int submodule_load_from_config(
...
@@ -1166,10 +1195,8 @@ static int submodule_load_from_config(
sm
->
update_default
=
sm
->
update
;
sm
->
update_default
=
sm
->
update
;
}
}
else
if
(
strcasecmp
(
property
,
"fetchRecurseSubmodules"
)
==
0
)
{
else
if
(
strcasecmp
(
property
,
"fetchRecurseSubmodules"
)
==
0
)
{
if
(
git__parse_bool
(
&
sm
->
fetch_recurse
,
value
)
<
0
)
{
if
(
git_submodule_parse_recurse
(
&
sm
->
fetch_recurse
,
value
)
<
0
)
error
=
submodule_config_error
(
"fetchRecurseSubmodules"
,
value
);
return
-
1
;
goto
done
;
}
}
}
else
if
(
strcasecmp
(
property
,
"ignore"
)
==
0
)
{
else
if
(
strcasecmp
(
property
,
"ignore"
)
==
0
)
{
if
((
error
=
git_submodule_parse_ignore
(
&
sm
->
ignore
,
value
))
<
0
)
if
((
error
=
git_submodule_parse_ignore
(
&
sm
->
ignore
,
value
))
<
0
)
...
...
src/submodule.h
View file @
fccadba2
...
@@ -85,7 +85,7 @@ struct git_submodule {
...
@@ -85,7 +85,7 @@ struct git_submodule {
git_submodule_update_t
update_default
;
git_submodule_update_t
update_default
;
git_submodule_ignore_t
ignore
;
git_submodule_ignore_t
ignore
;
git_submodule_ignore_t
ignore_default
;
git_submodule_ignore_t
ignore_default
;
in
t
fetch_recurse
;
git_submodule_recurse_
t
fetch_recurse
;
/* internal information */
/* internal information */
git_repository
*
repo
;
git_repository
*
repo
;
...
...
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