git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Krefting <peter@softwolves.pp.se>
To: Git <git@vger.kernel.org>
Subject: [PATCH 1/2] [RFC] Detect attempts at calling git init specifying a remote repository.
Date: Fri, 12 Nov 2010 12:27:35 +0100	[thread overview]
Message-ID: <3f7d07a2b3a02c1d3f864d2a17f3b8808890a4d1.1289561504.git.peter@softwolves.pp.se> (raw)
In-Reply-To: <cover.1289561504.git.peter@softwolves.pp.se>

We can only initialize local repositories, so bail out immediately if the
user tries to specify a remote repository.
---
 builtin/init-db.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 9d4886c..f80ff08 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -435,7 +435,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 		int mkdir_tried = 0;
 	retry:
 		if (chdir(argv[0]) < 0) {
-			if (!mkdir_tried) {
+			if (is_url(argv[0]) || strchr(argv[0], '@') != NULL || (strchr(argv[0], ':') != NULL && !has_dos_drive_prefix(argv[0]))) {
+				/*
+				 * We were passed a remote repository specification.
+				 */
+				die("Cannot initialize remote repository '%s'", argv[0]);
+			} else if (!mkdir_tried) {
 				int saved;
 				/*
 				 * At this point we haven't read any configuration,
-- 
1.7.3

  reply	other threads:[~2010-11-12 11:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-12 11:31 [PATCH 0/2] RFC: Better handling of git init remote-spec Peter Krefting
2010-11-12 11:27 ` Peter Krefting [this message]
2010-11-16 17:57   ` [PATCH 1/2] [RFC] Detect attempts at calling git init specifying a remote repository Junio C Hamano
2010-11-16 20:10     ` Peter Krefting
2010-11-12 11:30 ` [PATCH 2/2] [WIP] Allow running git init on a remote repository specification Peter Krefting
2010-11-13 21:29   ` Sverre Rabbelier
2010-11-16  5:33     ` Peter Krefting
2010-11-16 17:58       ` Junio C Hamano
2010-11-16 20:12         ` Peter Krefting

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=3f7d07a2b3a02c1d3f864d2a17f3b8808890a4d1.1289561504.git.peter@softwolves.pp.se \
    --to=peter@softwolves.pp.se \
    --cc=git@vger.kernel.org \
    /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).