Re: [PATCH 5/5] environment.c: fix incorrect git_graft_file initialization
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 12 quoted lines
> "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>
> ---Thanks Eric for sharp eyes and Duy for a quick fix.
Will queue all five.
Show 57 quoted lines
> 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