{git,patch}_unittest: fix running with newer repo

Newer repo will probe the default branch via HEAD rather than
hardcoding "master", so make sure we initialize our local test
repos with the right HEAD value.

BUG=gerrit:13339
TEST=CQ passes

Cq-Depend: chromium:2569272
Change-Id: I753b2ea60f3ac310d55882bedf020b0b5e9b251e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2568980
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: LaMont Jones <lamontjones@chromium.org>
diff --git a/lib/git_unittest.py b/lib/git_unittest.py
index a96bb8f..d868595 100644
--- a/lib/git_unittest.py
+++ b/lib/git_unittest.py
@@ -590,6 +590,9 @@
     git.CreateBranch(remote_manifests, 'release-R23-2913.B')
     git.CreateBranch(remote_manifests, 'release-R23-2913.B-suffix')
     git.CreateBranch(remote_manifests, 'firmware-link-')
+    # This must come last as it sets up HEAD for the default branch, and repo
+    # uses that to figure out which branch to check out.
+    git.CreateBranch(remote_manifests, 'master')
 
     # Create a copy of our existing manifests.git, but rewrite it so it
     # looks like a remote manifests.git.  This is to avoid hitting the
diff --git a/lib/patch_unittest.py b/lib/patch_unittest.py
index 96eaccd..8bb3a28 100644
--- a/lib/patch_unittest.py
+++ b/lib/patch_unittest.py
@@ -219,7 +219,8 @@
     bare_path = os.path.join(tmp_path, 'bare.git')
     checkout_path = os.path.join(tmp_path, 'checkout')
     cros_build_lib.run(
-        ['git', 'init', '--separate-git-dir', bare_path, checkout_path],
+        ['git', 'init', '--separate-git-dir', bare_path,
+         '--initial-branch', 'master', checkout_path],
         cwd=tmp_path, print_cmd=False, capture_output=True)
 
     # Nerf any hooks the OS might have installed on us as they aren't going to