Skip to content

Commit b8b358c

Browse files
committed
Improve the 'worksapce branch is advanced by the user' Git command for a quick fix.
1 parent 6ab41fb commit b8b358c

File tree

2 files changed

+9
-21
lines changed
  • crates/but-workspace

2 files changed

+9
-21
lines changed

crates/but-workspace/src/ref_info.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -483,22 +483,10 @@ pub(crate) mod function {
483483
[info.commit_index_of_managed_commit]
484484
.id;
485485
msg.push_str(
486-
"The current changes will be stashed and must be re-applied manually. Commit them otherwise.\n",
486+
"Run the following command in your working directory to fix this while leaving your worktree unchanged.\n",
487487
);
488-
msg.push_str(
489-
"Run the following command in your working directory to fix this and restore the committed changes.\n\n",
490-
);
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-
));
488+
msg.push_str("Worktree changes need to be re-committed manually for now.\n\n");
489+
msg.push_str(&format!(" git reset --soft {ws_commit_id}"));
502490
bail!("{msg}");
503491
}
504492
info.compute_similarity(graph, repo, opts.expensive_commit_info)?;

crates/but-workspace/tests/workspace/ref_info/with_workspace_commit/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,10 +3248,10 @@ fn advanced_workspace_multi_stack() -> anyhow::Result<()> {
32483248
insta::assert_snapshot!(err.to_string(), @r"
32493249
Found 5 commit(s) on top of the workspace commit.
32503250
3251-
The current changes will be stashed and must be re-applied manually. Commit them otherwise.
3252-
Run the following command in your working directory to fix this and restore the committed changes.
3251+
Run the following command in your working directory to fix this while leaving your worktree unchanged.
3252+
Worktree changes need to be re-committed manually for now.
32533253
3254-
git stash && git reset --hard 619d5486e6f5ae7f5e4ecc4a6ea506d6c8433410 && git checkout a7131b181b20c699ecbe4f6145bbb8746716c18b -- .
3254+
git reset --soft 619d5486e6f5ae7f5e4ecc4a6ea506d6c8433410
32553255
");
32563256
Ok(())
32573257
}
@@ -3280,10 +3280,10 @@ fn advanced_workspace_single_stack() -> anyhow::Result<()> {
32803280
insta::assert_snapshot!(err.to_string(), @r"
32813281
Found 5 commit(s) on top of the workspace commit.
32823282
3283-
The current changes will be stashed and must be re-applied manually. Commit them otherwise.
3284-
Run the following command in your working directory to fix this and restore the committed changes.
3283+
Run the following command in your working directory to fix this while leaving your worktree unchanged.
3284+
Worktree changes need to be re-committed manually for now.
32853285
3286-
git stash && git reset --hard c58f15768a8ba280fe773ffc4820b13ad882cd84 && git checkout da912a8a455bca9e94ed65cb42328177fa891081 -- .
3286+
git reset --soft c58f15768a8ba280fe773ffc4820b13ad882cd84
32873287
");
32883288
Ok(())
32893289
}

0 commit comments

Comments
 (0)