@matheusbsbs / matheus-bagliano / commits / 11dbe9e880
Fork 0

git-archimport: initial import needs empty directory

git-archimport should better refuse to start an initial import if the current directory is not empty. (http://bugs.debian.org/400508) Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Gerrit Pape committed Feb 3, 2007 at 22:38 UTC 11dbe9e88016f3894eda79c7437f6c3bf79e155e
1 file changed +9
git-archimport.perl
+9
@@ -95,6 +95,15 @@ $ENV{'TMPDIR'} = $opt_t if $opt_t; # $ENV{TMPDIR} will affect tempdir() calls:
95 my $tmp = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1);
96 $opt_v && print "+ Using $tmp as temporary directory\n";
97
98 +unless (-d $git_dir) { # initial import needs empty directory
99 + opendir DIR, '.' or die "Unable to open current directory: $!\n";
100 + while (my $entry = readdir DIR) {
101 + $entry =~ /^\.\.?$/ or
102 + die "Initial import needs an empty current working directory.\n"
103 + }
104 + closedir DIR
105 +}
106 +
107 my %reachable = (); # Arch repositories we can access
108 my %unreachable = (); # Arch repositories we can't access :<
109 my @psets = (); # the collection