From 95940ee01ecfe63892bac0d916ab795645e53e8a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 9 Mar 2025 17:30:19 +0100 Subject: [PATCH 1/2] Ignore commit prefixes with an empty pattern 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 as git: commitPrefix: pattern: "" replace: "" This 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 https://github.com/jesseduffield/lazygit/discussions/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. --- pkg/gui/controllers/helpers/working_tree_helper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index c967fab92..1cf658818 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -155,6 +155,9 @@ func (self *WorkingTreeHelper) HandleCommitPress() error { commitPrefixConfigs := self.commitPrefixConfigsForRepo() for _, commitPrefixConfig := range commitPrefixConfigs { prefixPattern := commitPrefixConfig.Pattern + if prefixPattern == "" { + continue + } prefixReplace := commitPrefixConfig.Replace branchName := self.refHelper.GetCheckedOutRef().Name rgx, err := regexp.Compile(prefixPattern) From 05a18edc549a5090f237620975044da7eb0bde99 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 9 Mar 2025 17:38:59 +0100 Subject: [PATCH 2/2] Add hint to not copy the whole defaults section into the config file I'm not mentioning *why* it's not a good idea, and I'm not sure it's important to explain this to users. I'll say it here: - it exposes users to potential bugs like the one described in the previous commit - if we decide to change the default of an option to something "better" (like we did with the "show graph" setting), users don't benefit from what we think is an improvement for most users --- docs/Config.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/Config.md b/docs/Config.md index 7ffeca39f..044ba10ea 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -31,6 +31,8 @@ to the top of your config file or via [Visual Studio Code settings.json config][ ## Default +This is only meant as a reference for what config options exist, and what their default values are. It is not meant to be copied and pasted into your config file as a whole; that's not a good idea for several reasons. It is recommended to include only those settings in your config file that you actually want to change. + ```yaml # Config relating to the Lazygit UI