From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
bjornar@snoksrud.no, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v4 0/6] fix local clone from a linked checkout
Date: Mon, 28 Sep 2015 20:06:10 +0700 [thread overview]
Message-ID: <1443445576-29526-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1442106148-22895-1-git-send-email-pclouds@gmail.com>
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
next prev parent reply other threads:[~2015-09-28 13:06 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
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 ` Nguyễn Thái Ngọc Duy [this message]
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=1443445576-29526-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=bjornar@snoksrud.no \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).