diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-05-23 01:38:28 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-05-23 01:38:28 -0700 |
commit | 9d764f9538f63d654a1147e11920c2bc36b75194 (patch) | |
tree | 8f7c0f6f83e57a033cd0e4dfee7fdb249905c29c | |
parent | 77ce907786d2c4a7789e81c83a28e829c36fab30 (diff) | |
parent | fe53bbc9bebb853f97f0da3f63f7fca5774e3f95 (diff) | |
download | git-9d764f9538f63d654a1147e11920c2bc36b75194.tar.gz git-9d764f9538f63d654a1147e11920c2bc36b75194.tar.xz |
Merge branch 'fl/git-pm'
* fl/git-pm:
Git.pm: Always set Repository to absolute path if autodetecting
Git.pm: Set GIT_WORK_TREE if we set GIT_DIR
-rw-r--r-- | perl/Git.pm | 4 | ||||
-rwxr-xr-x | t/t9700-perl-git.sh | 4 | ||||
-rwxr-xr-x | t/t9700/test.pl | 23 |
3 files changed, 22 insertions, 9 deletions
diff --git a/perl/Git.pm b/perl/Git.pm index 291ff5b53..e8df55d2f 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -185,7 +185,7 @@ sub repository { if ($dir) { $dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir; - $opts{Repository} = $dir; + $opts{Repository} = abs_path($dir); # If --git-dir went ok, this shouldn't die either. my $prefix = $search->command_oneline('rev-parse', '--show-prefix'); @@ -1280,6 +1280,8 @@ sub _cmd_exec { 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 b4ca24462..4eb7d3f7f 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 697daf3ff..6c70aec02 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -86,15 +86,22 @@ 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"); +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'); |