From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 1/3] worktree setup: calculate prefix even if no worktree is found
Date: Mon, 8 Mar 2010 23:50:31 +0700 [thread overview]
Message-ID: <1268067033-25199-1-git-send-email-pclouds@gmail.com> (raw)
Commit a672ea6 (rehabilitate 'git index-pack' inside the object
store - 2008-10-20) worked around a fault in
setup_git_directory_gently(). When walking up from inside a git
repository, we will return NULL as prefix. We should have returned a
correct prefix anyway because cwd has been moved.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
I missed index-pack in my RUN_SETUP_GENTLY series. So three more patches
on top.
setup.c | 19 ++++++++-----------
t/t1500-rev-parse.sh | 2 +-
t/t1501-worktree.sh | 5 +++++
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/setup.c b/setup.c
index bb3648c..8796c6f 100644
--- a/setup.c
+++ b/setup.c
@@ -392,13 +392,16 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
offset = len = strlen(cwd);
for (;;) {
gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
- if (gitfile_dir) {
- if (set_git_dir(gitfile_dir))
+ if (gitfile_dir || is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT)) {
+ if (gitfile_dir && set_git_dir(gitfile_dir))
die("Repository setup failed");
+ inside_git_dir = 0;
+ if (!work_tree_env)
+ inside_work_tree = 1;
+ root_len = offset_1st_component(cwd);
+ git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
break;
}
- if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
- break;
if (is_git_directory(".")) {
inside_git_dir = 1;
if (!work_tree_env)
@@ -409,8 +412,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
set_git_dir(cwd);
} else
set_git_dir(".");
- check_repository_format_gently(nongit_ok);
- return NULL;
+ break;
}
while (--offset > ceil_offset && cwd[offset] != '/');
if (offset <= ceil_offset) {
@@ -426,11 +428,6 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
die_errno("Cannot change to '%s/..'", cwd);
}
- inside_git_dir = 0;
- if (!work_tree_env)
- inside_work_tree = 1;
- root_len = offset_1st_component(cwd);
- git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
if (check_repository_format_gently(nongit_ok))
return NULL;
if (offset == len)
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 48ee077..4ee92c7 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -42,7 +42,7 @@ test_rev_parse toplevel false false true '' .git
cd .git || exit 1
test_rev_parse .git/ false true false '' .
cd objects || exit 1
-test_rev_parse .git/objects/ false true false '' "$ROOT/.git"
+test_rev_parse .git/objects/ false true false 'objects/' "$ROOT/.git"
cd ../.. || exit 1
mkdir -p sub/dir || exit 1
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index 9df3012..c72b578 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -28,6 +28,11 @@ test_rev_parse() {
[ $# -eq 0 ] && return
}
+cd .git/objects || exit 1
+say "subdirectory inside .git"
+test_rev_parse 'inside' false true false objects/
+cd ../.. || exit 1
+
EMPTY_TREE=$(git write-tree)
mkdir -p work/sub/dir || exit 1
mv .git repo.git || exit 1
--
1.7.0.1.384.g6abcaa
next reply other threads:[~2010-03-08 16:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-08 16:50 Nguyễn Thái Ngọc Duy [this message]
2010-03-08 16:50 ` [PATCH 2/3] index-pack: trust the prefix returned by setup_git_directory_gently() Nguyễn Thái Ngọc Duy
2010-03-08 16:50 ` [PATCH 3/3] index-pack: use RUN_SETUP_GENTLY 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1268067033-25199-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.