{"thread":{"id":"1794","subject":"[PATCH] cg-clean -d removes \"arch\" and \"include\" in Linux","startedAt":"2005-09-13T22:04:35Z","lastAt":"2005-09-13T22:04:35Z","messageCount":1,"participants":["Pavel Roskin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"8490","messageId":"1126649075.28384.15.camel@dv","threadId":"1794","inReplyTo":null,"subject":"[PATCH] cg-clean -d removes \"arch\" and \"include\" in Linux","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-09-13T22:04:35Z","receivedAt":"2005-09-13T22:04:35Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello!\n\n\"cg-clean -d\" would delete directories that don't have versioned files\nin them, even if their subdirectories do.  \"arch\" and \"include\" in Linux\nsources are such directories.\n\nTo be safe, every directory in the directory list should be complemented\nby all its parent directories.\n\nThe patch below is a quick hack that shows that bash is not the best\nlanguage to implement this.  Still, it's better to have such fix than\nhaving cg-clean remove source files.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\ndiff --git a/cg-clean b/cg-clean\n--- a/cg-clean\n+++ b/cg-clean\n@@ -53,6 +53,18 @@ clean_dirs()\n \tgit-ls-files --cached |\n \t\tsed -n 's|^'\"$_git_relpath\"'||p' |\n \t\tsed -n 's|/[^/]*$||p' |\n+\t\twhile IFS='/' read -a dir; do\n+\t\t\ti=0\n+\t\t\twhile test $i != ${#dir[@]}; do\n+\t\t\t\tj=0\n+\t\t\t\twhile test $i != $j; do\n+\t\t\t\t\techo -n ${dir[$j]}/\n+\t\t\t\t\tj=$[$j+1]\n+\t\t\t\tdone\n+\t\t\t\techo ${dir[$i]}\n+\t\t\t\ti=$[$i+1]\n+\t\t\tdone\n+\t\tdone |\n \t\tsort -u >\"$dirlist\"\n \n \tsave_IFS=\"$IFS\"\n\n\n-- \nRegards,\nPavel Roskin\n"}]}