Commit aed07f9
committed
config: keep bailing on unreadable global files
The behaviour for `git config list` is:
A. Without `--global`, it should not bail on unreadable/non-existent
global config files.
B. With `--global`, it should bail when both `$HOME/.gitconfig` and
`$XDG_CONFIG_HOME/git/config` are unreadable. It should not bail
when one or more of them is readable.
The previous patch introduced a regression in scenario B: running
`git config list --global` would not fail when both global config files
are unreadable. For example,
`GIT_CONFIG_GLOBAL=does-not-exist git config list --global` would exit
with status code 0.
Assuming that `config_source->scope == CONFIG_SCOPE_GLOBAL` iff the
`--global` argument is specified, use this to determine whether to bail.
When reading only the global scope and both config files are unreadable,
then adjust the return code to be non-zero.
Note: The logic to determine the exit code does not actually sum the
return codes of the underlying operations. Instead, it uses a single
decrement operation. If this is undesirable, we can change it to sum
the return codes of the underlying operations instead.
Lastly, modify the tests to remove the known breakage/regression. The
tests for scenario B should now pass.
Signed-off-by: Delilah Ashley Wu <[email protected]>1 parent f5ba3b6 commit aed07f9
2 files changed
+33
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1498 | 1498 | | |
1499 | 1499 | | |
1500 | 1500 | | |
1501 | | - | |
1502 | | - | |
| 1501 | + | |
| 1502 | + | |
1503 | 1503 | | |
1504 | 1504 | | |
1505 | 1505 | | |
| |||
1532 | 1532 | | |
1533 | 1533 | | |
1534 | 1534 | | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
1535 | 1538 | | |
1536 | 1539 | | |
1537 | | - | |
1538 | | - | |
1539 | | - | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
1540 | 1559 | | |
1541 | | - | |
1542 | | - | |
1543 | | - | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
1544 | 1563 | | |
1545 | 1564 | | |
1546 | 1565 | | |
| |||
1601 | 1620 | | |
1602 | 1621 | | |
1603 | 1622 | | |
1604 | | - | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
1605 | 1627 | | |
1606 | 1628 | | |
1607 | 1629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2372 | 2372 | | |
2373 | 2373 | | |
2374 | 2374 | | |
2375 | | - | |
| 2375 | + | |
2376 | 2376 | | |
2377 | 2377 | | |
2378 | 2378 | | |
| |||
2483 | 2483 | | |
2484 | 2484 | | |
2485 | 2485 | | |
2486 | | - | |
| 2486 | + | |
2487 | 2487 | | |
2488 | 2488 | | |
2489 | 2489 | | |
| |||
0 commit comments