Fix commitPrefix setting with empty pattern #4381
Merged
+5
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before we changed the commitPrefix config to a list in #4261, we had this bug where the defaults section in
Config.md
would erroneously list the default for commitPrefix asThis was not correct, commitPrefix was a pointer, and the default for that was nil, which is not the same.
Now, some people copied and pasted the entire defaults section into their config files, setting the commitPrefix to an empty pattern (which is not the same as not setting it at all). And this caused the branch name to be filled in to the subject field for every commit; see for example #3632.
New users copying the defaults section into their config file in the current version no longer have this problem because now that commitPrefix is a list, it is no longer included in the defaults section. However, the migration that we added in #4261 would happily carry over those empty strings into a list entry, so people migrating from an older version still have the broken config in their config files.
To work around the issue, ignore commit prefix settings whose pattern is an empty string. I can't imagine a valid reason why people would actually want to set the pattern to an empty string, so I assume this only comes from the broken defaults problem described above.