git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: git@vger.kernel.org, anmolmago@gmail.com, briankyho@gmail.com,
	david.lu97@outlook.com, shirui.wang@hotmail.com
Subject: Re: [RFC PATCH v2] remote: add --save-push option to git remote set-url
Date: Fri, 09 Nov 2018 12:15:22 +0900	[thread overview]
Message-ID: <xmqqin1754c5.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <b910987d3aa778b39b6e27a75fe685a4797b8422.1541730538.git.liu.denton@gmail.com> (Denton Liu's message of "Thu, 8 Nov 2018 21:37:45 -0500")

Denton Liu <liu.denton@gmail.com> writes:

> This adds the --save-push 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.
>
> For example, if we have the following config:
>
> 	[remote "origin"]
> 		url = git@github.com:git/git.git
>
> `git remote set-url --save-push origin https://github.com/git/git.git`
> would change the config to the following:
>
> 	[remote "origin"]
> 		url = https://github.com/git/git.git
> 		pushurl = git@github.com:git/git.git

This sounds more like "saving to push" (i.e. what you are saving is
the existing "url" and the "push" is a shorthand for "pushURL",
which is the location the old value of "url" is aved to), not "save
(the) push(URL)".  So if adding this option makes sense, I would say
"--save-to-push" (or even "--save-to-pushURL") may be a more
appropriate name for it.

> +With `--save-push`, the current URL is saved into the push URL before setting
> +the URL to <url>. Note that this command will not work if more than one URL is
> +defined or if any push URLs are defined because behavior would be ambiguous.

Ambigous in what way?  You asked the current URL to be saved as a
pushURL, so existing pushURL destinations should not come into play,
I would think.  If there are more than one URL (not pushURL), on the
other hand, I think you have a bigger problem (where would "git fetch"
fetch from, and how would these multiple URLs are prevented from
trashing refs/remotes/$remote/* with each other's refs?), so
stopping the operation before "set-url" makes the problem worse is
probably a good idea, but I think that is true with or without this
new option.

> diff --git a/builtin/remote.c b/builtin/remote.c
> index f7edf7f2cb..0eaec7ef38 100644
> --- a/builtin/remote.c
> +++ b/builtin/remote.c
> @@ -24,8 +24,9 @@ static const char * const builtin_remote_usage[] = {
>  	N_("git remote set-branches [--add] <name> <branch>..."),
>  	N_("git remote get-url [--push] [--all] <name>"),
>  	N_("git remote set-url [--push] <name> <newurl> [<oldurl>]"),
> -	N_("git remote set-url --add <name> <newurl>"),
> -	N_("git remote set-url --delete <name> <url>"),
> +	N_("git remote set-url --add [--push] <name> <newurl>"),
> +	N_("git remote set-url --delete [--push] <name> <url>"),
> +	N_("git remote set-url --save-push <name> <url>"),
>  	NULL
>  };

Needs update?

> @@ -77,8 +78,9 @@ static const char * const builtin_remote_geturl_usage[] = {
>  
>  static const char * const builtin_remote_seturl_usage[] = {
>  	N_("git remote set-url [--push] <name> <newurl> [<oldurl>]"),
> -	N_("git remote set-url --add <name> <newurl>"),
> -	N_("git remote set-url --delete <name> <url>"),
> +	N_("git remote set-url --add [--push] <name> <newurl>"),
> +	N_("git remote set-url --delete [--push] <name> <url>"),
> +	N_("git remote set-url --save-push <name> <url>"),
>  	NULL
>  };

Needs update?

> +		if (save_push) {
> +			if (remote->url_nr != 1 || remote->pushurl_nr != 0)
> +				die(_("--save-push can only be used when one url and no pushurl is defined"), remotename);

I _think_ in the future (if this option turns out to be widely used)
people may ask for this condition to be loosened somewhat, but it is
relatively easy to start restrictive and then to loosen later, so I
think this is OK for now.


  reply	other threads:[~2018-11-09  3:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-27  8:09 [RFC PATCH] remote: add --fetch option to git remote set-url Denton Liu
2018-10-29  5:57 ` Junio C Hamano
2018-10-30  7:56   ` Denton Liu
2018-10-30 10:11     ` Junio C Hamano
2018-11-09  2:37       ` [RFC PATCH v2] remote: add --save-push " Denton Liu
2018-11-09  3:15         ` Junio C Hamano [this message]
2018-11-09  5:20           ` [PATCH v3] remote: add --save-to-push " Denton Liu
2018-11-13  9:46             ` Junio C Hamano
2018-12-10 14:15             ` [PATCH v4] " Denton Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqin1754c5.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=anmolmago@gmail.com \
    --cc=briankyho@gmail.com \
    --cc=david.lu97@outlook.com \
    --cc=git@vger.kernel.org \
    --cc=liu.denton@gmail.com \
    --cc=shirui.wang@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).