Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin: implement, document and test url-parse #1715

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Documentation: describe the url-parse builtin
The new url-parse builtin validates git URLs
and optionally extracts their components.

Signed-off-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
  • Loading branch information
matheusmoreira committed Apr 28, 2024
commit abda074aeef2ffb20d2156b5f24f47745b6f3134
59 changes: 59 additions & 0 deletions Documentation/git-url-parse.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
git-url-parse(1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Ghanshyam Thakkar wrote (reply to this):

On Sun, 28 Apr 2024, Matheus Afonso Martins Moreira via GitGitGadget <gitgitgadget@gmail.com> wrote:
> +* Print the path:
> ++
> +------------
> +$ git url-parse --component path https://example.com/user/repo
> +/usr/repo

s/usr/user/

Thanks.

================

NAME
----
git-url-parse - Parse and extract git URL components

SYNOPSIS
--------
[verse]
'git url-parse' [<options>] [--] <url>...

DESCRIPTION
-----------

Git supports many ways to specify URLs, some of them non-standard.
For example, git supports the scp style [user@]host:[path] format.
This command eases interoperability with git URLs by enabling the
parsing and extraction of the components of all git URLs.

OPTIONS
-------

-c <arg>::
--component <arg>::
Extract the `<arg>` component from the given git URLs.
`<arg>` can be one of:
`protocol`, `user`, `password`, `host`, `port`, `path`.

EXAMPLES
--------

* Print the host name:
+
------------
$ git url-parse --component host https://example.com/user/repo
example.com
------------

* Print the path:
+
------------
$ git url-parse --component path https://example.com/user/repo
/usr/repo
$ git url-parse --component path example.com:~user/repo
~user/repo
$ git url-parse --component path example.com:user/repo
/user/repo
------------

* Validate URLs without outputting anything:
+
------------
$ git url-parse https://example.com/user/repo example.com:~user/repo
------------

GIT
---
Part of the linkgit:git[1] suite