-
Notifications
You must be signed in to change notification settings - Fork 153
config: read both home and xdg files for --global
#1938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2367,6 +2367,71 @@ test_expect_success '--show-scope with --default' ' | |
test_cmp expect actual | ||
' | ||
|
||
test_expect_success 'list with nonexistent global config' ' | ||
rm -rf "$HOME"/.gitconfig "$HOME"/.config/git/config && | ||
git config ${mode_prefix}list --show-scope | ||
' | ||
|
||
test_expect_success 'list --global with nonexistent global config' ' | ||
rm -rf "$HOME"/.gitconfig "$HOME"/.config/git/config && | ||
test_must_fail git config ${mode_prefix}list --global --show-scope | ||
' | ||
|
||
test_expect_success 'list --global with only home' ' | ||
rm -rf "$HOME"/.config/git/config && | ||
|
||
test_when_finished rm -f \"\$HOME\"/.gitconfig && | ||
cat >"$HOME"/.gitconfig <<-EOF && | ||
[home] | ||
config = true | ||
EOF | ||
|
||
cat >expect <<-EOF && | ||
global home.config=true | ||
EOF | ||
git config ${mode_prefix}list --global --show-scope >output && | ||
test_cmp expect output | ||
' | ||
|
||
test_expect_success 'list --global with only xdg' ' | ||
rm -f "$HOME"/.gitconfig && | ||
|
||
test_when_finished rm -rf \"\$HOME\"/.config/git && | ||
mkdir -p "$HOME"/.config/git && | ||
cat >"$HOME"/.config/git/config <<-EOF && | ||
[xdg] | ||
config = true | ||
EOF | ||
|
||
cat >expect <<-EOF && | ||
global xdg.config=true | ||
EOF | ||
git config ${mode_prefix}list --global --show-scope >output && | ||
test_cmp expect output | ||
' | ||
|
||
test_expect_success 'list --global with both home and xdg' ' | ||
test_when_finished rm -f \"\$HOME\"/.gitconfig && | ||
cat >"$HOME"/.gitconfig <<-EOF && | ||
[home] | ||
config = true | ||
EOF | ||
|
||
test_when_finished rm -rf \"\$HOME\"/.config/git && | ||
mkdir -p "$HOME"/.config/git && | ||
cat >"$HOME"/.config/git/config <<-EOF && | ||
[xdg] | ||
config = true | ||
EOF | ||
|
||
cat >expect <<-EOF && | ||
global xdg.config=true | ||
global home.config=true | ||
EOF | ||
git config ${mode_prefix}list --global --show-scope >output && | ||
test_cmp expect output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of this patch, this test will fail, correct? It would be good to be clear about what step is failing here. Something like:
This demonstrates that the test is documenting the expected behavior and how the current implementation fails to achieve that result (it doesn't fail in the Later, you can remove the This is in contrast to using |
||
' | ||
|
||
test_expect_success 'override global and system config' ' | ||
test_when_finished rm -f \"\$HOME\"/.gitconfig && | ||
cat >"$HOME"/.gitconfig <<-EOF && | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--show-scope
is valuable data to include so we see that both sources are included asglobal
scope. Could you also add--show-origin
to demonstrate that we can differentiate the two files? This will be particularly important for users who are trying to figure out why a behavior change occurred (if they had both files already but one was ignored by previous behavior).