commit 19ba7c5a404fe3fcfdaeb04967ba00898b16d397
Author: Randy Fay <randy@randyfay.com>
Date:   Fri Jun 3 11:27:51 2011 -0600

    Issue #1172366 by rfay: Make branches or tags be handled identically as vcs IDs

diff --git a/client/review/vcs/git.inc b/client/review/vcs/git.inc
index bf7e2da..7b7ae22 100644
--- a/client/review/vcs/git.inc
+++ b/client/review/vcs/git.inc
@@ -29,31 +29,43 @@ class pifr_client_vcs_git extends pifr_client_vcs {
 
 
   /**
-   * Check out a given repo URL into given directory.
+   * Check out a given repository URL into given directory.
    *
    * @param $directory
    *   Directory to check out into.
    * @param unknown_type $url
    *   Repo URL, like git://git.drupal.org/project/drupal.git
-   * @param $branch
-   *   Branch to check out, like 7.x-1.0.
+   * @param $vcs_id
+   *   branch or tag to check out, like 7.x-1.0, 7.x, or 7.x-1.x.
+   *
+   * @return
+   *   TRUE on success, FALSE on failure.
    */
-  public function checkout($directory, $url, $branch) {
+  public function checkout($work_tree, $url, $vcs_id) {
     $url = escapeshellarg($url);
-    $branch = escapeshellarg($branch);
-    if (!empty($directory)) {
-      $directory = escapeshellarg($directory);
+    $vcs_id = escapeshellarg("*/$vcs_id");
+    $git_dir = escapeshellarg("$work_tree/.git");
+    if (!empty($work_tree)) {
+      $work_tree = escapeshellarg($work_tree);
     }
     // We can use a reference repository to shortcut the wait for a clone.
     // It can have any or all of the projects that might get checked out.
     // This should be an absolute path to the reference repo or a git URL.
     $reference_repo = variable_get('pifr_reference_repository', '');
+
+    // Note that we may get a warning if the repo doesn't have a HEAD pointing
+    // to a valid branch (as in doesn't have a master branch). Should not be
+    // a failure though.
+    $cmd = "git clone $url $work_tree";
     if (!empty($reference_repo)) {
-      $cmd = "git clone --reference $reference_repo -b $branch $url $directory";
+      $cmd .= " --reference $reference_repo";
     }
-    else {
-      $cmd = "git clone --depth 1 -b $branch $url $directory";
+    if (!pifr_client_review::exec($cmd)) {
+      return FALSE;
     }
+    // This incantation allows us to check out either a branch or a tag without
+    // caring which we're after.
+    $cmd = "git --work-tree=$work_tree --git-dir=$git_dir checkout $(git --work-tree=$work_tree --git-dir=$git_dir rev-parse --remotes=$vcs_id --tags=$vcs_id) 2>&1";
     return pifr_client_review::exec($cmd);
   }
 
