@@ -52,7 +52,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
5252 gitDir , err := git .GitDir ()
5353 if err != nil {
5454 cfg .Errorf ("not a git repository" )
55- return ErrSilent
55+ return ErrNotInStack
5656 }
5757
5858 // Determine trunk branch
@@ -67,15 +67,15 @@ func runInit(cfg *config.Config, opts *initOptions) error {
6767 trunk , err = git .DefaultBranch ()
6868 if err != nil {
6969 cfg .Errorf ("unable to determine default branch\n Use -b to specify the trunk branch" )
70- return ErrSilent
70+ return ErrNotInStack
7171 }
7272 }
7373
7474 // Load existing stack file
7575 sf , err := stack .Load (gitDir )
7676 if err != nil {
7777 cfg .Errorf ("failed to load stack state: %s" , err )
78- return ErrSilent
78+ return ErrNotInStack
7979 }
8080
8181 // Set repository context
@@ -93,7 +93,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
9393 for _ , s := range sf .FindAllStacksForBranch (currentBranch ) {
9494 if s .IndexOf (currentBranch ) >= 0 {
9595 cfg .Errorf ("current branch %q is already part of a stack" , currentBranch )
96- return ErrSilent
96+ return ErrInvalidArgs
9797 }
9898 }
9999 }
@@ -104,16 +104,16 @@ func runInit(cfg *config.Config, opts *initOptions) error {
104104 // Adopt mode: validate all specified branches exist
105105 if len (opts .branches ) == 0 {
106106 cfg .Errorf ("--adopt requires at least one branch name" )
107- return ErrSilent
107+ return ErrInvalidArgs
108108 }
109109 for _ , b := range opts .branches {
110110 if ! git .BranchExists (b ) {
111111 cfg .Errorf ("branch %q does not exist" , b )
112- return ErrSilent
112+ return ErrInvalidArgs
113113 }
114114 if err := sf .ValidateNoDuplicateBranch (b ); err != nil {
115115 cfg .Errorf ("branch %q already exists in a stack" , b )
116- return ErrSilent
116+ return ErrInvalidArgs
117117 }
118118 }
119119 branches = opts .branches
@@ -132,7 +132,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
132132 state = "merged"
133133 }
134134 cfg .Errorf ("branch %q already has a %s PR (#%d: %s)" , b , state , pr .Number , pr .URL )
135- return ErrSilent
135+ return ErrInvalidArgs
136136 }
137137 }
138138 }
@@ -141,7 +141,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
141141 for _ , b := range opts .branches {
142142 if err := sf .ValidateNoDuplicateBranch (b ); err != nil {
143143 cfg .Errorf ("branch %q already exists in a stack" , b )
144- return ErrSilent
144+ return ErrInvalidArgs
145145 }
146146 if ! git .BranchExists (b ) {
147147 if err := git .CreateBranch (b , trunk ); err != nil {
@@ -155,7 +155,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
155155 // Interactive mode
156156 if ! cfg .IsInteractive () {
157157 cfg .Errorf ("interactive input required; provide branch names or use --adopt" )
158- return ErrSilent
158+ return ErrInvalidArgs
159159 }
160160 p := prompter .New (cfg .In , cfg .Out , cfg .Err )
161161
@@ -191,7 +191,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
191191 if useCurrentBranch {
192192 if err := sf .ValidateNoDuplicateBranch (currentBranch ); err != nil {
193193 cfg .Errorf ("branch %q already exists in the stack" , currentBranch )
194- return ErrSilent
194+ return ErrInvalidArgs
195195 }
196196 branches = []string {currentBranch }
197197 }
@@ -218,15 +218,15 @@ func runInit(cfg *config.Config, opts *initOptions) error {
218218 branchName = branch .NextNumberedName (opts .prefix , nil )
219219 } else if branchName == "" {
220220 cfg .Errorf ("branch name cannot be empty" )
221- return ErrSilent
221+ return ErrInvalidArgs
222222 } else if opts .prefix != "" {
223223 // Prepend prefix to the user-provided name
224224 branchName = opts .prefix + "/" + branchName
225225 }
226226
227227 if err := sf .ValidateNoDuplicateBranch (branchName ); err != nil {
228228 cfg .Errorf ("branch %q already exists in a stack" , branchName )
229- return ErrSilent
229+ return ErrInvalidArgs
230230 }
231231 if ! git .BranchExists (branchName ) {
232232 if err := git .CreateBranch (branchName , trunk ); err != nil {
@@ -242,7 +242,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
242242 if opts .prefix != "" {
243243 if err := git .ValidateRefName (opts .prefix ); err != nil {
244244 cfg .Errorf ("invalid prefix %q: must be a valid git ref component" , opts .prefix )
245- return ErrSilent
245+ return ErrInvalidArgs
246246 }
247247 }
248248
0 commit comments