Skip to content

Commit

Permalink
gitcfg: rewrite the config parser to be path-agnostic
Browse files Browse the repository at this point in the history
We have been running into configuraiton issues on platforms where the
.gitconfig might be stored in a location that is opaque and unknown to
cola a-priori.

The root cause is that we read each config file separately, with three
different "git config --file ..." calls, and this logic requires that we
know *exactly* which config files we are going to read.

Another downside to reading the config files one-at-a-time is that it
requires three calls to "git".

Rework the config reader so that it reads all of the configuration using
a single call to "git config --show-origin --show-scope --list".

"git config" will output the file paths that it reads when run this way,
which alleviates cola from needing to know about the paths itself.

Furthermore, this ensures that we will read the config value in all
situations. The file paths are still used to maintain a cache (to
prevent repeated calls to "git config") but they are no longer necessary
for reading the values.

Closes #927
Related-to: #1258
Related-to: #1263
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Oct 11, 2022
1 parent 4726cd5 commit 2c77ba5
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 201 deletions.
2 changes: 1 addition & 1 deletion cola/app.py
Expand Up @@ -166,7 +166,7 @@ def get_icon_themes(context):
if icon_themes_env:
result.extend([x for x in icon_themes_env.split(':') if x])

icon_themes_cfg = context.cfg.get_all('cola.icontheme')
icon_themes_cfg = list(reversed(context.cfg.get_all('cola.icontheme')))
if icon_themes_cfg:
result.extend(icon_themes_cfg)

Expand Down

0 comments on commit 2c77ba5

Please sign in to comment.