{"thread":{"id":"16302","subject":"[PATCH fixed] Git.pm: Make _temp_cache use the repository directory","startedAt":"2008-11-13T12:04:09Z","lastAt":"2008-11-13T12:04:09Z","messageCount":1,"participants":["Marten Svanfeldt (dev)"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95679","messageId":"491C17B9.2070106@svanfeldt.com","threadId":"16302","inReplyTo":null,"subject":"[PATCH fixed] Git.pm: Make _temp_cache use the repository directory","fromName":"Marten Svanfeldt (dev)","fromEmail":"developer@svanfeldt.com","sentAt":"2008-11-13T12:04:09Z","receivedAt":"2008-11-13T12:04:09Z","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 is needed to be able to fix git-svn on msys as msysperl generates\npaths with UNIX-style paths (/tmp/xxx) while the git tools expect natvie\npath format (c:/..). The repository dir is stored in native format so by\nusing it as the base directory for temporary files we always get a\nusable native full path.\n\nSigned-off-by: Marten Svanfeldt <developer@svanfeldt.com>\n---\nHi,\nReworked the second part of the commit message after comments to make it\nmore obvious why this patch is needed.\n\n\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.1439.gc9385a.dirty\n"}]}