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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:03

Peter Krefting [off-list ref] writes:
quoted hunk
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.
Or a directory with ':' in its pathname, no?

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

From: Peter Krefting <hidden>
Date: 2016-06-15 22:50:03

Junio C Hamano:
quoted
--- 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.
Or a directory with ':' in its pathname, no?
Indeed. Don't do that, then :-)

Seriously, though, I tried finding an API that checked if the pathspec is local or remote, but I was unable to. Is there one I should use instead?

-- 
\\// Peter - http://www.softwolves.pp.se/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help