@@ -566,12 +566,7 @@ func start(configuration config.Configuration) error {
566566
567567 createRemoteBranch (configuration , currentBaseBranch )
568568
569- if ! currentBaseBranch .hasLocalBranch (localBranches ) {
570- silentgit ("checkout" , "-b" , currentBaseBranch .Name )
571- silentgit ("checkout" , currentBranch .Name )
572- }
573-
574- if currentBaseBranch .hasUnpushedCommits (configuration ) {
569+ if currentBaseBranch .hasLocalBranch (localBranches ) && currentBaseBranch .hasUnpushedCommits (configuration ) {
575570 say .Error ("cannot start; unpushed changes on base branch must be pushed upstream" )
576571 say .Fix ("to fix this, push those commits and try again" , "git push " + configuration .RemoteName + " " + currentBaseBranch .String ())
577572 return errors .New ("cannot start; unpushed changes on base branch must be pushed upstream" )
@@ -610,7 +605,7 @@ func start(configuration config.Configuration) error {
610605 }
611606
612607 say .Info ("you are on wip branch '" + currentWipBranch .String () + "' (base branch '" + currentBaseBranch .String () + "')" )
613- sayLastCommitsList (currentBaseBranch . String () , currentWipBranch . String () )
608+ sayLastCommitsList (currentBaseBranch , currentWipBranch , configuration )
614609
615610 openLastModifiedFileIfPresent (configuration )
616611
@@ -1021,12 +1016,16 @@ func squashOrCommit(configuration config.Configuration) string {
10211016 }
10221017}
10231018
1024- func sayLastCommitsList (currentBaseBranch string , currentWipBranch string ) {
1025- commitsBaseWipBranch := currentBaseBranch + ".." + currentWipBranch
1026- log := silentgit ("--no-pager" , "log" , commitsBaseWipBranch , "--pretty=format:%h %cr <%an>" , "--abbrev-commit" )
1019+ func sayLastCommitsList (currentBaseBranch Branch , currentWipBranch Branch , configuration config.Configuration ) {
1020+ commitsBaseWipBranch := currentBaseBranch .String () + ".." + currentWipBranch .String ()
1021+ log , err := silentgitignorefailure ("--no-pager" , "log" , commitsBaseWipBranch , "--pretty=format:%h %cr <%an>" , "--abbrev-commit" )
1022+ if err != nil {
1023+ commitsBaseWipBranch = currentBaseBranch .remote (configuration ).String () + ".." + currentWipBranch .String ()
1024+ log = silentgit ("--no-pager" , "log" , commitsBaseWipBranch , "--pretty=format:%h %cr <%an>" , "--abbrev-commit" )
1025+ }
10271026 lines := strings .Split (log , "\n " )
10281027 if len (lines ) > 5 {
1029- say .Info ("wip branch '" + currentWipBranch + "' contains " + strconv .Itoa (len (lines )) + " commits. The last 5 were:" )
1028+ say .Info ("wip branch '" + currentWipBranch . String () + "' contains " + strconv .Itoa (len (lines )) + " commits. The last 5 were:" )
10301029 lines = lines [:5 ]
10311030 }
10321031 ReverseSlice (lines )
@@ -1094,7 +1093,8 @@ func doBranchesDiverge(ancestor string, successor string) bool {
10941093}
10951094
10961095func gitUserName () string {
1097- return silentgitignorefailure ("config" , "--get" , "user.name" )
1096+ output , _ := silentgitignorefailure ("config" , "--get" , "user.name" )
1097+ return output
10981098}
10991099
11001100func gitUserEmail () string {
@@ -1150,13 +1150,13 @@ func silentgit(args ...string) string {
11501150 return strings .TrimSpace (output )
11511151}
11521152
1153- func silentgitignorefailure (args ... string ) string {
1153+ func silentgitignorefailure (args ... string ) ( string , error ) {
11541154 _ , output , err := runCommandSilent ("git" , args ... )
11551155
11561156 if err != nil {
1157- return ""
1157+ return "" , err
11581158 }
1159- return strings .TrimSpace (output )
1159+ return strings .TrimSpace (output ), nil
11601160}
11611161
11621162func deleteEmptyStrings (s []string ) []string {
@@ -1225,7 +1225,8 @@ func gitIgnoreFailure(args ...string) error {
12251225}
12261226
12271227func gitCommitHash () string {
1228- return silentgitignorefailure ("rev-parse" , "HEAD" )
1228+ output , _ := silentgitignorefailure ("rev-parse" , "HEAD" )
1229+ return output
12291230}
12301231
12311232func gitVersion () string {
0 commit comments