summaryrefslogtreecommitdiff
path: root/t/t9700
diff options
context:
space:
mode:
authorLibravatar Masatake Osanai <unpush@gmail.com>2011-02-15 07:13:04 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2011-02-14 15:28:13 -0800
commit48d9e6ae4bcb6fd08562595aed47bef7326ec144 (patch)
tree79de4fa2c09d73b2ea793db9b0bcd64bcbba1941 /t/t9700
parentGit 1.7.4.1 (diff)
downloadtgif-48d9e6ae4bcb6fd08562595aed47bef7326ec144.tar.xz
perl: command_bidi_pipe() method should set-up git environmens
When command_input_pipe and command_output_pipe are used as a method of a Git::repository instance, they eventually call into _cmd_exec method that sets up the execution environment such as GIT_DIR, GIT_WORK_TREE environment variables and the current working directory in the child process that interacts with the repository. command_bidi_pipe however didn't expect to be called as such, and lacked all these set-up. Because of this, a program that did this did not work as expected: my $repo = Git->repository(Directory => '/some/where/else'); my ($pid, $in, $out, $ctx) = $repo->command_bidi_pipe(qw(hash-object -w --stdin-paths)); This patch refactors the _cmd_exec into _setup_git_cmd_env that sets up the execution environment, and makes _cmd_exec and command_bidi_pipe to use it. Note that unlike _cmd_exec that execv's a git command as an external process, command_bidi_pipe is called from the main line of control, and the execution environment needs to be restored after open2() does its magic. Signed-off-by: Masatake Osanai <unpush@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9700')
-rwxr-xr-xt/t9700/test.pl10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index c15ca2d647..13ba96e21a 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -113,6 +113,16 @@ 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');
+# commands outside working tree
+chdir($abs_repo_dir . '/..');
+my $r3 = Git->repository(Directory => $abs_repo_dir);
+my $tmpfile3 = "$abs_repo_dir/file3.tmp";
+open TEMPFILE3, "+>$tmpfile3" or die "Can't open $tmpfile3: $!";
+is($r3->cat_blob($file1hash, \*TEMPFILE3), 15, "cat_blob(outside): size");
+close TEMPFILE3;
+unlink $tmpfile3;
+chdir($abs_repo_dir);
+
printf "1..%d\n", Test::More->builder->current_test;
my $is_passing = eval { Test::More->is_passing };