Repository navigation
fix(squash): do not commit unstaged changes - #1285
Conversation
git squash with a message ran `git commit -a`, so edits that were never staged went into the squash commit. merge --squash and reset --soft already stage the squashed changes.
spacewander
left a comment
There was a problem hiding this comment.
The test runs raw bin/git-squash, which lacks source helper/git-extra-utility. So git_extra_default_branch is "command not found" on stderr and prompt_continuation_if_squashing_default_branch() is a silent no-op. The test passes by luck and would not catch a default-branch detection regression.
Please add test_util.install_command squash as tests/git-delete-merged-branches.bats does.
spacewander
left a comment
There was a problem hiding this comment.
Would you also update the doc to emphasize this behavior? I am worried if there is someone still expecting the previous behavior.
|
Updated the docs in be145d9. The man page and Commands.md now say that unstaged changes stay out of the squash commit, and to git add them first if you want them in. |
|
@jayhemnani9910 |
git squash <src> "<msg>"commits withgit commit -a, so any tracked file edited but not staged goes into the squash commit too. Aftergit merge --squashorgit reset --soft, the squashed changes are already staged, so-aonly adds work that was never meant for this commit.Changes
bin/git-squash: commit withgit commit -minstead ofgit commit -a -m.tests/git-squash.bats: both forms (branch, and commit on the current branch) leave unstaged edits out of the squash commit. Both tests fail without the fix.Ran
bats ./tests(92 ok) and the steps above on Linux.AI tools assisted with this contribution.