File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -221,8 +221,8 @@ pub struct RefInfo {
221
221
#[ derive( Debug , Clone ) ]
222
222
pub struct AncestorWorkspaceCommit {
223
223
/// The commits along the first parent that are between the managed workspace reference and the managed workspace commit.
224
- /// The vec is never empty.
225
- pub commits_outside : Vec < crate :: ref_info:: Commit > ,
224
+ /// The vec *should* not be empty, but it can be empty in practice for reasons yet to be discovered .
225
+ pub commits_outside : Vec < ref_info:: Commit > ,
226
226
/// The index of the segment that actually holds the managed workspace commit.
227
227
pub segment_with_managed_commit : SegmentIndex ,
228
228
/// The index of the workspace commit within the `commits` array in its parent segment.
Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ pub(crate) mod function {
337
337
use crate :: ref_info:: { LocalCommit , LocalCommitRelation } ;
338
338
use crate :: ui:: PushStatus ;
339
339
use crate :: { AncestorWorkspaceCommit , RefInfo , WorkspaceCommit , branch} ;
340
- use anyhow:: { Context , bail} ;
340
+ use anyhow:: bail;
341
341
use but_core:: ref_metadata:: ValueInfo ;
342
342
use but_graph:: petgraph:: Direction ;
343
343
use but_graph:: {
@@ -488,10 +488,17 @@ pub(crate) mod function {
488
488
msg. push_str (
489
489
"Run the following command in your working directory to fix this and restore the committed changes.\n \n " ,
490
490
) ;
491
- msg. push_str ( & format ! ( " git stash && git reset --hard {ws_commit_id} && git checkout {user_commit_id} -- ." ,
492
- user_commit_id = info. commits_outside
493
- . first( )
494
- . context( "BUG: at least one user commit on top" ) ?. id) ) ;
491
+ msg. push_str ( & format ! (
492
+ " git stash && git reset --hard {ws_commit_id}{checkout_clause}" ,
493
+ checkout_clause = info
494
+ . commits_outside
495
+ . first( )
496
+ . map( |c| format!(
497
+ " && git checkout {user_commit_id} -- ." ,
498
+ user_commit_id = c. id
499
+ ) )
500
+ . unwrap_or_default( )
501
+ ) ) ;
495
502
bail ! ( "{msg}" ) ;
496
503
}
497
504
info. compute_similarity ( graph, repo, opts. expensive_commit_info ) ?;
You can’t perform that action at this time.
0 commit comments