From da159c7759418bb14af655968dfa7a98bdcb8661 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Thu, 7 May 2009 15:41:27 +0200 Subject: Git.pm: Set GIT_WORK_TREE if we set GIT_DIR Otherwise git will use the current directory as work tree which will lead to unexpected results if we operate in sub directory of the work tree. Signed-off-by: Frank Lichtenheld Acked-by: Petr Baudis Signed-off-by: Junio C Hamano --- t/t9700-perl-git.sh | 4 ++++ t/t9700/test.pl | 13 +++++++++++++ 2 files changed, 17 insertions(+) (limited to 't') diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh index b4ca244626..4eb7d3f7f0 100755 --- a/t/t9700-perl-git.sh +++ b/t/t9700-perl-git.sh @@ -29,6 +29,10 @@ test_expect_success \ git add . && git commit -m "first commit" && + echo "new file in subdir 2" > directory2/file2 && + git add . && + git commit -m "commit in directory2" && + echo "changed file 1" > file1 && git commit -a -m "second commit" && diff --git a/t/t9700/test.pl b/t/t9700/test.pl index 697daf3ffd..d9b29eab22 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -98,3 +98,16 @@ TODO: { todo_skip 'config after wc_chdir', 1; is($r->config("color.string"), "value", "config after wc_chdir"); } + +# Object generation in sub directory +chdir("directory2"); +my $r2 = Git->repository(); +is($r2->repo_path, $abs_repo_dir . "/.git", "repo_path (2)"); +is($r2->wc_path, $abs_repo_dir . "/", "wc_path (2)"); +is($r2->wc_subdir, "directory2/", "wc_subdir initial (2)"); + +# commands in sub directory +my $last_commit = $r2->command_oneline(qw(rev-parse --verify HEAD)); +like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash'); +my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.'); +isnt($last_commit, $dir_commit, 'log . does not show last commit'); -- cgit v1.2.3 From fe53bbc9bebb853f97f0da3f63f7fca5774e3f95 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Thu, 7 May 2009 15:41:28 +0200 Subject: Git.pm: Always set Repository to absolute path if autodetecting So far we only set it to absolute paths in some cases which lead to problems like wc_chdir not working. Signed-off-by: Frank Lichtenheld Acked-by: Petr Baudis Signed-off-by: Junio C Hamano --- t/t9700/test.pl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 't') diff --git a/t/t9700/test.pl b/t/t9700/test.pl index d9b29eab22..6c70aec020 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -86,18 +86,12 @@ close TEMPFILE; unlink $tmpfile; # paths -is($r->repo_path, "./.git", "repo_path"); +is($r->repo_path, $abs_repo_dir . "/.git", "repo_path"); is($r->wc_path, $abs_repo_dir . "/", "wc_path"); is($r->wc_subdir, "", "wc_subdir initial"); $r->wc_chdir("directory1"); is($r->wc_subdir, "directory1", "wc_subdir after wc_chdir"); -TODO: { - local $TODO = "commands do not work after wc_chdir"; - # Failure output is active even in non-verbose mode and thus - # annoying. Hence we skip these tests as long as they fail. - todo_skip 'config after wc_chdir', 1; - is($r->config("color.string"), "value", "config after wc_chdir"); -} +is($r->config("test.string"), "value", "config after wc_chdir"); # Object generation in sub directory chdir("directory2"); -- cgit v1.2.3