@@ -52,30 +52,30 @@ 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 nil
55+ return ErrSilent
5656 }
5757
5858 // Determine trunk branch
5959 trunk := opts .base
6060
6161 // Enable git rerere so conflict resolutions are remembered.
6262 if err := ensureRerere (cfg ); errors .Is (err , errInterrupt ) {
63- return nil
63+ return ErrSilent
6464 }
6565
6666 if trunk == "" {
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 nil
70+ return ErrSilent
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 nil
78+ return ErrSilent
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 nil
96+ return ErrSilent
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 nil
107+ return ErrSilent
108108 }
109109 for _ , b := range opts .branches {
110110 if ! git .BranchExists (b ) {
111111 cfg .Errorf ("branch %q does not exist" , b )
112- return nil
112+ return ErrSilent
113113 }
114114 if err := sf .ValidateNoDuplicateBranch (b ); err != nil {
115115 cfg .Errorf ("branch %q already exists in a stack" , b )
116- return nil
116+ return ErrSilent
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 nil
135+ return ErrSilent
136136 }
137137 }
138138 }
@@ -141,12 +141,12 @@ 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 nil
144+ return ErrSilent
145145 }
146146 if ! git .BranchExists (b ) {
147147 if err := git .CreateBranch (b , trunk ); err != nil {
148148 cfg .Errorf ("creating branch %s: %s" , b , err )
149- return nil
149+ return ErrSilent
150150 }
151151 }
152152 }
@@ -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 nil
158+ return ErrSilent
159159 }
160160 p := prompter .New (cfg .In , cfg .Out , cfg .Err )
161161
@@ -165,10 +165,10 @@ func runInit(cfg *config.Config, opts *initOptions) error {
165165 if err != nil {
166166 if isInterruptError (err ) {
167167 printInterrupt (cfg )
168- return nil
168+ return ErrSilent
169169 }
170170 cfg .Errorf ("failed to read prefix: %s" , err )
171- return nil
171+ return ErrSilent
172172 }
173173 opts .prefix = strings .TrimSpace (prefixInput )
174174 }
@@ -183,15 +183,15 @@ func runInit(cfg *config.Config, opts *initOptions) error {
183183 if err != nil {
184184 if isInterruptError (err ) {
185185 printInterrupt (cfg )
186- return nil
186+ return ErrSilent
187187 }
188188 cfg .Errorf ("failed to confirm branch selection: %s" , err )
189- return nil
189+ return ErrSilent
190190 }
191191 if useCurrentBranch {
192192 if err := sf .ValidateNoDuplicateBranch (currentBranch ); err != nil {
193193 cfg .Errorf ("branch %q already exists in the stack" , currentBranch )
194- return nil
194+ return ErrSilent
195195 }
196196 branches = []string {currentBranch }
197197 }
@@ -206,10 +206,10 @@ func runInit(cfg *config.Config, opts *initOptions) error {
206206 if err != nil {
207207 if isInterruptError (err ) {
208208 printInterrupt (cfg )
209- return nil
209+ return ErrSilent
210210 }
211211 cfg .Errorf ("failed to read branch name: %s" , err )
212- return nil
212+ return ErrSilent
213213 }
214214 branchName = strings .TrimSpace (branchName )
215215
@@ -218,20 +218,20 @@ 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 nil
221+ return ErrSilent
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 nil
229+ return ErrSilent
230230 }
231231 if ! git .BranchExists (branchName ) {
232232 if err := git .CreateBranch (branchName , trunk ); err != nil {
233233 cfg .Errorf ("creating branch %s: %s" , branchName , err )
234- return nil
234+ return ErrSilent
235235 }
236236 }
237237 branches = []string {branchName }
@@ -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 nil
245+ return ErrSilent
246246 }
247247 }
248248
@@ -288,7 +288,7 @@ func runInit(cfg *config.Config, opts *initOptions) error {
288288 if currentBranch != lastBranch {
289289 if err := git .CheckoutBranch (lastBranch ); err != nil {
290290 cfg .Errorf ("switching to branch %s: %s" , lastBranch , err )
291- return nil
291+ return ErrSilent
292292 }
293293 cfg .Printf ("Switched to branch %s" , lastBranch )
294294 } else {
0 commit comments