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
52fba18f
Commit
52fba18f
authored
Mar 10, 2014
by
Jan Melcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add git_submodule_resolve_url()
parent
6de018bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
10 deletions
+30
-10
include/git2/submodule.h
+10
-0
src/submodule.c
+20
-10
No files found.
include/git2/submodule.h
View file @
52fba18f
...
@@ -272,6 +272,16 @@ GIT_EXTERN(const char *) git_submodule_path(git_submodule *submodule);
...
@@ -272,6 +272,16 @@ GIT_EXTERN(const char *) git_submodule_path(git_submodule *submodule);
GIT_EXTERN
(
const
char
*
)
git_submodule_url
(
git_submodule
*
submodule
);
GIT_EXTERN
(
const
char
*
)
git_submodule_url
(
git_submodule
*
submodule
);
/**
/**
* Resolve a submodule url relative to the given repository.
*
* @param out buffer to store the absolute submodule url in
* @param repository Pointer to repository object
* @param url Relative url
* @return 0 or an error code
*/
GIT_EXTERN
(
int
)
git_submodule_resolve_url
(
git_buf
*
out
,
git_repository
*
repo
,
const
char
*
url
);
/**
* Get the branch for the submodule.
* Get the branch for the submodule.
*
*
* @param submodule Pointer to submodule object
* @param submodule Pointer to submodule object
...
...
src/submodule.c
View file @
52fba18f
...
@@ -229,16 +229,7 @@ int git_submodule_add_setup(
...
@@ -229,16 +229,7 @@ int git_submodule_add_setup(
}
}
/* resolve parameters */
/* resolve parameters */
error
=
git_submodule_resolve_url
(
&
real_url
,
repo
,
url
);
if
(
url
[
0
]
==
'.'
&&
(
url
[
1
]
==
'/'
||
(
url
[
1
]
==
'.'
&&
url
[
2
]
==
'/'
)))
{
if
(
!
(
error
=
lookup_head_remote
(
&
real_url
,
repo
)))
error
=
git_path_apply_relative
(
&
real_url
,
url
);
}
else
if
(
strchr
(
url
,
':'
)
!=
NULL
||
url
[
0
]
==
'/'
)
{
error
=
git_buf_sets
(
&
real_url
,
url
);
}
else
{
giterr_set
(
GITERR_SUBMODULE
,
"Invalid format for submodule URL"
);
error
=
-
1
;
}
if
(
error
)
if
(
error
)
goto
cleanup
;
goto
cleanup
;
...
@@ -533,6 +524,25 @@ const char *git_submodule_url(git_submodule *submodule)
...
@@ -533,6 +524,25 @@ const char *git_submodule_url(git_submodule *submodule)
return
submodule
->
url
;
return
submodule
->
url
;
}
}
int
git_submodule_resolve_url
(
git_buf
*
out
,
git_repository
*
repo
,
const
char
*
url
)
{
assert
(
url
);
int
error
=
0
;
if
(
url
[
0
]
==
'.'
&&
(
url
[
1
]
==
'/'
||
(
url
[
1
]
==
'.'
&&
url
[
2
]
==
'/'
)))
{
if
(
!
(
error
=
lookup_head_remote
(
out
,
repo
)))
error
=
git_path_apply_relative
(
out
,
url
);
}
else
if
(
strchr
(
url
,
':'
)
!=
NULL
||
url
[
0
]
==
'/'
)
{
error
=
git_buf_sets
(
out
,
url
);
}
else
{
giterr_set
(
GITERR_SUBMODULE
,
"Invalid format for submodule URL"
);
error
=
-
1
;
}
return
error
;
}
const
char
*
git_submodule_branch
(
git_submodule
*
submodule
)
const
char
*
git_submodule_branch
(
git_submodule
*
submodule
)
{
{
assert
(
submodule
);
assert
(
submodule
);
...
...
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