# Re: git equivalent to svn info?

4 messages from 2008-09-18 to 2008-09-22. Participants: Junio C Hamano, Michael J Gruber.
Thread: https://gitlist.dev/t/15570

## Junio C Hamano, 2008-09-18 05:50

Subject: Re: git equivalent to svn info?
Message-ID: <7v4p4e0zpg.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4p4e0zpg.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080917224856.GT10360@machine.or.cz>

```
Petr Baudis <pasky-+ZI9xUNit7I@public.gmane.org> writes:

> On Thu, Sep 18, 2008 at 10:13:34AM +1200, Francois Marier wrote:
>> On Wed, 2008-09-17 at 14:46 -0700, skillzero-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>> > Is there an easy way with git to get the URL of the repository that
>> > you cloned from, similar to what svn info shows for a subversion
>> > repository? I see it's stored in [remote "origin"]->url section of
>> > the .git/config, but I was hoping for an easy-to-remember command to
>> > display it.
>> 
>> I normally use "git remote show origin"
>
> You can also get a quick overview with git remote -v.

Ah, that reminds me...

It is Ok to have more than one URL defined for a remote if you use that
remote for push, but "git remote -v" complains, like this:

    $ git remote -v
    warning: Remote builders has more than one URL
    builders        box-fc5:git/
    ko-private	m.kernel.org:git/

when I have 3 URLs (box-fc5, box-fc7 and box-fc9) for "builders" remote to
push into.

Could somebody fix this, please?

```

## Michael J Gruber, 2008-09-18 16:11

Subject: [PATCH] make "git remote" report multiple URLs
Message-ID: <1221754262-15772-1-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1221754262-15772-1-git-send-email-git%40drmicha.warpmail.net
In-Reply-To: <7v4p4e0zpg.fsf@gitster.siamese.dyndns.org>

```
This patch makes "git remote -v" and "git remote show" report multiple URLs
rather than warn about them. Multiple URLs are OK for pushing into
multiple repos simultaneously.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 builtin-remote.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

This passes all tests, so I think the new output does not break anything.

diff --git a/builtin-remote.c b/builtin-remote.c
index 01945a8..ae560e7 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -652,10 +652,13 @@ static int get_one_entry(struct remote *remote, void *priv)
 {
 	struct string_list *list = priv;
 
-	string_list_append(remote->name, list)->util = remote->url_nr ?
-		(void *)remote->url[0] : NULL;
-	if (remote->url_nr > 1)
-		warning("Remote %s has more than one URL", remote->name);
+	if (remote->url_nr > 0) {
+		int i;
+
+		for (i = 0; i < remote->url_nr; i++)
+			string_list_append(remote->name, list)->util = (void *)remote->url[i];
+	} else
+		string_list_append(remote->name, list)->util = NULL;
 
 	return 0;
 }
-- 
1.6.0.2.249.g97d7f

```

## Junio C Hamano, 2008-09-19 20:28

Subject: Re: [PATCH] make "git remote" report multiple URLs
Message-ID: <7vej3fswwe.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vej3fswwe.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1221754262-15772-1-git-send-email-git@drmicha.warpmail.net>

```
Michael J Gruber <git@drmicha.warpmail.net> writes:

> This patch makes "git remote -v" and "git remote show" report multiple URLs
> rather than warn about them. Multiple URLs are OK for pushing into
> multiple repos simultaneously.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---

Nice.  But this makes "git remote show" to give duplicate results, which
you might want to cull.

>  builtin-remote.c |   11 +++++++----
>  1 files changed, 7 insertions(+), 4 deletions(-)
>
> This passes all tests, so I think the new output does not break anything.

Or just there is no existing tests that verify the output from this command.

> diff --git a/builtin-remote.c b/builtin-remote.c
> index 01945a8..ae560e7 100644
> --- a/builtin-remote.c
> +++ b/builtin-remote.c
> @@ -652,10 +652,13 @@ static int get_one_entry(struct remote *remote, void *priv)
>  {
>  	struct string_list *list = priv;
>  
> -	string_list_append(remote->name, list)->util = remote->url_nr ?
> -		(void *)remote->url[0] : NULL;
> -	if (remote->url_nr > 1)
> -		warning("Remote %s has more than one URL", remote->name);
> +	if (remote->url_nr > 0) {
> +		int i;
> +
> +		for (i = 0; i < remote->url_nr; i++)
> +			string_list_append(remote->name, list)->util = (void *)remote->url[i];
> +	} else
> +		string_list_append(remote->name, list)->util = NULL;
>  
>  	return 0;
>  }
> -- 
> 1.6.0.2.249.g97d7f

```

## Michael J Gruber, 2008-09-22 08:57

Subject: [PATCH v2] make "git remote" report multiple URLs
Message-ID: <1222073871-495-1-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1222073871-495-1-git-send-email-git%40drmicha.warpmail.net
In-Reply-To: <7vej3fswwe.fsf@gitster.siamese.dyndns.org>

```
This patch makes "git remote -v" and "git remote show" report multiple URLs
rather than warn about them. Multiple URLs are OK for pushing into
multiple repos simultaneously. Without "-v" each repo is shown once only.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 builtin-remote.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

Change in v2: report each repo once only if "-v" is not used (i.e. URL is not shown),
as requested by JC.

JC wrote:
> MJG wrote:
>> This passes all tests, so I think the new output does not break anything.

> Or just there is no existing tests that verify the output from this command.

JC, sounds as if you're a mathematician, as well ;)

diff --git a/builtin-remote.c b/builtin-remote.c
index 01945a8..1e2edc2 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -652,10 +652,13 @@ static int get_one_entry(struct remote *remote, void *priv)
 {
 	struct string_list *list = priv;
 
-	string_list_append(remote->name, list)->util = remote->url_nr ?
-		(void *)remote->url[0] : NULL;
-	if (remote->url_nr > 1)
-		warning("Remote %s has more than one URL", remote->name);
+	if (remote->url_nr > 0) {
+		int i;
+
+		for (i = 0; i < remote->url_nr; i++)
+			string_list_append(remote->name, list)->util = (void *)remote->url[i];
+	} else
+		string_list_append(remote->name, list)->util = NULL;
 
 	return 0;
 }
@@ -671,10 +674,14 @@ static int show_all(void)
 		sort_string_list(&list);
 		for (i = 0; i < list.nr; i++) {
 			struct string_list_item *item = list.items + i;
-			printf("%s%s%s\n", item->string,
-				verbose ? "\t" : "",
-				verbose && item->util ?
-					(const char *)item->util : "");
+			if (verbose)
+				printf("%s\t%s\n", item->string,
+					item->util ? (const char *)item->util : "");
+			else {
+				if (i && !strcmp((item - 1)->string, item->string))
+					continue;
+				printf("%s\n", item->string);
+			}
 		}
 	}
 	return result;
-- 
1.6.0.2.287.g3791f

```
