forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3791: Various fixes around
safe.directory
The first three commits are rebased versions of those in gitgitgadget#1215. These allow the following: 1. Fix `git config --global foo.bar <path>` from allowing the `<path>`. As a bonus, users with a config value starting with `/` will not get a warning about "old-style" paths needing a "`%(prefix)/`". 2. When in WSL, the path starts with `/` so it needs to be interpolated properly. Update the warning to include `%(prefix)/` to get the right value for WSL users. (This is specifically for using Git for Windows from Git Bash, but in a WSL directory.) 3. When using WSL, the ownership check fails and reports an error message. This is noisy, and happens even if the user has marked the path with `safe.directory`. Remove that error message.
- Loading branch information
Showing
4 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
test_description='verify safe.directory checks' | ||
|
||
. ./test-lib.sh | ||
|
||
GIT_TEST_ASSUME_DIFFERENT_OWNER=1 | ||
export GIT_TEST_ASSUME_DIFFERENT_OWNER | ||
|
||
expect_rejected_dir () { | ||
test_must_fail git status 2>err && | ||
grep "safe.directory" err | ||
} | ||
|
||
test_expect_success 'safe.directory is not set' ' | ||
expect_rejected_dir | ||
' | ||
|
||
test_expect_success 'safe.directory does not match' ' | ||
git config --global safe.directory bogus && | ||
expect_rejected_dir | ||
' | ||
|
||
test_expect_success 'path exist as different key' ' | ||
git config --global foo.bar "$(pwd)" && | ||
expect_rejected_dir | ||
' | ||
|
||
test_expect_success 'safe.directory matches' ' | ||
git config --global --add safe.directory "$(pwd)" && | ||
git status | ||
' | ||
|
||
test_expect_success 'safe.directory matches, but is reset' ' | ||
git config --global --add safe.directory "" && | ||
expect_rejected_dir | ||
' | ||
|
||
test_expect_success 'safe.directory=*' ' | ||
git config --global --add safe.directory "*" && | ||
git status | ||
' | ||
|
||
test_expect_success 'safe.directory=*, but is reset' ' | ||
git config --global --add safe.directory "" && | ||
expect_rejected_dir | ||
' | ||
|
||
test_done |