From 46e0303014d1059404903044c2a01bfa4c29ca3e Mon Sep 17 00:00:00 2001
From: Yuya Nishihara <yuya@tcha.org>
Date: Tue, 17 Oct 2023 08:39:54 +0900
Subject: [PATCH] cli: remove redundant workaround for unborn branch on "git
 clone --colocate"

Apparently, 0fe25575ba4f "cli: ensure first new HEAD is detached" is more
general solution to the problem. The test added at 8b5ff208742f passes.
---
 cli/src/commands/git.rs | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs
index 57a5cf7e1..e74bb6ca7 100644
--- a/cli/src/commands/git.rs
+++ b/cli/src/commands/git.rs
@@ -489,7 +489,7 @@ fn cmd_git_clone(
         }
     }
 
-    let (mut workspace_command, git_repo, stats) = clone_result?;
+    let (mut workspace_command, stats) = clone_result?;
     if let Some(default_branch) = &stats.default_branch {
         let default_branch_remote_ref = workspace_command
             .repo()
@@ -498,12 +498,6 @@ fn cmd_git_clone(
         if let Some(commit_id) = default_branch_remote_ref.target.as_normal().cloned() {
             let mut checkout_tx =
                 workspace_command.start_transaction("check out git remote's default branch");
-            if args.colocate {
-                // HEAD can't be detached without specifying a commit, so we set the new default
-                // branch instead. Otherwise, the old "unborn" default branch would move
-                // alongside the new default branch.
-                git_repo.set_head(&format!("refs/heads/{default_branch}"))?;
-            }
             if let Ok(commit) = checkout_tx.repo().store().get_commit(&commit_id) {
                 checkout_tx.check_out(&commit)?;
             }
@@ -519,7 +513,7 @@ fn do_git_clone(
     colocate: bool,
     source: &str,
     wc_path: &Path,
-) -> Result<(WorkspaceCommandHelper, git2::Repository, GitFetchStats), CommandError> {
+) -> Result<(WorkspaceCommandHelper, GitFetchStats), CommandError> {
     let (workspace, repo) = if colocate {
         let git_repo = git2::Repository::init(wc_path)?;
         add_to_git_exclude(ui, &git_repo)?;
@@ -560,7 +554,7 @@ fn do_git_clone(
     })?;
     print_git_import_stats(ui, &stats.import_stats)?;
     fetch_tx.finish(ui)?;
-    Ok((workspace_command, git_repo, stats))
+    Ok((workspace_command, stats))
 }
 
 fn with_remote_callbacks<T>(ui: &mut Ui, f: impl FnOnce(git::RemoteCallbacks<'_>) -> T) -> T {