TO-250: Fix jiri status crashing

Fix jiri status fails on repo checked out to local master synced to
upstream master

Change-Id: I3441ce20c22ad2027e10260d3220b86b9a1414a6
diff --git a/cmd/jiri/status.go b/cmd/jiri/status.go
index 8444b3b..93476da 100644
--- a/cmd/jiri/status.go
+++ b/cmd/jiri/status.go
@@ -82,7 +82,7 @@
 		if statusFlags.branch != "" && (statusFlags.branch != state.CurrentBranch.Name) {
 			continue
 		}
-		changes, headRev, extraCommits, err := getStatus(jirix, localProject, remoteProject, state.CurrentBranch.Name)
+		changes, headRev, extraCommits, err := getStatus(jirix, localProject, remoteProject, state.CurrentBranch)
 		if err != nil {
 			return fmt.Errorf("Error while getting status for project %q :%s", localProject.Name, err)
 		}
@@ -138,7 +138,7 @@
 	return nil
 }
 
-func getStatus(jirix *jiri.X, local project.Project, remote project.Project, currentBranch string) (string, string, []string, error) {
+func getStatus(jirix *jiri.X, local project.Project, remote project.Project, currentBranch project.BranchState) (string, string, []string, error) {
 	var extraCommits []string
 	headRev := ""
 	changes := ""
@@ -161,8 +161,12 @@
 		}
 	}
 
-	if currentBranch != "" && statusFlags.commits {
-		commits, err := scm.ExtraCommits(statusFlags.branch, "origin")
+	if currentBranch.Name != "" && statusFlags.commits {
+		remoteBranch := "remotes/origin/" + remote.RemoteBranch
+		if currentBranch.Tracking != nil {
+			remoteBranch = currentBranch.Tracking.Name
+		}
+		commits, err := scm.ExtraCommits(currentBranch.Name, remoteBranch)
 		if err != nil {
 			return "", "", nil, err
 		}