Skip to content

Commit bb50ec3

Browse files
Matheus28gitster
authored andcommitted
setup: fix safe.directory key not being checked
It seems that nothing is ever checking to make sure the safe directories in the configs actually have the key safe.directory, so some unrelated config that has a value with a certain directory would also make it a safe directory. Signed-off-by: Matheus Valadares <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e47363e commit bb50ec3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,9 @@ static int safe_directory_cb(const char *key, const char *value, void *d)
10341034
{
10351035
struct safe_directory_data *data = d;
10361036

1037+
if (strcmp(key, "safe.directory"))
1038+
return 0;
1039+
10371040
if (!value || !*value)
10381041
data->is_safe = 0;
10391042
else {

t/t0033-safe-directory.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ test_expect_success 'safe.directory does not match' '
2121
expect_rejected_dir
2222
'
2323

24+
test_expect_success 'path exist as different key' '
25+
git config --global foo.bar "$(pwd)" &&
26+
expect_rejected_dir
27+
'
28+
2429
test_expect_success 'safe.directory matches' '
2530
git config --global --add safe.directory "$(pwd)" &&
2631
git status

0 commit comments

Comments
 (0)