This repository was archived by the owner on Dec 12, 2024. It is now read-only.
Commit 8cc5926 1 parent f63213d commit 8cc5926 Copy full SHA for 8cc5926
File tree 1 file changed +17
-12
lines changed
1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -150,35 +150,40 @@ fn main() {
150
150
151
151
Ok ( branches)
152
152
} ;
153
+
154
+ let fallback_base = || -> git_glimpse:: Result < _ > {
155
+ let base = git_config ( "glimpse.base" ) ?;
156
+ let base = base. unwrap_or_else ( || {
157
+ let default = "main" ;
158
+ log:: debug!(
159
+ "no base branch specified in command line or configuration, falling back to \
160
+ {default:?}"
161
+ ) ;
162
+ default. to_owned ( )
163
+ } ) ;
164
+ Ok ( base)
165
+ } ;
166
+
153
167
let ( branches, files) = match subcommand {
154
168
Subcommand :: Stack {
155
169
base,
156
170
config,
157
171
files : FileSelection { files } ,
158
172
} => {
159
- let specified_base = base
160
- . map ( Ok )
161
- . or_else ( || git_config ( "glimpse.base" ) . transpose ( ) )
162
- . transpose ( ) ?;
163
- let base = specified_base. as_deref ( ) . unwrap_or_else ( || {
164
- let default = "main" ;
165
- log:: debug!( "no base branch specified in command line or configuration, falling back to {default:?}" ) ;
166
- default
167
- } ) ;
168
-
173
+ let base = base. map ( Ok ) . unwrap_or_else ( fallback_base) ?;
169
174
let branches = if let Some ( current_branch) = current_branch ( ) ? {
170
175
let mut config = config;
171
176
if current_branch == base {
172
177
config. select_upstreams = true ;
173
178
}
174
179
branches ( & config, & |cmd| {
175
180
if base != current_branch {
176
- cmd. arg ( base) ;
181
+ cmd. arg ( & base) ;
177
182
}
178
183
cmd. arg ( & current_branch) . arg ( "--all" )
179
184
} ) ?
180
185
} else {
181
- let mut branches = branches ( & config, & |cmd| cmd. arg ( base) . arg ( "--all" ) ) ?;
186
+ let mut branches = branches ( & config, & |cmd| cmd. arg ( & base) . arg ( "--all" ) ) ?;
182
187
branches. push ( "HEAD" . to_owned ( ) ) ;
183
188
branches
184
189
} ;
You can’t perform that action at this time.
0 commit comments