{"thread":{"id":"10363","subject":"[PATCH] cvs export: ensure we add directories in order","startedAt":"2007-10-18T16:15:44Z","lastAt":"2007-10-18T16:15:44Z","messageCount":1,"participants":["Alex Bennee"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"56414","messageId":"1192724144.26933.64.camel@murta.transitives.com","threadId":"10363","inReplyTo":null,"subject":"[PATCH] cvs export: ensure we add directories in order","fromName":"Alex Bennee","fromEmail":"kernel-hacker@bennee.com","sentAt":"2007-10-18T16:15:44Z","receivedAt":"2007-10-18T16:15:44Z","isPatch":true,"sender":{"key":"kernel-hacker@bennee.com","avatar":null},"body":"Hi,\n\nCVS gets understandably upset if you try and add a subdirectory before\nit's parent directory. This patch fixes that.\n\n>From d99d4e7eb0ce7b85fb84d3c57f57abbb100baa5e Mon Sep 17 00:00:00 2001\nFrom: Alex Bennee <alex@bennee.com>\nDate: Thu, 18 Oct 2007 17:12:13 +0100\nSubject: [PATCH] Ensure we add directories in the correct order\n\n---\n git-cvsexportcommit.perl |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\ndiff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl\nindex 0a21215..a70c583 100755\n--- a/git-cvsexportcommit.perl\n+++ b/git-cvsexportcommit.perl\n@@ -234,6 +234,17 @@ print \"Applying\\n\";\n \n print \"Patch applied successfully. Adding new files and directories to CVS\\n\";\n my $dirtypatch = 0;\n+\n+#\n+# We have to add the directories in order otherwise we will have\n+# problems when we try and add the sub-directory of a directory we\n+# have not added yet.\n+#\n+# Luckily this is easy to deal with by sorting the directories and\n+# dealing with the shortest ones first.\n+#\n+@dirs = sort { length $a <=> length $b} @dirs;\n+\n foreach my $d (@dirs) {\n     if (system(@cvs,'add',$d)) {\n \t$dirtypatch = 1;\n-- \n1.5.2.5\n\n\n\n-- \nAlex, homepage: http://www.bennee.com/~alex/\nBusiness is a good game -- lots of competition and minimum of rules. You\nkeep score with money. -- Nolan Bushnell, founder of Atari\n"}]}