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.
Reproduction:
Creating a repo `foo`, checkout --to'ing it to ../bar, then try to
clone both resulting repositories..
$ git --version
git version 2.4.4.600.g6397abd
$ mkdir foo
$ cd foo
$ git init
Initialized empty Git repository in /bar/foo/.git/
$ git commit -m init --allow-empty
[master (root-commit) c6da399] init
$ git branch bar
$ git checkout bar --to ../bar
Enter ../bar (identifier bar)
Switched to branch 'bar'
$ cd ../bar
$ cd bar
$ git status -sb
## bar
$ cd ..
$ git clone bar baz
Cloning into 'baz'...
fatal: '/path/bar' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ git clone foo baz
Cloning into 'baz'...
done.
--
bjornar@snoksrud.no
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< --
On Wed, Jul 15, 2015 at 8:25 PM, Duy Nguyen [off-list ref] wrote:
On Wed, Jul 15, 2015 at 11:40:18AM +0200, Bjørnar Snoksrud wrote:
quoted
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.
Here it is. Mostly the same as the previous patch except that the last
patch is new.
Nguyễn Thái Ngọc Duy (5):
path.c: delete an extra space
enter_repo: avoid duplicating logic, use is_git_directory() instead
enter_repo: allow .git files in strict mode
clone: allow --local from a linked checkout
clone: better error when --reference is a linked checkout
builtin/clone.c | 13 ++++++++++---
path.c | 14 +++++++++-----
t/t2025-worktree-add.sh | 5 +++++
3 files changed, 24 insertions(+), 8 deletions(-)
--
2.3.0.rc1.137.g477eb31
Strict mode is about not guessing where .git is. If the user points to a
.git file, we know exactly where the target .git dir will be.
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
path.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
@@ -294,9 +294,14 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)char*ref_git_git=mkpathdup("%s/.git",ref_git);free(ref_git);ref_git=ref_git_git;-}elseif(!is_directory(mkpath("%s/objects",ref_git)))+}elseif(!is_directory(mkpath("%s/objects",ref_git))){+structstrbufsb=STRBUF_INIT;+if(get_common_dir(&sb,ref_git))+die(_("reference repository '%s' as a linked checkout is not supported yet."),+item->string);die(_("reference repository '%s' is not a local repository."),item->string);+}if(!access(mkpath("%s/shallow",ref_git),F_OK))die(_("reference repository '%s' is shallow"),item->string);
Strict mode is about not guessing where .git is. If the user points to a
.git file, we know exactly where the target .git dir will be.
This is needed even in local clone case because transport.c code uses
upload-pack for fetching remote refs.
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
path.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
@@ -294,9 +294,14 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)char*ref_git_git=mkpathdup("%s/.git",ref_git);free(ref_git);ref_git=ref_git_git;-}elseif(!is_directory(mkpath("%s/objects",ref_git)))+}elseif(!is_directory(mkpath("%s/objects",ref_git))){+structstrbufsb=STRBUF_INIT;+if(get_common_dir(&sb,ref_git))+die(_("reference repository '%s' as a linked checkout is not supported yet."),+item->string);die(_("reference repository '%s' is not a local repository."),item->string);+}if(!access(mkpath("%s/shallow",ref_git),F_OK))die(_("reference repository '%s' is shallow"),item->string);
It matters for linked checkouts where 'refs' directory won't be
available in $GIT_DIR. is_git_directory() knows about $GIT_COMMON_DIR
and can handle this case.
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
path.c | 3 +--
t/t0002-gitfile.sh | 14 ++++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
Strict mode is about not guessing where .git is. If the user points to a
.git file, we know exactly where the target .git dir will be. This makes
it possible to serve .git files as repository on the server side.
This may be needed even in local clone case because transport.c code
uses upload-pack for fetching remote refs. But right now the
clone/transport code goes with non-strict.
Signed-off-by: Nguyễn Thái Ngọc Duy <redacted>
---
path.c | 9 +++++++--
t/t0002-gitfile.sh | 10 ++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
@@ -294,9 +294,14 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)char*ref_git_git=mkpathdup("%s/.git",ref_git);free(ref_git);ref_git=ref_git_git;-}elseif(!is_directory(mkpath("%s/objects",ref_git)))+}elseif(!is_directory(mkpath("%s/objects",ref_git))){+structstrbufsb=STRBUF_INIT;+if(get_common_dir(&sb,ref_git))+die(_("reference repository '%s' as a linked checkout is not supported yet."),+item->string);die(_("reference repository '%s' is not a local repository."),item->string);+}if(!access(mkpath("%s/shallow",ref_git),F_OK))die(_("reference repository '%s' is shallow"),item->string);