[PATCH] archimport - better handling of temp dirs
Switched from backwards hard-coded tmp directory creation to using File::Temp::tempdir() to create the directory inside $TMP_PATH or what the user has provided via the -t parameter. Signed-off-by: Martin Langhoff <martin@catalyst.net.nz> Signed-off-by: Junio C Hamano <junkio@cox.net>
martin@catalyst.net.nz committed
Sep 11, 2005 at 21:26 UTC
127bf00f7d2fee044602bec8c76ec9d6bf368025
1 file changed
+5
-5
git-archimport.perl
+5
-5
@@ -23,7 +23,6 @@ See man (1) git-archimport for more details.
23
24
- create tag objects instead of ref tags
25
- audit shell-escaping of filenames
26
- - better handling of temp directories
26
- hide our private tags somewhere smarter
27
- find a way to make "cat *patches | patch" safe even when patchfiles are missing newlines
28
@@ -37,7 +36,7 @@ use strict;
36
use warnings;
37
use Getopt::Std;
38
use File::Spec;
40
-use File::Temp qw(tempfile);
39
+use File::Temp qw(tempfile tempdir);
40
use File::Path qw(mkpath);
41
use File::Basename qw(basename dirname);
42
use String::ShellQuote;
@@ -72,9 +71,10 @@ usage if $opt_h;
71
@ARGV >= 1 or usage();
72
my @arch_roots = @ARGV;
73
75
-my $tmp = $opt_t;
76
-$tmp ||= '/tmp';
77
-$tmp .= '/git-archimport/';
74
+my ($tmpdir, $tmpdirname) = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1);
75
+my $tmp = $opt_t || 1;
76
+$tmp = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1);
77
+$opt_v && print "+ Using $tmp as temporary directory\n";
78
79
my @psets = (); # the collection
80
my %psets = (); # the collection, by name