git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: bjornar@snoksrud.no
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: workdirs: cannot clone a local workdir directory
Date: Wed, 15 Jul 2015 20:25:52 +0700	[thread overview]
Message-ID: <20150715132552.GA28574@lanh> (raw)
In-Reply-To: <CA+cck7GR1Gs+OvhweQZFs0=5uKu=RwEgY=0_0CZSCDqtDWrR2A@mail.gmail.com>

On Wed, Jul 15, 2015 at 11:40:18AM +0200, Bjørnar Snoksrud wrote:
> I reported this before, but now I have a nice topic to hang it on -
> 
> I have re-reproduced the bug using a build from master as of today,
> using the new worktree commands.

Something like the following patch should work if you need it now.

Because this may conflict (in the test cases) with Eric's series to
move "git checkout --to" to "git worktree add", and because the next
release is already delayed to let "git worktree add" in, I think we
could keep this patch out of tree for now. I will split it up, add
tests and resubmit once the release is out. Please remind me if you
see nothing from me for too long.

Note to self, "git clone --reference" remains broken.

-- 8< --
diff --git a/builtin/clone.c b/builtin/clone.c
index 00535d0..0e594f1 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -373,8 +373,10 @@ static void clone_local(const char *src_repo, const char *dest_repo)
 	} else {
 		struct strbuf src = STRBUF_INIT;
 		struct strbuf dest = STRBUF_INIT;
-		strbuf_addf(&src, "%s/objects", src_repo);
-		strbuf_addf(&dest, "%s/objects", dest_repo);
+		get_common_dir(&src, src_repo);
+		get_common_dir(&dest, dest_repo);
+		strbuf_addstr(&src, "/objects");
+		strbuf_addf(&dest, "/objects");
 		copy_or_link_directory(&src, &dest, src_repo, src.len);
 		strbuf_release(&src);
 		strbuf_release(&dest);
diff --git a/path.c b/path.c
index 10f4cbf..7f7b56f 100644
--- a/path.c
+++ b/path.c
@@ -416,18 +416,22 @@ const char *enter_repo(const char *path, int strict)
 		}
 		if (!suffix[i])
 			return NULL;
-		gitfile = read_gitfile(used_path) ;
+		gitfile = read_gitfile(used_path);
 		if (gitfile)
 			strcpy(used_path, gitfile);
 		if (chdir(used_path))
 			return NULL;
 		path = validated_path;
 	}
-	else if (chdir(path))
-		return NULL;
+	else {
+		const char *gitfile = read_gitfile(used_path);
+		if (gitfile)
+			path = gitfile;
+		if (chdir(path))
+			return NULL;
+	}
 
-	if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
-	    validate_headref("HEAD") == 0) {
+	if (is_git_directory(".")) {
 		set_git_dir(".");
 		check_repository_format();
 		return path;
-- 8< --

  reply	other threads:[~2015-07-15 13:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-15  9:40 workdirs: cannot clone a local workdir directory Bjørnar Snoksrud
2015-07-15 13:25 ` Duy Nguyen [this message]
2015-08-22  0:39   ` [PATCH v2 0/5] fix local clone from a linked checkout Nguyễn Thái Ngọc Duy
2015-08-22  0:39     ` [PATCH v2 1/5] path.c: delete an extra space Nguyễn Thái Ngọc Duy
2015-08-22  0:39     ` [PATCH v2 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead Nguyễn Thái Ngọc Duy
2015-09-07 16:33       ` Junio C Hamano
2015-09-13  0:49         ` Duy Nguyen
2015-09-13  1:04           ` Junio C Hamano
2015-09-14 11:57             ` Duy Nguyen
2015-09-21 22:42               ` Junio C Hamano
2015-08-22  0:40     ` [PATCH v2 3/5] enter_repo: allow .git files in strict mode Nguyễn Thái Ngọc Duy
2015-08-22  0:40     ` [PATCH v2 4/5] clone: allow --local from a linked checkout Nguyễn Thái Ngọc Duy
2015-09-07 16:25       ` Junio C Hamano
2015-08-22  0:40     ` [PATCH v2 5/5] clone: better error when --reference is " Nguyễn Thái Ngọc Duy
2015-09-13  1:02     ` [PATCH v3 0/5] fix local clone from " Nguyễn Thái Ngọc Duy
2015-09-13  1:02       ` [PATCH v3 1/5] path.c: delete an extra space Nguyễn Thái Ngọc Duy
2015-09-13  1:02       ` [PATCH v3 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead Nguyễn Thái Ngọc Duy
2015-09-13  1:02       ` [PATCH v3 3/5] enter_repo: allow .git files in strict mode Nguyễn Thái Ngọc Duy
2015-09-25 19:59         ` Junio C Hamano
2015-09-13  1:02       ` [PATCH v3 4/5] clone: allow --local from a linked checkout Nguyễn Thái Ngọc Duy
2015-09-13  1:02       ` [PATCH v3 5/5] clone: better error when --reference is " Nguyễn Thái Ngọc Duy
2015-09-28 13:06       ` [PATCH v4 0/6] fix local clone from " Nguyễn Thái Ngọc Duy
2015-09-28 13:06         ` [PATCH v4 1/6] path.c: delete an extra space Nguyễn Thái Ngọc Duy
2015-09-28 13:06         ` [PATCH v4 2/6] t0002: add test for enter_repo(), non-strict mode Nguyễn Thái Ngọc Duy
2015-09-28 13:06         ` [PATCH v4 3/6] enter_repo: avoid duplicating logic, use is_git_directory() instead Nguyễn Thái Ngọc Duy
2015-09-28 13:06         ` [PATCH v4 4/6] enter_repo: allow .git files in strict mode Nguyễn Thái Ngọc Duy
2015-09-28 13:06         ` [PATCH v4 5/6] clone: allow --local from a linked checkout Nguyễn Thái Ngọc Duy
2015-09-28 13:06         ` [PATCH v4 6/6] clone: better error when --reference is " Nguyễn Thái Ngọc Duy

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150715132552.GA28574@lanh \
    --to=pclouds@gmail.com \
    --cc=bjornar@snoksrud.no \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).