New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Undo Last commit' does not work if there is no commit message #71258
Comments
(Experimental duplicate detection)
|
@joaomoreno is this issue resolved? if not i would like to work on this. |
I have the same question, would like to work on this if it still isn't resolved. @joaomoreno |
Hi again everyone, 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. As I described it in the last comment, 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 think I've located where the error with whitespace commits is happening. In commands.ts, the function undoCommit() calls getCommit() on 'HEAD' and leads to the getCommit() function in git.ts, which is where the 'bad commit format' error originates. getCommit() in git.ts returns the 'bad commit' error if the function parseGitCommit() (which takes an inputted string) returns null. parseGitCommit() runs a regex check on the inputted string after calling trim() on it and returns null if it doesn't find any matches. It appears to me that the error eventually corresponds to that regex match/calling trim() on the inputted string, as that should be causing any pure whitespace commit message passed in to become an empty string. I'm hesitant to simply remove the trim() function call, however, as I believe that could cause a lot of new issues. |
I have found a potential fix for this error, I will submit a pull request for it soon. |
I have found this error to be in the same location as well. By testing with different commits it seems the regex matching expression is at fault, not the trimming function call. 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 build on my pull requests is failing and I am unsure why. I would appreciate help if someone could provide it for me. It seems an integration test for macOS is failing. |
Issue Type: Bug
VS Code version: Code 1.32.1 (05f146c, 2019-03-08T00:46:10.898Z)
OS version: Linux x64 4.15.0-46-generic
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
surface_synchronization: enabled_on
video_decode: unavailable_off
webgl: enabled
webgl2: enabled
Extensions (3)
The text was updated successfully, but these errors were encountered: