Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 333896b

Browse filesBrowse files
committed
Treat false-seeming HIDE_* env var values as false
This changes how HIDE_WINDOWS_KNOWN_ERRORS and HIDE_WINDOWS_FREEZE_ERRORS environment variables, if present, are interpreted, so that values that strongly seem intuitivley to represent falsehood now do. Before, only the empty string was treated as false. Now: - "0", "false", "no", and their case variants, as well as the empty string, are treated as false. - The presence of leading and trailing whitespace in the value now longer changes the truth value it represents. For example, all-whitespace (e.g., a space) is treated as false. - Values other than the above false values, and the recognized true values "1", "true", "yes", and their variants, are still treated as true, but issue a warning about how they are unrecognied.
1 parent eb51277 commit 333896b
Copy full SHA for 333896b

File tree

2 files changed

+12
-6
lines changed
Filter options

2 files changed

+12
-6
lines changed

‎git/util.py

Copy file name to clipboardExpand all lines: git/util.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ def _read_env_flag(name: str, default: bool) -> bool:
121121
name,
122122
)
123123

124-
# FIXME: This should treat some values besides "" as expressing falsehood.
125-
return bool(value)
124+
adjusted_value = value.strip().lower()
125+
126+
if adjusted_value in {"", "0", "false", "no"}:
127+
return False
128+
if adjusted_value in {"1", "true", "yes"}:
129+
return True
130+
log.warning("%s has unrecognized value %r, treating as %r.", name, value, default)
131+
return default
126132

127133

128134
#: We need an easy way to see if Appveyor TCs start failing,

‎test/test_util.py

Copy file name to clipboardExpand all lines: test/test_util.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,15 +529,15 @@ def run_parse(value):
529529
("true-seeming", "True"),
530530
("true-seeming", "yes"),
531531
("true-seeming", "YES"),
532+
]
533+
falsy_cases = [
534+
("empty", ""),
535+
("whitespace", " "),
532536
("false-seeming", "0"),
533537
("false-seeming", "false"),
534538
("false-seeming", "False"),
535539
("false-seeming", "no"),
536540
("false-seeming", "NO"),
537-
("whitespace", " "),
538-
]
539-
falsy_cases = [
540-
("empty", ""),
541541
]
542542

543543
for msg, env_var_value in truthy_cases:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.