@@ -167,6 +167,38 @@ def test_backslash_line_continuation(self):
167167 key = "co" if section == "alias" else "k"
168168 self .assertEqual (config .get_value (section , key ), expected )
169169
170+ def test_get_value_reads_git_boolean_spellings (self ):
171+ # git accepts yes/no and on/off as well as true/false, and getboolean on
172+ # this class already did. get_value returned them as strings, so "no" and
173+ # "off" arrived as non-empty (truthy) values for a caller testing them.
174+ cases = [
175+ (b"true" , True ),
176+ (b"TRUE" , True ),
177+ (b"yes" , True ),
178+ (b"Yes" , True ),
179+ (b"on" , True ),
180+ (b"On" , True ),
181+ (b"false" , False ),
182+ (b"no" , False ),
183+ (b"off" , False ),
184+ (b"Off" , False ),
185+ ]
186+ for raw , expected in cases :
187+ config_file = io .BytesIO (b"[core]\n \t flag = " + raw + b"\n " )
188+ config_file .name = "boolean_spellings.config"
189+ config = GitConfigParser (config_file )
190+ config .read ()
191+ self .assertIs (config .get_value ("core" , "flag" ), expected , raw .decode ())
192+ # The two accessors must not disagree about the same value.
193+ self .assertIs (config .getboolean ("core" , "flag" ), expected , raw .decode ())
194+
195+ # A value that is not a boolean at all still comes back untouched.
196+ config_file = io .BytesIO (b"[core]\n \t flag = meld\n " )
197+ config_file .name = "boolean_spellings.config"
198+ config = GitConfigParser (config_file )
199+ config .read ()
200+ self .assertEqual (config .get_value ("core" , "flag" ), "meld" )
201+
170202 @with_rw_directory
171203 def test_comment_backslash_does_not_continue_value (self , rw_dir ):
172204 config_path = osp .join (rw_dir , "config" )
0 commit comments