git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] Add url.<base>.pushInsteadOf: URL rewriting for push only

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 7, 2009, 07:53 UTC
Message-ID
<7vljkr2ntd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<0be9995dcd7d48c918fa75f4d9e557a6144a047c.1252306396.git.josh@joshtriplett.org>
Josh Triplett <josh@joshtriplett.org> writes:
Show 9 quoted lines
> This configuration option allows systematically rewriting fetch-only
> URLs to push-capable URLs when used with push.  For instance:
>
> [url "ssh://example.org/"]
>     pushInsteadOf = "git://example.org/"
>
> This will allow clones of "git://example.org/path/to/repo" to
> subsequently push to "ssh://example.org/path/to/repo", without manually
> configuring pushurl for that remote.
Nice.
Show 14 quoted lines
> @@ -435,12 +449,13 @@ static void alias_all_urls(void)
>  	for (i = 0; i < remotes_nr; i++) {
>  		if (!remotes[i])
>  			continue;
> -		for (j = 0; j < remotes[i]->url_nr; j++) {
> -			remotes[i]->url[j] = alias_url(remotes[i]->url[j], &rewrites);
> -		}
>  		for (j = 0; j < remotes[i]->pushurl_nr; j++) {
>  			remotes[i]->pushurl[j] = alias_url(remotes[i]->pushurl[j], &rewrites);
>  		}
> +		for (j = 0; j < remotes[i]->url_nr; j++) {
> +			remotes[i]->url[j] = alias_url(remotes[i]->url[j], &rewrites);
> +			add_pushurl_alias(remotes[i], remotes[i]->url[j]);
> +		}

Even if you have URL but not pushURL, now you get a corresponding pushURL for free by just adding pushinsteadof mapping that covers the URL without having to configue pushURL for each of them.

What happens if you already had a pair of concrete url and pushurl defined for one of your repositories (say git://git.kernel.org/pub/scm/git/git.git for fetch, ssh://x.kernel.org/pub/scm/git/git.git for push) at a site, and then upon seeing this new feature, added a pushinsteadof pattern that also covers the URL side of that pair (e.g. everything in git://git.kernel.org/ is mapped to x.kernel.org:/ namespsace)?

Do you end up pushing to both (e.g. ssh://x.kernel.org/pub/scm/git/git.git and x.kernel.org:/pub/scm/git/git.git), or in such a case, the pushURL you gave explicitly prevents the pushinsteadof to give unexpected duplicates?

Previous: Josh TriplettNext: Josh Triplett
Message 4 of 5 in “Add url.<base>.pushInsteadOf: URL rewriting for push only”
  1. 0/2 Add url.<base>.pushInsteadOf: URL rewriting for push onlyJosh Triplett, Sep 7, 2009
  2. 1/2 Wrap rewrite globals in a struct in preparation for adding another setJosh Triplett, Sep 7, 2009
  3. 2/2 Add url.<base>.pushInsteadOf: URL rewriting for push onlyJosh Triplett, Sep 7, 2009
  4. Junio C HamanoSep 7, 2009
  5. Josh TriplettSep 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.