summaryrefslogtreecommitdiff
path: root/t/t9700
diff options
context:
space:
mode:
authorLibravatar Frank Lichtenheld <flichtenheld@astaro.com>2009-05-07 15:41:27 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-05-09 08:25:55 -0700
commitda159c7759418bb14af655968dfa7a98bdcb8661 (patch)
treeb5d108f10e1c6d05988693e8c0f3c319f8c9a121 /t/t9700
parentGIT 1.6.3 (diff)
downloadtgif-da159c7759418bb14af655968dfa7a98bdcb8661.tar.xz
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 <flichtenheld@astaro.com> Acked-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9700')
-rwxr-xr-xt/t9700/test.pl13
1 files changed, 13 insertions, 0 deletions
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');