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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]