Skip to content

Commit 39f12bd

Browse files
authored
Do not call get_user_id if it is not needed
On systems without any environment variables and no pwd module, gitpython crashes as it tries to read the environment variable before looking at its config.
1 parent d8a6398 commit 39f12bd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

git/util.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,11 @@ def default_name() -> str:
704704
setattr(actor, attr, val)
705705
except KeyError:
706706
if config_reader is not None:
707-
setattr(actor, attr, config_reader.get_value('user', cvar, default()))
707+
try:
708+
val = config_reader.get_value('user', cvar)
709+
except Exception:
710+
val = default()
711+
setattr(actor, attr, val)
708712
# END config-reader handling
709713
if not getattr(actor, attr):
710714
setattr(actor, attr, default())

0 commit comments

Comments
 (0)