-
Notifications
You must be signed in to change notification settings - Fork 138
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
Updates to the safe.directory config option #1215
Changes from all commits
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 |
---|---|---|
|
@@ -1100,9 +1100,14 @@ static int safe_directory_cb(const char *key, const char *value, void *d) | |
{ | ||
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. On the Git mailing list, Junio C Hamano wrote (reply to this):
|
||
struct safe_directory_data *data = d; | ||
|
||
if (!value || !*value) | ||
if (strcmp(key, "safe.directory")) | ||
return 0; | ||
|
||
if (!value || !*value) { | ||
data->is_safe = 0; | ||
else { | ||
} else if (!strcmp(value, "*")) { | ||
data->is_safe = 1; | ||
} else { | ||
const char *interpolated = NULL; | ||
|
||
if (!git_config_pathname(&interpolated, key, value) && | ||
|
@@ -1119,7 +1124,8 @@ static int ensure_valid_ownership(const char *path) | |
{ | ||
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. On the Git mailing list, Junio C Hamano wrote (reply to this):
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. On the Git mailing list, Derrick Stolee wrote (reply to this):
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. On the Git mailing list, Ævar Arnfjörð Bjarmason wrote (reply to this):
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. On the Git mailing list, Junio C Hamano wrote (reply to this):
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. On the Git mailing list, Derrick Stolee wrote (reply to this):
|
||
struct safe_directory_data data = { .path = path }; | ||
|
||
if (is_path_owned_by_current_user(path)) | ||
if (is_path_owned_by_current_user(path) && | ||
!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER", 0)) | ||
return 1; | ||
|
||
read_very_early_config(safe_directory_cb, &data); | ||
|
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 |
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.
On the Git mailing list, Junio C Hamano wrote (reply to this):