{"thread":{"id":"16283","subject":"[PATCH] Git.pm: Make _temp_cache use the repository directory","startedAt":"2008-11-12T14:28:26Z","lastAt":"2008-11-12T23:27:27Z","messageCount":3,"participants":["Marten Svanfeldt (dev)","Clifford Caoile"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95564","messageId":"491AE80A.5060807@svanfeldt.com","threadId":"16283","inReplyTo":null,"subject":"[PATCH] Git.pm: Make _temp_cache use the repository directory","fromName":"Marten Svanfeldt (dev)","fromEmail":"developer@svanfeldt.com","sentAt":"2008-11-12T14:28:26Z","receivedAt":"2008-11-12T14:28:26Z","isPatch":true,"sender":{"key":"developer@svanfeldt.com","avatar":null},"body":"Update the usage of File::Temp->tempfile to place the temporary files\nwithin the repository directory instead of just letting Perl decide what\ndirectory to use, given there is a repository specified when requesting\nthe temporary file.\n\nThis fixes issues when the Perl in use uses a different format for paths\nthan in use by native code in the git tools such as msysgit with msys-perl.\n\nSigned-off-by: Marten Svanfeldt <developer@svanfeldt.com>\n---\n perl/Git.pm |   15 ++++++++++-----\n 1 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex 6aab712..4b71dad 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -961,9 +961,7 @@ issue.\n =cut\n\n sub temp_acquire {\n-\tmy ($self, $name) = _maybe_self(@_);\n-\n-\tmy $temp_fd = _temp_cache($name);\n+\tmy $temp_fd = _temp_cache(@_);\n\n \t$TEMP_FILES{$temp_fd}{locked} = 1;\n \t$temp_fd;\n@@ -1005,7 +1003,7 @@ sub temp_release {\n }\n\n sub _temp_cache {\n-\tmy ($name) = @_;\n+\tmy ($self, $name) = _maybe_self(@_);\n\n \t_verify_require();\n\n@@ -1022,9 +1020,16 @@ sub _temp_cache {\n \t\t\t\t\"' was closed. Opening replacement.\";\n \t\t}\n \t\tmy $fname;\n+\n+\t\tmy $tmpdir;\n+\t\tif (defined $self) {\n+\t\t\t$tmpdir = $self->repo_path();\n+\t\t}\n+\t\t\n \t\t($$temp_fd, $fname) = File::Temp->tempfile(\n-\t\t\t'Git_XXXXXX', UNLINK => 1\n+\t\t\t'Git_XXXXXX', UNLINK => 1, DIR => $tmpdir,\n \t\t\t) or throw Error::Simple(\"couldn't open new temp file\");\n+\n \t\t$$temp_fd->autoflush;\n \t\tbinmode $$temp_fd;\n \t\t$TEMP_FILES{$$temp_fd}{fname} = $fname;\n-- \n1.6.0.3.1437.g6c121.dirty\n"},{"id":"95631","messageId":"1f748ec60811121406j7ac72c7eqcfbe68132b2ebfc0@mail.gmail.com","threadId":"16283","inReplyTo":"491AE80A.5060807@svanfeldt.com","subject":"Re: [msysGit] [PATCH] Git.pm: Make _temp_cache use the repository directory","fromName":"Clifford Caoile","fromEmail":"piyo@users.sourceforge.net","sentAt":"2008-11-12T22:06:27Z","receivedAt":"2008-11-12T22:06:27Z","isPatch":true,"sender":{"key":"piyo@users.sourceforge.net","avatar":null},"body":"Hi Marten Svanfeldt:\n\nOn Wed, Nov 12, 2008 at 11:28 PM, Marten Svanfeldt (dev)\n<developer@svanfeldt.com> wrote:\n>\n> Update the usage of File::Temp->tempfile to place the temporary files\n> within the repository directory instead of just letting Perl decide what\n> [snip]\n> +\n> +               my $tmpdir;\n> +               if (defined $self) {\n> +                       $tmpdir = $self->repo_path();\n> +               }\n> +\n\nI suppose if I wanted to used ${workingdir}/.git instead of\n${workingdir}, I should replace the $tmpdir line above with $tmpdir =\n$self->repo_path() . \"/.git\" ?\n\nBest regards,\nClifford Caoile\n"},{"id":"95645","messageId":"491B665F.3090103@svanfeldt.com","threadId":"16283","inReplyTo":"1f748ec60811121406j7ac72c7eqcfbe68132b2ebfc0@mail.gmail.com","subject":"Re: [PATCH] Git.pm: Make _temp_cache use the repository directory","fromName":"Marten Svanfeldt (dev)","fromEmail":"developer@svanfeldt.com","sentAt":"2008-11-12T23:27:27Z","receivedAt":"2008-11-12T23:27:27Z","isPatch":true,"sender":{"key":"developer@svanfeldt.com","avatar":null},"body":"\nHi,\n\nClifford Caoile wrote:\n> Hi Marten Svanfeldt:\n> \n> On Wed, Nov 12, 2008 at 11:28 PM, Marten Svanfeldt (dev)\n> <developer@svanfeldt.com> wrote:\n..\n> I suppose if I wanted to used ${workingdir}/.git instead of\n> ${workingdir}, I should replace the $tmpdir line above with $tmpdir =\n> $self->repo_path() . \"/.git\" ?\n\nNo. repo_path() is the path to the repository, so the .git directory. If\nyou instead want within the working directory it is wc_path().\n\n> \n> Best regards,\n> Clifford Caoile\n\n-Marten Svanfeldt\n"}]}