Make git cl upload correctly track upstream refs when uploading to Gerrit

NOPRESUBMIT because it's broke on CQ, Cf. https://codereview.chromium.org/1124803002

BUG=478260
NOPRESUBMIT=true

Review URL: https://codereview.chromium.org/1110293002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295124 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index b94be71..1f78545 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1702,9 +1702,10 @@
   # We assume the remote called "origin" is the one we want.
   # It is probably not worthwhile to support different workflows.
   gerrit_remote = 'origin'
-  branch = 'master'
-  if options.target_branch:
-    branch = options.target_branch
+
+  remote, remote_branch = cl.GetRemoteBranch()
+  branch = GetTargetRef(remote, remote_branch, options.target_branch,
+                        pending_prefix='')
 
   change_desc = ChangeDescription(
       options.message or CreateDescriptionFromLog(args))