Skip to content

Commit 5d60f3c

Browse files
Matheus28derrickstolee
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]>
1 parent 1bdb9e3 commit 5d60f3c

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
@@ -1100,6 +1100,9 @@ static int safe_directory_cb(const char *key, const char *value, void *d)
11001100
{
11011101
struct safe_directory_data *data = d;
11021102

1103+
if (strcmp(key, "safe.directory"))
1104+
return 0;
1105+
11031106
if (!value || !*value)
11041107
data->is_safe = 0;
11051108
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)