Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/README.txt,v
retrieving revision 1.1.2.19
diff -u -F '^f' -r1.1.2.19 README.txt
--- README.txt	9 Sep 2010 06:43:06 -0000	1.1.2.19
+++ README.txt	22 Sep 2010 11:49:04 -0000
@@ -207,12 +207,18 @@
 
   `url` - the URL of the file. Required.
 
+  `subtree` - if the download is an archive, only this subtree within the
+  archive will be copied to the target destination. Optional.
+
 - `download[type][post]`
 
   Retrieve a project as a direct download using an HTTP POST request. Options:
 
   `url` - the URL of the file. Required.
 
+  `subtree` - if the download is an archive, only this subtree within the
+  archive will be copied to the target destination. Optional.
+
   `post_data` - The post data to be submitted with the request. Should be a
   valid URL query string. Required.
 
Index: drush_make.download.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/drush_make.download.inc,v
retrieving revision 1.1.2.89
diff -u -F '^f' -r1.1.2.89 drush_make.download.inc
--- drush_make.download.inc	20 Sep 2010 21:01:16 -0000	1.1.2.89
+++ drush_make.download.inc	22 Sep 2010 11:49:04 -0000
@@ -65,7 +65,12 @@ function drush_make_download_cvs($name, 
 function drush_make_download_file($name, $download, $download_location) {
   if ($filename = _drush_make_download_file($download)) {
     drush_log(dt('%project downloaded from %url.', array('%project' => $name, '%url' => $download['url'])), 'ok');
-    return drush_make_download_file_unpack($filename, $download_location);
+    if (!empty($download['subtree'])) {
+      return drush_make_download_file_unpack($filename, $download_location, $download['subtree']);
+    }
+    else {
+      return drush_make_download_file_unpack($filename, $download_location);
+    }
   }
   drush_make_error('DOWNLOAD_ERROR', dt('Unable to download %project from %url.', array('%project' => $name, '%url' => $download['url'])));
   return FALSE;
@@ -227,27 +232,27 @@ function _drush_make_download_file($down
   return FALSE;
 }
 
-function drush_make_download_file_unpack($filename, $download_location) {
+function drush_make_download_file_unpack($filename, $download_location, $subtree = NULL) {
   $extension = array_pop(explode('.', $filename));
   $gzip = FALSE;
   switch ($extension) {
     case 'gz':
     case 'tgz':
       // I'd like to just use tar -z, but apparently it breaks on windoze. Why do they always have to ruin everything?
-      drush_make_download_file_unpack_gzip($filename, $download_location);
+      drush_make_download_file_unpack_gzip($filename, $download_location, $subtree);
       break;
     case 'tar':
-      drush_make_download_file_unpack_tar($filename, $download_location);
+      drush_make_download_file_unpack_tar($filename, $download_location, $subtree);
       break;
     case 'zip':
-      drush_make_download_file_unpack_zip($filename, $download_location);
+      drush_make_download_file_unpack_zip($filename, $download_location, $subtree);
       break;
     default:
       drush_make_error('DOWNLOAD_ERROR', dt('Unable to unpack %file', array('%file' => $filename)));
   }
 }
 
-function drush_make_download_file_unpack_tar($filename, $download_location) {
+function drush_make_download_file_unpack_tar($filename, $download_location, $subtree = NULL) {
   $tmp_path = drush_make_tmp();
   // Tarbomb detection.
   drush_shell_exec('tar -tf %s', $filename);
@@ -256,14 +261,17 @@ function drush_make_download_file_unpack
     return FALSE;
   }
   $directory = drush_make_download_file_protect_bomb($lines);
-  if (!$directory) {
+  if (!$directory && empty($subtree)) {
     drush_shell_exec('tar -x -C %s -f %s', $download_location, $filename);
   }
   else {
     list($main_directory) = array_reverse(explode('/', $download_location));
     drush_make_mkdir($tmp_path . '/__unzip__');
     drush_shell_exec('tar -x -C %s -f %s', $tmp_path . '/__unzip__', $filename);
-    if ($directory != $main_directory) {
+    if (!empty($subtree)) {
+      drush_shell_exec('mv %s %s', $tmp_path . '/__unzip__/' . $directory . '/' . $subtree, $tmp_path . '/__unzip__/' . $main_directory);
+    }
+    elseif ($directory != $main_directory) {
       drush_shell_exec('mv %s %s', $tmp_path . '/__unzip__/' . $directory, $tmp_path . '/__unzip__/' . $main_directory);
     }
     drush_shell_exec('cp -Rf %s %s', $tmp_path . '/__unzip__/' . $main_directory, dirname($download_location));
@@ -276,7 +284,7 @@ function drush_make_download_file_unpack
   }
 }
 
-function drush_make_download_file_unpack_gzip($filename, $download_location) {
+function drush_make_download_file_unpack_gzip($filename, $download_location, $subtree = NULL) {
   // Find out where contents will end up. Retrieve last column of output using awk.
   drush_shell_exec("gzip --list %s | awk '{print $4;}'", $filename);
   $info = drush_shell_exec_output();
@@ -289,14 +297,14 @@ function drush_make_download_file_unpack
       // Unzip it and then delete the tar file.
       drush_shell_exec('gzip -d %s', $filename);
       $filename = $file;
-      return drush_make_download_file_unpack_tar($filename, $download_location);
+      return drush_make_download_file_unpack_tar($filename, $download_location, $subtree);
     }
   }
   drush_make_error('PACKAGE_ERROR', dt('Could not retrieve package information for %filename.', array('%filename' => $filename)));
   return;
 }
 
-function drush_make_download_file_unpack_zip($filename, $download_location) {
+function drush_make_download_file_unpack_zip($filename, $download_location, $subtree = NULL) {
   $tmp_path = drush_make_tmp();
   // Find the main directory in the zip file.
   drush_shell_exec("unzip -l %s", $filename);
@@ -312,7 +320,7 @@ function drush_make_download_file_unpack
     $directory = drush_make_download_file_protect_bomb($lines);
     if ($directory) {
       list($main_directory) = array_reverse(explode('/', $download_location));
-      if ($main_directory == $directory) {
+      if ($main_directory == $directory && empty($subtree)) {
         // Directory names match up.
         drush_shell_exec("unzip %s -d %s", $filename, dirname($download_location));
       }
@@ -326,7 +334,12 @@ function drush_make_download_file_unpack
         if (is_dir($tmp_path . '/__unzip__' . $directory . '/__MACOSX')) {
           drush_shell_exec('rm -rf %s', $tmp_path . '/__unzip__' . $directory . '/__MACOSX');
         }
-        drush_shell_exec('mv %s %s', $tmp_path . '/__unzip__/' . $directory, $tmp_path . '/__unzip__/' . $main_directory);
+        if (empty($subtree)) {
+          drush_shell_exec('mv %s %s', $tmp_path . '/__unzip__/' . $directory, $tmp_path . '/__unzip__/' . $main_directory);
+        }
+        else {
+          drush_shell_exec('mv %s %s', $tmp_path . '/__unzip__/' . $directory . '/' . $subtree, $tmp_path . '/__unzip__/' . $main_directory);
+        }
         drush_shell_exec('cp -Rf %s %s', $tmp_path . '/__unzip__/' . $main_directory, dirname($download_location));
         drush_shell_exec('rm -rf %s', $tmp_path . '/__unzip__');
       }
@@ -471,7 +484,10 @@ function drush_make_download_git($name, 
         // Progress branch / tag / revision download. Ensure that only one option ist set (branch OR tag OR revision)
         // check if branch a other than master
         if ($download['branch'] !== 'master' && !$download['tag'] && !$download['revision']) {
-          if (drush_shell_exec("git checkout -b %s %s", $download['branch'], 'origin/' . $download['branch'])) {
+          if (drush_shell_exec("git checkout %s", $download['branch'])) {
+            drush_log(dt("Checked out branch %branch.", array('%branch' => $download['branch'])), 'ok');
+          }
+          elseif (drush_shell_exec("git checkout -b %s %s", $download['branch'], 'origin/' . $download['branch'])) {
             drush_log(dt("Checked out branch %branch.", array('%branch' => $download['branch'])), 'ok');
           }
           else {
