Skip to content

Commit 7b24c4f

Browse files
committed
checkout: set ignorecase=0 when config lookup fails
When `git_repository__cvar` fails we may end up with a `ignorecase` value of `-1`. As we subsequently check if `ignorecase` is non-zero, we may end up reporting that data should be removed when in fact it should not. Err on the safer side and set `ignorecase = 0` when `git_repository__cvar` fails.
1 parent fcd1b78 commit 7b24c4f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/checkout.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,9 +1360,11 @@ static int checkout_get_actions(
13601360

13611361
static bool should_remove_existing(checkout_data *data)
13621362
{
1363-
int ignorecase = 0;
1363+
int ignorecase;
13641364

1365-
git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE);
1365+
if (git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE) < 0) {
1366+
ignorecase = 0;
1367+
}
13661368

13671369
return (ignorecase &&
13681370
(data->strategy & GIT_CHECKOUT_DONT_REMOVE_EXISTING) == 0);

0 commit comments

Comments
 (0)