@@ -28,15 +28,16 @@ import (
2828const rebaseSynopsis = "move revision (and descendants) to a different branch"
2929
3030func rebase (ctx context.Context , cc * cmdContext , args []string ) error {
31+ const upstreamRev = "@{upstream}"
3132 f := flag .NewFlagSet (true , "gg rebase [--src REV | --base REV] [--dst REV] [options]" , rebaseSynopsis + `
3233
3334 Rebasing will replay a set of changes on top of the destination
3435 revision and set the current branch to the final revision.
3536
3637 If neither ` + "`--src`" + ` or ` + "`--base`" + ` is specified, it acts as if
37- ` + "`--base=@{upstream} `" + ` was specified.` )
38+ ` + "`--base=" + upstreamRev + " `"+ ` was specified.` )
3839 base := f .String ("base" , "" , "rebase everything from branching point of specified `rev`ision" )
39- dst := f .String ("dst" , "@{upstream}" , "rebase onto the specified `rev`ision" )
40+ dst := f .String ("dst" , upstreamRev , "rebase onto the specified `rev`ision" )
4041 src := f .String ("src" , "" , "rebase the specified `rev`ision and descendants" )
4142 abort := f .Bool ("abort" , false , "abort an interrupted rebase" )
4243 continue_ := f .Bool ("continue" , false , "continue an interrupted rebase" )
@@ -52,7 +53,7 @@ func rebase(ctx context.Context, cc *cmdContext, args []string) error {
5253 if * abort && * continue_ {
5354 return usagef ("can't specify both --abort and --continue" )
5455 }
55- if (* abort || * continue_ ) && (* base != "" || * dst != "@{upstream}" || * src != "" ) {
56+ if (* abort || * continue_ ) && (* base != "" || * dst != upstreamRev || * src != "" ) {
5657 return usagef ("can't specify other options with --abort or --continue" )
5758 }
5859 if * abort {
@@ -61,6 +62,11 @@ func rebase(ctx context.Context, cc *cmdContext, args []string) error {
6162 if * continue_ {
6263 return continueRebase (ctx , cc )
6364 }
65+ // Verify that -dst exists to give the user a better error message.
66+ // See https://github.com/gg-scm/gg/issues/127
67+ if _ , err := cc .git .ParseRev (ctx , * dst ); err != nil {
68+ return fmt .Errorf ("destination: %w" , err )
69+ }
6470 switch {
6571 case * base != "" && * src != "" :
6672 return usagef ("can't specify both -s and -b" )
0 commit comments