threads / patch / 37836

patchGit.pm: add specified name to tempfile template

Subject: [PATCH] Git.pm: add specified name to tempfile template

## tl;dr

2 messages between Oct 29, 2014 and Oct 29, 2014. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Eric Wong· Oct 29, 2014, 19:31 UTC · lore
This should help me track down errors in git-svn more easily:
	write .git/Git_XXXXXX: Bad file descriptor
	 at /usr/lib/perl5/SVN/Ra.pm line 623
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
  Not sure you want to take this separately or in a git-svn pull.
  Still working on the error this patch is meant to help me find.
 perl/Git.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Show changes to perl/Git.pm +4 −1
diff --git a/perl/Git.pm b/perl/Git.pm
index 204fdc6..b5905ee 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -1294,8 +1294,11 @@ sub _temp_cache {
 			$tmpdir = $self->repo_path();
 		}
 
+		my $n = $name;
+		$n =~ s/\W/_/g; # no strange chars
+
 		($$temp_fd, $fname) = File::Temp::tempfile(
-			'Git_XXXXXX', UNLINK => 1, DIR => $tmpdir,
+			"Git_${n}_XXXXXX", UNLINK => 1, DIR => $tmpdir,
 			) or throw Error::Simple("couldn't open new temp file");
 
 		$$temp_fd->autoflush;
-- 
EW
Junio C Hamano· Oct 29, 2014, 19:50 UTC · re: Eric Wong · lore

Re: [PATCH] Git.pm: add specified name to tempfile template

Eric Wong <normalperson@yhbt.net> writes:
Show 9 quoted lines
> This should help me track down errors in git-svn more easily:
>
> 	write .git/Git_XXXXXX: Bad file descriptor
> 	 at /usr/lib/perl5/SVN/Ra.pm line 623
>
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
> ---
>   Not sure you want to take this separately or in a git-svn pull.
>   Still working on the error this patch is meant to help me find.

Thanks; I think it is OK for it to be part of the git-svn update. No other active perl/Git.pm user that wants to have access to this facility early exists as far as I can see ;-)

Show 21 quoted lines
>
>  perl/Git.pm | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/perl/Git.pm b/perl/Git.pm
> index 204fdc6..b5905ee 100644
> --- a/perl/Git.pm
> +++ b/perl/Git.pm
> @@ -1294,8 +1294,11 @@ sub _temp_cache {
>  			$tmpdir = $self->repo_path();
>  		}
>  
> +		my $n = $name;
> +		$n =~ s/\W/_/g; # no strange chars
> +
>  		($$temp_fd, $fname) = File::Temp::tempfile(
> -			'Git_XXXXXX', UNLINK => 1, DIR => $tmpdir,
> +			"Git_${n}_XXXXXX", UNLINK => 1, DIR => $tmpdir,
>  			) or throw Error::Simple("couldn't open new temp file");
>  
>  		$$temp_fd->autoflush;

← back to recent threads