Skip to content

Commit

Permalink
gitcfg: properly handle mixed-case names in find()
Browse files Browse the repository at this point in the history
We downcase the search pattern to match the case-ignoring behavior used
by "git config", but we did not also downcase the candidate string.

Downcase both so that we properly support having tool with mixed case
names.  Add a test to ensure the proper behavior.

Related-to: #44
Reported-by: Leho Kraav <leho@kraav.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Jul 5, 2014
1 parent 6f4b6f3 commit 86d04c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cola/gitcfg.py
Expand Up @@ -301,7 +301,7 @@ def find(self, pat):
result = {}
self.update()
for key, val in self._all.items():
if match(key, pat):
if match(key.lower(), pat):
result[key] = val
return result

Expand Down
2 changes: 2 additions & 0 deletions share/doc/git-cola/relnotes.rst
Expand Up @@ -15,6 +15,8 @@ Fixes
* The `Ctrl+P` hotkey was overloaded to both "push" and "cherry-pick",
so "cherry-pick" was moved to `Shift+Ctrl+C`.

* Custom GUI tools with mixed-case names are now properly supported.

git-cola v2.0.4
===============
Usability, bells and whistles
Expand Down
8 changes: 8 additions & 0 deletions test/gitcfg_test.py
Expand Up @@ -66,6 +66,14 @@ def test_guitool_names(self):
names = self.config.get_guitool_names()
self.assertTrue('hello meow' in names)

def test_guitool_names_mixed_case(self):
self.shell('git config guitool."Meow Cat".cmd "cat hello"')
names = self.config.get_guitool_names()
self.assertTrue('Meow Cat' in names)

opts = self.config.find('guitool.Meow Cat.*')
self.assertEqual(opts['guitool.Meow Cat.cmd'], 'cat hello')


if __name__ == '__main__':
unittest.main()

0 comments on commit 86d04c7

Please sign in to comment.