remote: move relative_url()
This method was initially written in 63e95beb0
(submodule: port
resolve_relative_url from shell to C, 2016-05-15). As we will need
similar functionality in the bundle URI feature, extract this to be
available in remote.h.
The code is almost exactly the same, except for the following trivial
differences:
* Fix whitespace and wrapping issues with the prototype and argument
lists.
* Let's call starts_with_dot_{,dot_}slash_native() instead of the
functionally identical "starts_with_dot_{,dot_}slash()" wrappers
"builtin/submodule--helper.c".
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
c1d024b843
commit
1d04e719e7
31
remote.h
31
remote.h
@ -409,4 +409,35 @@ int parseopt_push_cas_option(const struct option *, const char *arg, int unset);
|
||||
int is_empty_cas(const struct push_cas_option *);
|
||||
void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
|
||||
|
||||
/*
|
||||
* The `url` argument is the URL that navigates to the submodule origin
|
||||
* repo. When relative, this URL is relative to the superproject origin
|
||||
* URL repo. The `up_path` argument, if specified, is the relative
|
||||
* path that navigates from the submodule working tree to the superproject
|
||||
* working tree. Returns the origin URL of the submodule.
|
||||
*
|
||||
* Return either an absolute URL or filesystem path (if the superproject
|
||||
* origin URL is an absolute URL or filesystem path, respectively) or a
|
||||
* relative file system path (if the superproject origin URL is a relative
|
||||
* file system path).
|
||||
*
|
||||
* When the output is a relative file system path, the path is either
|
||||
* relative to the submodule working tree, if up_path is specified, or to
|
||||
* the superproject working tree otherwise.
|
||||
*
|
||||
* NEEDSWORK: This works incorrectly on the domain and protocol part.
|
||||
* remote_url url outcome expectation
|
||||
* http://a.com/b ../c http://a.com/c as is
|
||||
* http://a.com/b/ ../c http://a.com/c same as previous line, but
|
||||
* ignore trailing slash in url
|
||||
* http://a.com/b ../../c http://c error out
|
||||
* http://a.com/b ../../../c http:/c error out
|
||||
* http://a.com/b ../../../../c http:c error out
|
||||
* http://a.com/b ../../../../../c .:c error out
|
||||
* NEEDSWORK: Given how chop_last_dir() works, this function is broken
|
||||
* when a local part has a colon in its path component, too.
|
||||
*/
|
||||
char *relative_url(const char *remote_url, const char *url,
|
||||
const char *up_path);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user