From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Max Kirillov" <max@max630.net>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 5/5] environment.c: fix incorrect git_graft_file initialization
Date: Wed, 23 Jul 2014 18:43:15 +0700 [thread overview]
Message-ID: <1406115795-24082-6-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1406115795-24082-1-git-send-email-pclouds@gmail.com>
"info/grafts" should be part of the "common repository" when accessed
from a linked checkout (iow $GIT_COMMON_DIR/info/grafts, not
$GIT_DIR/info/grafts).
git_path("info/grafts") returns correctly, even without this fix,
because it detects that $GIT_GRAFT_FILE is not set, so it goes with the
common rule: anything except sparse-checkout in 'info' belongs to common
repo. But get_graft_file() would return a wrong value and that one is
used for setting grafts up.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
environment.c | 2 +-
t/t0060-path-utils.sh | 1 +
t/t2025-checkout-to.sh | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/environment.c b/environment.c
index 50ed40a..d5b0788 100644
--- a/environment.c
+++ b/environment.c
@@ -157,7 +157,7 @@ static void setup_git_env(void)
"objects", &git_db_env);
git_index_file = git_path_from_env(INDEX_ENVIRONMENT, git_dir,
"index", &git_index_env);
- git_graft_file = git_path_from_env(GRAFT_ENVIRONMENT, git_dir,
+ git_graft_file = git_path_from_env(GRAFT_ENVIRONMENT, git_common_dir,
"info/grafts", &git_graft_env);
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
check_replace_refs = 0;
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index da82aab..93605f4 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -269,6 +269,7 @@ test_git_path GIT_COMMON_DIR=bar logs/HEAD .git/logs/HEAD
test_git_path GIT_COMMON_DIR=bar objects bar/objects
test_git_path GIT_COMMON_DIR=bar objects/bar bar/objects/bar
test_git_path GIT_COMMON_DIR=bar info/exclude bar/info/exclude
+test_git_path GIT_COMMON_DIR=bar info/grafts bar/info/grafts
test_git_path GIT_COMMON_DIR=bar info/sparse-checkout .git/info/sparse-checkout
test_git_path GIT_COMMON_DIR=bar remotes/bar bar/remotes/bar
test_git_path GIT_COMMON_DIR=bar branches/bar bar/branches/bar
diff --git a/t/t2025-checkout-to.sh b/t/t2025-checkout-to.sh
index 8a00310..508993f 100755
--- a/t/t2025-checkout-to.sh
+++ b/t/t2025-checkout-to.sh
@@ -81,4 +81,22 @@ test_expect_success 'checkout from a bare repo without --to' '
)
'
+test_expect_success 'checkout with grafts' '
+ test_when_finished rm .git/info/grafts &&
+ test_commit abc &&
+ SHA1=`git rev-parse HEAD` &&
+ test_commit def &&
+ test_commit xyz &&
+ echo "`git rev-parse HEAD` $SHA1" >.git/info/grafts &&
+ cat >expected <<-\EOF &&
+ xyz
+ abc
+ EOF
+ git log --format=%s -2 >actual &&
+ test_cmp expected actual &&
+ git checkout --detach --to grafted master &&
+ git --git-dir=grafted/.git log --format=%s -2 >actual &&
+ test_cmp expected actual
+'
+
test_done
--
1.9.1.346.ga2b5940
next prev parent reply other threads:[~2014-07-23 11:44 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 11:43 [PATCH 0/5] nd/multiple-work-trees follow-ups Nguyễn Thái Ngọc Duy
2014-07-23 11:43 ` [PATCH 1/5] gitrepository-layout.txt: s/ignored/ignored if/ Nguyễn Thái Ngọc Duy
2014-07-23 11:43 ` [PATCH 2/5] prune --repos: fix uninitialized access Nguyễn Thái Ngọc Duy
2014-07-23 19:59 ` Junio C Hamano
2014-07-24 10:14 ` Duy Nguyen
2014-07-23 11:43 ` [PATCH 3/5] checkout --to: no auto-detach if the ref is already checked out Nguyễn Thái Ngọc Duy
2014-07-23 13:48 ` Michael J Gruber
2014-07-23 17:46 ` Junio C Hamano
2014-07-24 9:58 ` Duy Nguyen
2014-07-24 21:30 ` Junio C Hamano
2014-07-25 6:51 ` Michael J Gruber
2014-07-30 18:03 ` Junio C Hamano
2014-07-30 18:52 ` Junio C Hamano
2014-08-27 11:58 ` Duy Nguyen
2014-08-27 16:08 ` Junio C Hamano
2014-07-23 21:16 ` Junio C Hamano
2014-07-24 10:09 ` Duy Nguyen
2014-07-24 16:39 ` Junio C Hamano
2014-07-24 18:13 ` Junio C Hamano
2014-07-23 11:43 ` [PATCH 4/5] checkout --to: fix dangling pointers in remove_junk() Nguyễn Thái Ngọc Duy
2014-07-23 11:43 ` Nguyễn Thái Ngọc Duy [this message]
2014-07-23 21:22 ` [PATCH 5/5] environment.c: fix incorrect git_graft_file initialization Junio C Hamano
2014-07-29 13:50 ` [PATCH v2 0/8] nd/multiple-work-trees follow-ups Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 1/8] gitrepository-layout.txt: s/ignored/ignored if/ Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 2/8] checkout: no need to call check_linked_checkouts if head_ref is NULL Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 3/8] prune --repos: fix uninitialized access Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 4/8] checkout: no auto-detach if the ref is already checked out Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 5/8] checkout --to: fix dangling pointers in remove_junk() Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 6/8] environment.c: fix incorrect git_graft_file initialization Nguyễn Thái Ngọc Duy
2014-07-29 13:50 ` [PATCH v2 7/8] checkout: prefix --to argument properly when cwd is moved Nguyễn Thái Ngọc Duy
2014-07-29 20:51 ` Junio C Hamano
2014-07-30 10:32 ` Duy Nguyen
2014-07-29 13:50 ` [PATCH v2 8/8] checkout --to: do not touch existing target directory Nguyễn Thái Ngọc Duy
2014-07-30 17:51 ` [PATCH 0/5] nd/multiple-work-trees follow-ups Junio C Hamano
2014-07-31 10:13 ` Duy Nguyen
2014-07-31 17:00 ` Junio C Hamano
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=1406115795-24082-6-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=max@max630.net \
--cc=sunshine@sunshineco.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 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 NNTP newsgroup(s).