diff --git a/commands/pm/package_handler/git_drupalorg.inc b/commands/pm/package_handler/git_drupalorg.inc
index fe933e8..7ca58bf 100644
--- a/commands/pm/package_handler/git_drupalorg.inc
+++ b/commands/pm/package_handler/git_drupalorg.inc
@@ -190,7 +190,9 @@ function package_handler_post_download($project) {
 function drush_gitcache_check($gitcache) {
   if (is_dir(drush_server_home() . '/.drush')) {
     drush_mkdir($gitcache);
-    if (!drush_shell_cd_and_exec($gitcache, 'test $(git rev-parse --is-bare-repository) == "true"')) {
+    drush_shell_cd_and_exec($gitcache, 'git rev-parse --is-bare-repository');
+    $output = drush_shell_exec_output();
+    if (!isset($output[0]) || $output[0] != 'true') {
       drush_shell_cd_and_exec($gitcache, 'git init --bare');
       drush_shell_cd_and_exec($gitcache, 'git config core.compression 1');
     }
@@ -211,14 +213,14 @@ function drush_gitcache_add_project($gitcache, $request, $repository) {
   // On the first fetch, git will check for common commits with the remote
   // repository, so to speed this up we initially fetch from a local clone.
   $tmpdir = drush_tempdir();
-  $command = 'git clone --bare ';
+  $command = 'git clone --bare';
   if (drush_get_context('DRUSH_VERBOSE')) {
-    $command .= ' --verbose --progress ';
+    $command .= ' --verbose --progress';
   }
-  $command .= '%s';
-  if (drush_shell_cd_and_exec($tmpdir, $command, $repository)) {
+  $command .= ' %s %s';
+  if (drush_shell_cd_and_exec($tmpdir, $command, $repository, $request['name'])) {
     // Temporarily set the remote url to our temporary clone and fetch from there.
-    drush_shell_cd_and_exec($gitcache, 'git remote add %s %s && git fetch %s --tags', $request['name'], $tmpdir, $request['name']);
+    drush_shell_cd_and_exec($gitcache, 'git remote add %s %s/%s && git fetch %s --tags', $request['name'], $tmpdir, $request['name'], $request['name']);
 
     // Change the remote URL and fetch normally.
     drush_shell_cd_and_exec($gitcache, 'git remote set-url %s %s && git fetch %s --tags', $request['name'], $repository, $request['name']);
diff --git a/drush.bat b/drush.bat
index dcfcf49..34c1947 100644
--- a/drush.bat
+++ b/drush.bat
@@ -1,3 +1,16 @@
 @echo off
+rem Drush automatically determines the user's home directory by checking for
+rem HOME or HOMEDRIVE/HOMEPATH environment variables, and the temporary
+rem directory by checking for TEMP, TMP, or WINDIR environment variables.
+rem The home path is used for caching Drush commands and the git --reference
+rem cache. The temporary directory is used by various commands, including
+rem package manager for downloading projects.
+rem You may want to specify a path that is not user-specific here; e.g., to
+rem keep cache files on the same filesystem, or to share caches with other
+rem users.
+
+rem set HOME=H:/drush
+rem set TEMP=H:/drush
+
 REM See http://drupal.org/node/506448 for more information.
 @php.exe "%~dp0drush.php" %* --php="php.exe"
diff --git a/examples/example.drushrc.php b/examples/example.drushrc.php
index 40fd2a0..557748c 100644
--- a/examples/example.drushrc.php
+++ b/examples/example.drushrc.php
@@ -85,6 +85,10 @@
 // Specify Git clones for drupal.org extensions.
 # $options['package-handler'] = 'git_drupalorg';
 
+// Add a 'pm-clone' Drush shell alias to simplify (cached) cloning from drupal.org.
+// Defaults to --dev; i.e., currently recommended development branch.
+# $options['shell-aliases']['pm-clone'] = 'pm-download --gitusername=YOURUSERNAME --package-handler=git_drupalorg --cache --dev';
+
 // Specify additional directories to search for *.drush.inc files
 // Separate by : (Unix-based systems) or ; (Windows).
 # $options['i'] = 'sites/default:profiles/myprofile';
diff --git a/includes/filesystem.inc b/includes/filesystem.inc
index a4ed996..71abe92 100644
--- a/includes/filesystem.inc
+++ b/includes/filesystem.inc
@@ -278,9 +278,9 @@ function drush_save_data_to_temp_file($data) {
  * path is not valid in some setups for Mac.
  */
 function drush_find_tmp() {
-  static $temporary_directory = NULL;
+  static $temporary_directory;
 
-  if (is_null($temporary_directory)) {
+  if (!isset($temporary_directory)) {
     $directories = array();
 
     // Operating system specific dirs.
@@ -297,7 +297,10 @@ function drush_find_tmp() {
       }
       $windir = getenv('WINDIR');
       if (isset($windir)) {
-        $directories[] = $windir;
+        // WINDIR itself is not writable, but it always contains a /Temp dir,
+        // which is the system-wide temporary directory on older versions. Newer
+        // versions only allow system processes to use it.
+        $directories[] = $windir . '/Temp';
       }
     }
     else {
