Skip to content

Commit

Permalink
fix(amend): don't detach current branch when current commit has desce…
Browse files Browse the repository at this point in the history
…ndants
  • Loading branch information
arxanas committed Oct 3, 2023
1 parent 8520d4e commit 0c184b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion git-branchless/src/commands/amend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub fn amend(
resolve_merge_conflicts: move_options.resolve_merge_conflicts,
check_out_commit_options: CheckOutCommitOptions {
additional_args: Default::default(),
reset: true,
reset: false,
render_smartlog: false,
},
};
Expand Down
14 changes: 14 additions & 0 deletions git-branchless/tests/test_amend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,18 @@ fn test_amend_no_detach_branch() -> eyre::Result<()> {

git.run(&["checkout", "-b", "foo"])?;
git.commit_file("test1", 1)?;
git.run(&["checkout", "-b", "bar"])?;
git.commit_file("test2", 2)?;
git.run(&["checkout", "foo"])?;

{
let stdout = git.smartlog()?;
insta::assert_snapshot!(stdout, @r###"
O f777ecc (master) create initial.txt
|
@ 62fc20d (> foo) create test1.txt
|
o 96d1c37 (bar) create test2.txt
"###);
}

Expand All @@ -1013,6 +1018,13 @@ fn test_amend_no_detach_branch() -> eyre::Result<()> {
insta::assert_snapshot!(stdout, @r###"
branchless: processing 1 update: branch foo
branchless: running command: <git-executable> reset foo
Attempting rebase in-memory...
[1/1] Committed as: fc597fa create test2.txt
branchless: processing 1 update: branch bar
branchless: processing 1 rewritten commit
branchless: running command: <git-executable> checkout foo
In-memory rebase succeeded.
Restacked 1 commit.
Amended with 1 uncommitted change.
"###);
}
Expand All @@ -1023,6 +1035,8 @@ fn test_amend_no_detach_branch() -> eyre::Result<()> {
O f777ecc (master) create initial.txt
|
@ 7143ebc (> foo) create test1.txt
|
o fc597fa (bar) create test2.txt
"###);
}

Expand Down

0 comments on commit 0c184b0

Please sign in to comment.