From: Johannes Schindelin <johannes.schindelin@gmx.de>
To: gitster@pobox.com
Cc: anapsix@random.io, git@vger.kernel.org
Subject: [PATCH v2 0/2] Let `git remote add` play nicer with url.<url>.insteadOf
Date: Tue, 23 Dec 2014 14:24:50 +0100 (CET) [thread overview]
Message-ID: <cover.1419340898.git.johannes.schindelin@gmx.de> (raw)
In-Reply-To: <20141216021900.50095.24877@random.io>
Anastas Dancha reported that it is not possible to add a remote when
there is already a url.<url>.insteadOf = <nick> setting in
$HOME/.gitconfig.
While it makes sense to prevent surprises when a user adds a remote and
it fetches from somewhere completely different, it makes less sense to
prevent adding a remote when it is actually the same that was specified
in the config.
Therefore we add just another check that let's `git remote add` continue
when the "existing" remote's URL is identical to the specified one.
Interdiff below the diffstat (the commit message was also touched up to
stop pretending that we allow adding a remote twice when the URL did not
change).
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Johannes Schindelin (2):
git remote: allow adding remotes agreeing with url.<...>.insteadOf
Add a regression test for 'git remote add <existing> <same-url>'
builtin/remote.c | 4 +++-
t/t5505-remote.sh | 5 +++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/builtin/remote.c b/builtin/remote.c
index 9168c83..b4ff468 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -180,7 +180,8 @@ static int add(int argc, const char **argv)
url = argv[1];
remote = remote_get(name);
- if (remote && (remote->url_nr > 1 || (strcmp(name, remote->url[0]) &&
+ if (remote && (remote->url_nr > 1 ||
+ (strcmp(name, remote->url[0]) &&
strcmp(url, remote->url[0])) ||
remote->fetch_refspec_nr))
die(_("remote %s already exists."), name);
--
2.0.0.rc3.9669.g840d1f9
next prev parent reply other threads:[~2014-12-23 13:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 2:30 [PATCH] remote: allow adding remote w same name as alias Anastas Dancha
2014-12-16 9:01 ` Johannes Schindelin
2014-12-16 14:57 ` Anastas Dancha
2014-12-19 9:37 ` Johannes Schindelin
2014-12-19 15:44 ` Anastas Dancha
2014-12-19 16:30 ` Michael J Gruber
2014-12-20 20:57 ` Anastas Dancha
2014-12-21 20:40 ` Johannes Schindelin
2014-12-16 9:33 ` Michael J Gruber
2014-12-22 17:06 ` [PATCH 0/2] Let `git remote add` play nicer with url.<url>.insteadOf Johannes Schindelin
2014-12-22 17:06 ` [PATCH 1/2] git remote add: allow re-adding remotes with the same URL Johannes Schindelin
2014-12-22 17:49 ` Junio C Hamano
2014-12-23 13:25 ` Johannes Schindelin
[not found] ` <CAPc5daXcXs+Sw8jr65dmLnpf6LQ6Lr34y80bxSf2AhhFyXa_mQ@mail.gmail.com>
2014-12-23 18:26 ` Johannes Schindelin
2014-12-23 18:51 ` Junio C Hamano
2014-12-22 17:06 ` [PATCH 2/2] Add a regression test for 'git remote add <existing> <same-url>' Johannes Schindelin
2014-12-23 13:24 ` Johannes Schindelin [this message]
2014-12-23 13:25 ` [PATCH v2 1/2] git remote: allow adding remotes agreeing with url.<...>.insteadOf Johannes Schindelin
2014-12-23 13:25 ` [PATCH v2 2/2] Add a regression test for 'git remote add <existing> <same-url>' Johannes Schindelin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1419340898.git.johannes.schindelin@gmx.de \
--to=johannes.schindelin@gmx.de \
--cc=anapsix@random.io \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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 NNTP newsgroup(s).