Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix Microsoft #71258 - Cannot undo empty commits #72699
This is a fix for #71258
I've noticed that in this bug there are essentially two parts to it. If VS Code tries to undo a commit where there was an empty commit message, or a commit message with only whitespace, the "Bad Commit" error occurs.
Furthermore, there is a way to make a commit with just whitespace through VS Code. If you press the tick by Source Control: Git, enter some whitespace, and then press enter, the commit goes through with the message being whitespace. If you try to undo this, the same error will occur.
I've removed the second as a requirement because the issue does not explicitly call for a fix on that.
By testing with different commits it seems the regex matching expression is at fault.
The string that goes into the regex match is as follows:
The last part, the name of this commit, is optional, and is not present when there is an empty git commit, but the regex expression looks for it, and hence sees the expression as invalid.
The above has been reverted to its original behaviour.
joaomoreno left a comment •
Good investigation but the fix breaks the Undo behavior of populating the input box with the commit message. By removing that 4th capture group, you lost the commit message for commits which do have a message. I've pushed daf581d instead.
I've merged your PR anyway, since you drove me to the right fix. Thanks!