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

[PATCH 1/2] [RFC] Detect attempts at calling git init specifying a remote repository.

From
Peter Krefting <peter@softwolves.pp.se>
Date
Nov 12, 2010, 11:27 UTC
Message-ID
<3f7d07a2b3a02c1d3f864d2a17f3b8808890a4d1.1289561504.git.peter@softwolves.pp.se>
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
Previous: Peter KreftingNext: Junio C Hamano
Message 2 of 9 in “RFC: Better handling of git init remote-spec”
  1. 0/2 RFC: Better handling of git init remote-specPeter Krefting, Nov 12, 2010
  2. 1/2 [RFC] Detect attempts at calling git init specifying a remote repository.Peter Krefting, Nov 12, 2010
  3. Junio C HamanoNov 16, 2010
  4. Peter KreftingNov 16, 2010
  5. 2/2 [WIP] Allow running git init on a remote repository specification.Peter Krefting, Nov 12, 2010
  6. Sverre RabbelierNov 13, 2010
  7. Peter KreftingNov 16, 2010
  8. Junio C HamanoNov 16, 2010
  9. Peter KreftingNov 16, 2010

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.