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

Re: [RFC PATCH] remote: add --fetch option to git remote set-url

From
Denton Liu <liu.denton@gmail.com>
Date
Oct 30, 2018, 07:56 UTC
Message-ID
<20181030075653.GA4114@archbookpro.localdomain>
In-Reply-To
<xmqqftwp47nb.fsf@gitster-ct.c.googlers.com>
On Mon, Oct 29, 2018 at 02:57:28PM +0900, Junio C Hamano wrote:
Show 12 quoted lines
> Denton Liu <liu.denton@gmail.com> writes:
> 
> > This adds the --fetch option to `git remote set-url` such that when
> > executed we move the remote.*.url to remote.*.pushurl and set
> > remote.*.url to the given url argument.
> >
> 
> I suspect this is a horrible idea from end-user's point of view.
> "set-url --push" is used to SET pushURL instead of setting URL and
> does not MOVE anything.  Why should the end user expect and remember
> "set-url --fetch" works very differently?  
>

I agree, `--fetch` is a terrible name for this. Perhaps a better name would be something like `--fetch-behavior` or `--keep-push` so that the behaviour is more transparent for the end-user. Either way, I think we can decide on the name later.

Show 44 quoted lines
> If there is a need for a "--move-URL-to-pushURL-and-set-pushURL"
> short-hand to avoid having to use two commands
> 
> 	git remote set-url --push $(git remote --get-url origin) origin
> 	git remote set-url $there origin
> 
> it should not be called "--fetch", which has a strong connotation of
> being an opposite of existing "--push", but something else.  And
> then we need to ask ourselves if we also need such a short-hand to
> "--move-pushURL-to-URL-and-set-URL" operation.  The answer to the
> last question would help us decide if (1) this combined operation is
> a good idea to begin with and (2) what is the good name for such an
> operation.
> 
> Assuming that the short-hand operation is a good idea in the first
> place, without deciding what the externally visible good name for it
> is, let's read on.
> 
> > +	/*
> > +	 * If add_mode, we will be appending to remote.*.url so we shouldn't move the urls over.
> > +	 * If pushurls exist, we don't need to move the urls over to pushurl.
> > +	 */
> > +	move_fetch_to_push = fetch_mode && !add_mode && !remote->pushurl_nr;
> 
> Should this kind of "the user asked for --fetch, but sometimes it is
> not appropriate to honor that request" be done silently like this?
> 
> Earlier you had a check like this:
> 
> > +	if (push_mode && fetch_mode)
> > +		die(_("--push --fetch doesn't make sense"));
> 
> If a request to "--fetch" is ignored when "--add" is given, for
> example, shouldn't the combination also be diagnosed as "not making
> sense, we'd ignore your wish to use the --fetch option"?  Similarly
> for the case where there already is pushurl defined for the remote.
> 
> This is a different tangent on the same line, but it could be that
> the user wants to have two (or more) pushURLs because the user wants
> to push to two remotes at the same time with "git push this-remote",
> so silently ignoring "--force" may not be the right thing in the
> first place.  We may instead need to make the value of URL to an
> extra pushURL entry (if we had one, we now have two).
>

Perhaps I should motivate the use-case for this option. There have been times when I've had the URL set to something but no pushURL. I've wanted to only change the fetching URL and keep the pushing URL the same but unfortunately, there's no way to do that because of the url/pushurl split is set up.

My implementation of --fetch is supposed to emulate what would happen if git were implemented with fetchurl/pushurl instead. Does the patch make more sense in this context?

Please let me know if you think that the concept behind this patch is a good idea. Thanks!

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 9 in “remote: add --fetch option to git remote set-url”
  1. remote: add --fetch option to git remote set-urlDenton Liu, Oct 27, 2018
  2. Junio C HamanoOct 29, 2018
  3. Denton LiuOct 30, 2018
  4. Junio C HamanoOct 30, 2018
  5. remote: add --save-push option to git remote set-urlDenton Liu, Nov 9, 2018
  6. Junio C HamanoNov 9, 2018
  7. remote: add --save-to-push option to git remote set-urlDenton Liu, Nov 9, 2018
  8. Junio C HamanoNov 13, 2018
  9. remote: add --save-to-push option to git remote set-urlDenton Liu, Dec 10, 2018

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.