summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-05-02 15:47:54 +0200
committerPatrick Steinhardt <ps@pks.im>2016-05-02 17:45:24 +0200
commit7b24c4fd48abc67792f2af82c0eb374618475d17 (patch)
treeb378e5ea64722ad9843eeaeb160fc429cc019eaf
parentfcd1b786017471a7cbf97b1065a00f0551d47115 (diff)
downloadlibgit2-7b24c4fd48abc67792f2af82c0eb374618475d17.tar.gz
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.
-rw-r--r--src/checkout.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/checkout.c b/src/checkout.c
index fed1819aa..d84b46ba7 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -1360,9 +1360,11 @@ fail:
static bool should_remove_existing(checkout_data *data)
{
- int ignorecase = 0;
+ int ignorecase;
- git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE);
+ if (git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE) < 0) {
+ ignorecase = 0;
+ }
return (ignorecase &&
(data->strategy & GIT_CHECKOUT_DONT_REMOVE_EXISTING) == 0);