* [PATCH v2 1/5] path.c: delete an extra space
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 ` 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
` (4 subsequent siblings)
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-08-22 0:39 UTC (permalink / raw)
To: git; +Cc: bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
path.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/path.c b/path.c
index 95acbaf..a536ee3 100644
--- a/path.c
+++ b/path.c
@@ -431,7 +431,7 @@ 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))
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v2 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead
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 ` Nguyễn Thái Ngọc Duy
2015-09-07 16:33 ` 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
` (3 subsequent siblings)
5 siblings, 1 reply; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-08-22 0:39 UTC (permalink / raw)
To: git; +Cc: bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
path.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/path.c b/path.c
index a536ee3..7340e11 100644
--- a/path.c
+++ b/path.c
@@ -441,8 +441,7 @@ const char *enter_repo(const char *path, int strict)
else 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;
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH v2 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead
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
0 siblings, 1 reply; 28+ messages in thread
From: Junio C Hamano @ 2015-09-07 16:33 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, bjornar
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
The cover letter talks about "local clone", and in this entire
series, I saw new tests only for the local case, but doesn't this
and the next change also affect the case where a Git daemon or a
upload-pack process is serving the remote repository?
And if so, how is that case affected?
> path.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/path.c b/path.c
> index a536ee3..7340e11 100644
> --- a/path.c
> +++ b/path.c
> @@ -441,8 +441,7 @@ const char *enter_repo(const char *path, int strict)
> else 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;
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v2 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead
2015-09-07 16:33 ` Junio C Hamano
@ 2015-09-13 0:49 ` Duy Nguyen
2015-09-13 1:04 ` Junio C Hamano
0 siblings, 1 reply; 28+ messages in thread
From: Duy Nguyen @ 2015-09-13 0:49 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List, bjornar
On Mon, Sep 7, 2015 at 11:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>
> The cover letter talks about "local clone", and in this entire
> series, I saw new tests only for the local case, but doesn't this
> and the next change also affect the case where a Git daemon or a
> upload-pack process is serving the remote repository?
>
> And if so, how is that case affected?
People who serve .git-dir repos should not be affected (I think we
have enough test cases covering that). People can serve .git-file
repos as well, which is sort of tested in the local clone test case
because upload-pack is involved for providing remote refs, I think.
--
Duy
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v2 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead
2015-09-13 0:49 ` Duy Nguyen
@ 2015-09-13 1:04 ` Junio C Hamano
2015-09-14 11:57 ` Duy Nguyen
0 siblings, 1 reply; 28+ messages in thread
From: Junio C Hamano @ 2015-09-13 1:04 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Git Mailing List, bjornar
Duy Nguyen <pclouds@gmail.com> writes:
> On Mon, Sep 7, 2015 at 11:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>>
>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>>> ---
>>
>> The cover letter talks about "local clone", and in this entire
>> series, I saw new tests only for the local case, but doesn't this
>> and the next change also affect the case where a Git daemon or a
>> upload-pack process is serving the remote repository?
>>
>> And if so, how is that case affected?
>
> People who serve .git-dir repos should not be affected (I think we
> have enough test cases covering that). People can serve .git-file
> repos as well, which is sort of tested in the local clone test case
> because upload-pack is involved for providing remote refs, I think.
Unfortunately, the above is still not unclear to me.
Was serving from a linked repository working without these five
patches, i.e. was the local case the only one that was broken and
needed fixing with these five patches? If so, the log message
should mention that (i.e. "remote case was working OK but local was
broken because ...; change this and that to make local one work as
well"). If the remote case also was broken and fixed by these five
patches, then that is also worth mentioning the same way.
I didn't ask you to explain it to me in the first place in a
response. The review comment pointed out that the proposed log
message was unclear and those who will be reading "git log" output
need clearer description.
Thanks.
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v2 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead
2015-09-13 1:04 ` Junio C Hamano
@ 2015-09-14 11:57 ` Duy Nguyen
2015-09-21 22:42 ` Junio C Hamano
0 siblings, 1 reply; 28+ messages in thread
From: Duy Nguyen @ 2015-09-14 11:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List, bjornar
On Sun, Sep 13, 2015 at 8:04 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> On Mon, Sep 7, 2015 at 11:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
>>>
>>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>>>> ---
>>>
>>> The cover letter talks about "local clone", and in this entire
>>> series, I saw new tests only for the local case, but doesn't this
>>> and the next change also affect the case where a Git daemon or a
>>> upload-pack process is serving the remote repository?
>>>
>>> And if so, how is that case affected?
>>
>> People who serve .git-dir repos should not be affected (I think we
>> have enough test cases covering that). People can serve .git-file
>> repos as well, which is sort of tested in the local clone test case
>> because upload-pack is involved for providing remote refs, I think.
>
> Unfortunately, the above is still not unclear to me.
>
> Was serving from a linked repository working without these five
> patches, i.e. was the local case the only one that was broken and
> needed fixing with these five patches? If so, the log message
> should mention that (i.e. "remote case was working OK but local was
> broken because ...; change this and that to make local one work as
> well"). If the remote case also was broken and fixed by these five
> patches, then that is also worth mentioning the same way.
>
> I didn't ask you to explain it to me in the first place in a
> response. The review comment pointed out that the proposed log
> message was unclear and those who will be reading "git log" output
> need clearer description.
I know. I sent the re-roll before receiving this. I think I still
haven't mentioned the impact on remote case. Another update coming,
maybe next weekend.
--
Duy
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v2 3/5] enter_repo: allow .git files in strict mode
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-08-22 0:40 ` 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
` (2 subsequent siblings)
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-08-22 0:40 UTC (permalink / raw)
To: git; +Cc: bjornar, Nguyễn Thái Ngọc Duy
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 <pclouds@gmail.com>
---
path.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/path.c b/path.c
index 7340e11..32d4ca6 100644
--- a/path.c
+++ b/path.c
@@ -438,8 +438,13 @@ const char *enter_repo(const char *path, int strict)
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 (is_git_directory(".")) {
set_git_dir(".");
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v2 4/5] clone: allow --local from a linked checkout
2015-08-22 0:39 ` [PATCH v2 0/5] fix local clone from a linked checkout Nguyễn Thái Ngọc Duy
` (2 preceding siblings ...)
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 ` 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
5 siblings, 1 reply; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-08-22 0:40 UTC (permalink / raw)
To: git; +Cc: bjornar, Nguyễn Thái Ngọc Duy
Noticed-by: Bjørnar Snoksrud <snoksrud@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/clone.c | 6 ++++--
t/t2025-worktree-add.sh | 5 +++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 578da85..836fb64 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -424,8 +424,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/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 8267411..3694174 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -193,4 +193,9 @@ test_expect_success '"add" -B/--detach mutually exclusive' '
test_must_fail git worktree add -B poodle --detach bamboo master
'
+test_expect_success 'local clone from linked checkout' '
+ git clone --local here here-clone &&
+ ( cd here-clone && git fsck )
+'
+
test_done
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH v2 4/5] clone: allow --local from a linked checkout
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
0 siblings, 0 replies; 28+ messages in thread
From: Junio C Hamano @ 2015-09-07 16:25 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, bjornar
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> Noticed-by: Bjørnar Snoksrud <snoksrud@gmail.com>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> builtin/clone.c | 6 ++++--
> t/t2025-worktree-add.sh | 5 +++++
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 578da85..836fb64 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -424,8 +424,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");
Why addstr vs addf? Shouldn't both be addstr?
> copy_or_link_directory(&src, &dest, src_repo, src.len);
> strbuf_release(&src);
> strbuf_release(&dest);
> diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
> index 8267411..3694174 100755
> --- a/t/t2025-worktree-add.sh
> +++ b/t/t2025-worktree-add.sh
> @@ -193,4 +193,9 @@ test_expect_success '"add" -B/--detach mutually exclusive' '
> test_must_fail git worktree add -B poodle --detach bamboo master
> '
>
> +test_expect_success 'local clone from linked checkout' '
> + git clone --local here here-clone &&
> + ( cd here-clone && git fsck )
> +'
> +
> test_done
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v2 5/5] clone: better error when --reference is a linked checkout
2015-08-22 0:39 ` [PATCH v2 0/5] fix local clone from a linked checkout Nguyễn Thái Ngọc Duy
` (3 preceding siblings ...)
2015-08-22 0:40 ` [PATCH v2 4/5] clone: allow --local from a linked checkout Nguyễn Thái Ngọc Duy
@ 2015-08-22 0:40 ` 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
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-08-22 0:40 UTC (permalink / raw)
To: git; +Cc: bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/clone.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 836fb64..7a010bb 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -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;
- } else if (!is_directory(mkpath("%s/objects", ref_git)))
+ } else if (!is_directory(mkpath("%s/objects", ref_git))) {
+ struct strbuf sb = 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);
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 0/5] fix local clone from a linked checkout
2015-08-22 0:39 ` [PATCH v2 0/5] fix local clone from a linked checkout Nguyễn Thái Ngọc Duy
` (4 preceding siblings ...)
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 ` 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
` (5 more replies)
5 siblings, 6 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-13 1:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Fixes strbuf_addf in 4/5. Makes a note about the relation of
enter_repo to this local clone in 3/5. Changes since v1
-- 8< --
diff --git a/builtin/clone.c b/builtin/clone.c
index 7a010bb..3e14491 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -432,7 +432,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)
get_common_dir(&src, src_repo);
get_common_dir(&dest, dest_repo);
strbuf_addstr(&src, "/objects");
- strbuf_addf(&dest, "/objects");
+ strbuf_addstr(&dest, "/objects");
copy_or_link_directory(&src, &dest, src_repo, src.len);
strbuf_release(&src);
strbuf_release(&dest);
-- 8< --
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
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 1/5] path.c: delete an extra space
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 ` 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
` (4 subsequent siblings)
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-13 1:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
path.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/path.c b/path.c
index 95acbaf..a536ee3 100644
--- a/path.c
+++ b/path.c
@@ -431,7 +431,7 @@ 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))
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 2/5] enter_repo: avoid duplicating logic, use is_git_directory() instead
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 ` 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
` (3 subsequent siblings)
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-13 1:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
path.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/path.c b/path.c
index a536ee3..7340e11 100644
--- a/path.c
+++ b/path.c
@@ -441,8 +441,7 @@ const char *enter_repo(const char *path, int strict)
else 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;
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 3/5] enter_repo: allow .git files in strict mode
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 ` 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
` (2 subsequent siblings)
5 siblings, 1 reply; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-13 1:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
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 <pclouds@gmail.com>
---
path.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/path.c b/path.c
index 7340e11..32d4ca6 100644
--- a/path.c
+++ b/path.c
@@ -438,8 +438,13 @@ const char *enter_repo(const char *path, int strict)
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 (is_git_directory(".")) {
set_git_dir(".");
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH v3 3/5] enter_repo: allow .git files in strict mode
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
0 siblings, 0 replies; 28+ messages in thread
From: Junio C Hamano @ 2015-09-25 19:59 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, bjornar
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> 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 <pclouds@gmail.com>
> ---
> path.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/path.c b/path.c
> index 7340e11..32d4ca6 100644
> --- a/path.c
> +++ b/path.c
> @@ -438,8 +438,13 @@ const char *enter_repo(const char *path, int strict)
> return NULL;
> path = validated_path;
> }
> - else if (chdir(path))
> - return NULL;
> + else {
> + const char *gitfile = read_gitfile(used_path);
At this point, used_path[] has not been touched since this function
was called. What file are we reading from?
Is that just a typo of used_path? Do we lack test that cover this
codepath?
Thanks.
> + if (gitfile)
> + path = gitfile;
> + if (chdir(path))
> + return NULL;
> + }
>
> if (is_git_directory(".")) {
> set_git_dir(".");
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v3 4/5] clone: allow --local from a linked checkout
2015-09-13 1:02 ` [PATCH v3 0/5] fix local clone from " Nguyễn Thái Ngọc Duy
` (2 preceding siblings ...)
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-13 1:02 ` 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
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-13 1:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Noticed-by: Bjørnar Snoksrud <snoksrud@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/clone.c | 6 ++++--
t/t2025-worktree-add.sh | 5 +++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 578da85..39d4adf 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -424,8 +424,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_addstr(&dest, "/objects");
copy_or_link_directory(&src, &dest, src_repo, src.len);
strbuf_release(&src);
strbuf_release(&dest);
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 8267411..3694174 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -193,4 +193,9 @@ test_expect_success '"add" -B/--detach mutually exclusive' '
test_must_fail git worktree add -B poodle --detach bamboo master
'
+test_expect_success 'local clone from linked checkout' '
+ git clone --local here here-clone &&
+ ( cd here-clone && git fsck )
+'
+
test_done
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 5/5] clone: better error when --reference is a linked checkout
2015-09-13 1:02 ` [PATCH v3 0/5] fix local clone from " Nguyễn Thái Ngọc Duy
` (3 preceding siblings ...)
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 ` 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
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-13 1:02 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/clone.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 39d4adf..3e14491 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -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;
- } else if (!is_directory(mkpath("%s/objects", ref_git)))
+ } else if (!is_directory(mkpath("%s/objects", ref_git))) {
+ struct strbuf sb = 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);
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v4 0/6] fix local clone from a linked checkout
2015-09-13 1:02 ` [PATCH v3 0/5] fix local clone from " Nguyễn Thái Ngọc Duy
` (4 preceding siblings ...)
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 ` 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
` (5 more replies)
5 siblings, 6 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-28 13:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
This fixes another embarassing bug in 4/6 and adds tests to make sure
it works. Changes since v3
-- 8< --
diff --git a/path.c b/path.c
index 32d4ca6..a346134 100644
--- a/path.c
+++ b/path.c
@@ -439,7 +439,7 @@ const char *enter_repo(const char *path, int strict)
path = validated_path;
}
else {
- const char *gitfile = read_gitfile(used_path);
+ const char *gitfile = read_gitfile(path);
if (gitfile)
path = gitfile;
if (chdir(path))
diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index 9393322..9670e8c 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -116,4 +116,46 @@ test_expect_success 'setup_git_dir twice in subdir' '
)
'
+test_expect_success 'enter_repo non-strict mode' '
+ test_create_repo enter_repo &&
+ (
+ cd enter_repo &&
+ test_tick &&
+ test_commit foo &&
+ mv .git .realgit &&
+ echo "gitdir: .realgit" >.git
+ ) &&
+ git ls-remote enter_repo >actual &&
+ cat >expected <<-\EOF &&
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 HEAD
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/heads/master
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/tags/foo
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'enter_repo linked checkout' '
+ (
+ cd enter_repo &&
+ git worktree add ../foo refs/tags/foo
+ ) &&
+ git ls-remote foo >actual &&
+ cat >expected <<-\EOF &&
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 HEAD
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/heads/master
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/tags/foo
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'enter_repo strict mode' '
+ git ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual &&
+ cat >expected <<-\EOF &&
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 HEAD
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/heads/master
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/tags/foo
+ EOF
+ test_cmp expected actual
+'
+
test_done
-- 8< --
Nguyễn Thái Ngọc Duy (6):
path.c: delete an extra space
t0002: add test for enter_repo(), non-strict mode
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/t0002-gitfile.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
t/t2025-worktree-add.sh | 5 +++++
4 files changed, 66 insertions(+), 8 deletions(-)
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v4 1/6] path.c: delete an extra space
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 ` 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
` (4 subsequent siblings)
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-28 13:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
path.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/path.c b/path.c
index 95acbaf..a536ee3 100644
--- a/path.c
+++ b/path.c
@@ -431,7 +431,7 @@ 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))
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v4 2/6] t0002: add test for enter_repo(), non-strict mode
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 ` 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
` (3 subsequent siblings)
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-28 13:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t0002-gitfile.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index 9393322..545bfe2 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -116,4 +116,22 @@ test_expect_success 'setup_git_dir twice in subdir' '
)
'
+test_expect_success 'enter_repo non-strict mode' '
+ test_create_repo enter_repo &&
+ (
+ cd enter_repo &&
+ test_tick &&
+ test_commit foo &&
+ mv .git .realgit &&
+ echo "gitdir: .realgit" >.git
+ ) &&
+ git ls-remote enter_repo >actual &&
+ cat >expected <<-\EOF &&
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 HEAD
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/heads/master
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/tags/foo
+ EOF
+ test_cmp expected actual
+'
+
test_done
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v4 3/6] enter_repo: avoid duplicating logic, use is_git_directory() instead
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 ` 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
` (2 subsequent siblings)
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-28 13:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
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 <pclouds@gmail.com>
---
path.c | 3 +--
t/t0002-gitfile.sh | 14 ++++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/path.c b/path.c
index a536ee3..7340e11 100644
--- a/path.c
+++ b/path.c
@@ -441,8 +441,7 @@ const char *enter_repo(const char *path, int strict)
else 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;
diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index 545bfe2..2e709cc 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -134,4 +134,18 @@ test_expect_success 'enter_repo non-strict mode' '
test_cmp expected actual
'
+test_expect_success 'enter_repo linked checkout' '
+ (
+ cd enter_repo &&
+ git worktree add ../foo refs/tags/foo
+ ) &&
+ git ls-remote foo >actual &&
+ cat >expected <<-\EOF &&
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 HEAD
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/heads/master
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/tags/foo
+ EOF
+ test_cmp expected actual
+'
+
test_done
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v4 4/6] enter_repo: allow .git files in strict mode
2015-09-28 13:06 ` [PATCH v4 0/6] fix local clone from " Nguyễn Thái Ngọc Duy
` (2 preceding siblings ...)
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 ` 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
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-28 13:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
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 <pclouds@gmail.com>
---
path.c | 9 +++++++--
t/t0002-gitfile.sh | 10 ++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/path.c b/path.c
index 7340e11..a346134 100644
--- a/path.c
+++ b/path.c
@@ -438,8 +438,13 @@ const char *enter_repo(const char *path, int strict)
return NULL;
path = validated_path;
}
- else if (chdir(path))
- return NULL;
+ else {
+ const char *gitfile = read_gitfile(path);
+ if (gitfile)
+ path = gitfile;
+ if (chdir(path))
+ return NULL;
+ }
if (is_git_directory(".")) {
set_git_dir(".");
diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index 2e709cc..9670e8c 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -148,4 +148,14 @@ test_expect_success 'enter_repo linked checkout' '
test_cmp expected actual
'
+test_expect_success 'enter_repo strict mode' '
+ git ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual &&
+ cat >expected <<-\EOF &&
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 HEAD
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/heads/master
+ 946e985ab20de757ca5b872b16d64e92ff3803a9 refs/tags/foo
+ EOF
+ test_cmp expected actual
+'
+
test_done
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v4 5/6] clone: allow --local from a linked checkout
2015-09-28 13:06 ` [PATCH v4 0/6] fix local clone from " Nguyễn Thái Ngọc Duy
` (3 preceding siblings ...)
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 ` 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
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-28 13:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Noticed-by: Bjørnar Snoksrud <snoksrud@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/clone.c | 6 ++++--
t/t2025-worktree-add.sh | 5 +++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 578da85..39d4adf 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -424,8 +424,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_addstr(&dest, "/objects");
copy_or_link_directory(&src, &dest, src_repo, src.len);
strbuf_release(&src);
strbuf_release(&dest);
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 8267411..3694174 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -193,4 +193,9 @@ test_expect_success '"add" -B/--detach mutually exclusive' '
test_must_fail git worktree add -B poodle --detach bamboo master
'
+test_expect_success 'local clone from linked checkout' '
+ git clone --local here here-clone &&
+ ( cd here-clone && git fsck )
+'
+
test_done
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v4 6/6] clone: better error when --reference is a linked checkout
2015-09-28 13:06 ` [PATCH v4 0/6] fix local clone from " Nguyễn Thái Ngọc Duy
` (4 preceding siblings ...)
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 ` Nguyễn Thái Ngọc Duy
5 siblings, 0 replies; 28+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-09-28 13:06 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, bjornar, Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin/clone.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 39d4adf..3e14491 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -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;
- } else if (!is_directory(mkpath("%s/objects", ref_git)))
+ } else if (!is_directory(mkpath("%s/objects", ref_git))) {
+ struct strbuf sb = 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);
--
2.3.0.rc1.137.g477eb31
^ permalink raw reply related [flat|nested] 28+ messages in thread