summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f01f109)
raw | patch | inline | side by side (parent: f01f109)
author | Frank Lichtenheld <flichtenheld@astaro.com> | |
Thu, 7 May 2009 13:41:27 +0000 (15:41 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 9 May 2009 15:25:55 +0000 (08:25 -0700) |
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>
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>
perl/Git.pm | patch | blob | history | |
t/t9700-perl-git.sh | patch | blob | history | |
t/t9700/test.pl | patch | blob | history |
diff --git a/perl/Git.pm b/perl/Git.pm
index 291ff5b53c1883ee8fce67fbb7e2b32393ef0800..4313db75b5a1de3085e45b949c267ea4be9fe5fe 100644 (file)
--- a/perl/Git.pm
+++ b/perl/Git.pm
my ($self, @args) = @_;
if ($self) {
$self->repo_path() and $ENV{'GIT_DIR'} = $self->repo_path();
+ $self->repo_path() and $self->wc_path()
+ and $ENV{'GIT_WORK_TREE'} = $self->wc_path();
$self->wc_path() and chdir($self->wc_path());
$self->wc_subdir() and chdir($self->wc_subdir());
}
diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh
index b4ca244626a6635faa2587722c26f4c17692af65..4eb7d3f7f042f896106f208a7f8bb91925352b2a 100755 (executable)
--- a/t/t9700-perl-git.sh
+++ b/t/t9700-perl-git.sh
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 697daf3ffd33c27654ce00f780acc2c6db5f9985..d9b29eab2261829deb898b593c642c913b5b219f 100755 (executable)
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
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');