{"thread":{"id":"6646","subject":"[PATCH] git-archimport: initial import needs empty directory","startedAt":"2007-02-03T22:38:59Z","lastAt":"2007-02-03T22:38:59Z","messageCount":1,"participants":["Gerrit Pape"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"33495","messageId":"20070203223859.19409.qmail@31fbb50a56ed49.315fe32.mid.smarden.org","threadId":"6646","inReplyTo":null,"subject":"[PATCH] git-archimport: initial import needs empty directory","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-02-03T22:38:59Z","receivedAt":"2007-02-03T22:38:59Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"Hi, please see http://bugs.debian.org/400508:\n\n> git-archimport deletes the directory tree in the current working\n> directory during the initial import. The documentation has a sentence\n> saying that an empty directory is expected but this can be dangerous\n> for people not familiar with the tool.\n\ngit-archimport should better refuse to start an initial import if the\ncurrent directory is not empty.\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n git-archimport.perl |    9 +++++++++\n 1 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/git-archimport.perl b/git-archimport.perl\nindex 2e15781..66aaeae 100755\n--- a/git-archimport.perl\n+++ b/git-archimport.perl\n@@ -95,6 +95,15 @@ $ENV{'TMPDIR'} = $opt_t if $opt_t; # $ENV{TMPDIR} will affect tempdir() calls:\n my $tmp = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1);\n $opt_v && print \"+ Using $tmp as temporary directory\\n\";\n \n+unless (-d $git_dir) { # initial import needs empty directory\n+    opendir DIR, '.' or die \"Unable to open current directory: $!\\n\";\n+    while (my $entry = readdir DIR) {\n+        $entry =~ /^\\.\\.?$/ or\n+            die \"Initial import needs an empty current working directory.\\n\"\n+    }\n+    closedir DIR\n+}\n+\n my %reachable = ();             # Arch repositories we can access\n my %unreachable = ();           # Arch repositories we can't access :<\n my @psets  = ();                # the collection\n-- \n1.4.4.4\n"}]}