Define url_parse, a general parsing function that supports all Git URLs
including scp style URLs such as hostname:~user/repo.
It is adapted from the algorithm in connect.c's parse_connect_url
and reuses the shared enum url_scheme and url_get_scheme function
that previous commits made available in url.h. The new parser and
the connect path agree on scheme classification. url_parse has the
same interface as url_normalize and uses the same data structures.
Both functions accept the same URL forms with one deliberate
exception. Bare local paths such as "/abs/path", "./rel"
or "repo" are accepted by parse_connect_url as URL_SCHEME_LOCAL,
but rejected by url_parse because url_normalize requires a URL
with a scheme://host form. A consumer that wants to handle both
URLs and local paths needs to dispatch on url_is_local_not_ssh
before calling url_parse, just as the connect path does internally.
The duplication with parse_connect_url is intentional.
The two functions have different contracts:
- parse_connect_url
Calls die() on an unknown scheme
and returns NUL-terminated host/path
strings for the connect path
- url_parse
Returns NULL on failure while populating
out_info->err, and exposes components
as offset/length pairs into the normalized
URL buffer, matching url_normalize.
Reconciling both is possible, but not in the scope
of the current patch set.
Signed-off-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||
|---|---|---|
| .. | ||
| clar | ||
| .gitignore | ||
| generate-clar-decls.sh | ||
| generate-clar-suites.sh | ||
| lib-oid.c | ||
| lib-oid.h | ||
| lib-reftable.c | ||
| lib-reftable.h | ||
| test-lib.c | ||
| test-lib.h | ||
| u-ctype.c | ||
| u-dir.c | ||
| u-example-decorate.c | ||
| u-hash.c | ||
| u-hashmap.c | ||
| u-list-objects-filter-options.c | ||
| u-mem-pool.c | ||
| u-oid-array.c | ||
| u-oidmap.c | ||
| u-oidtree.c | ||
| u-prio-queue.c | ||
| u-reftable-basics.c | ||
| u-reftable-block.c | ||
| u-reftable-merged.c | ||
| u-reftable-pq.c | ||
| u-reftable-readwrite.c | ||
| u-reftable-record.c | ||
| u-reftable-stack.c | ||
| u-reftable-table.c | ||
| u-reftable-tree.c | ||
| u-strbuf.c | ||
| u-strcmp-offset.c | ||
| u-string-list.c | ||
| u-strvec.c | ||
| u-trailer.c | ||
| u-urlmatch-normalization.c | ||
| u-utf8-width.c | ||
| unit-test.c | ||
| unit-test.h | ||