Merge pull request #3767 from pks-t/pks/misc-fixes Misc fixes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
diff --git a/src/checkout.c b/src/checkout.c
index fed1819..d84b46b 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);
diff --git a/src/delta-apply.c b/src/delta-apply.c
index 6e86a81..02ec7b7 100644
--- a/src/delta-apply.c
+++ b/src/delta-apply.c
@@ -121,13 +121,13 @@ int git__delta_apply(
size_t off = 0, len = 0;
if (cmd & 0x01) off = *delta++;
- if (cmd & 0x02) off |= *delta++ << 8;
- if (cmd & 0x04) off |= *delta++ << 16;
- if (cmd & 0x08) off |= *delta++ << 24;
+ if (cmd & 0x02) off |= *delta++ << 8UL;
+ if (cmd & 0x04) off |= *delta++ << 16UL;
+ if (cmd & 0x08) off |= *delta++ << 24UL;
if (cmd & 0x10) len = *delta++;
- if (cmd & 0x20) len |= *delta++ << 8;
- if (cmd & 0x40) len |= *delta++ << 16;
+ if (cmd & 0x20) len |= *delta++ << 8UL;
+ if (cmd & 0x40) len |= *delta++ << 16UL;
if (!len) len = 0x10000;
if (base_len < off + len || res_sz < len)
diff --git a/src/diff.c b/src/diff.c
index 64641da..26c0b89 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1083,17 +1083,13 @@ static int handle_unmatched_new_item(
if (recurse_into_dir) {
error = iterator_advance_into(&info->nitem, info->new_iter);
- /* if real error or no error, proceed with iteration */
- if (error != GIT_ENOTFOUND)
- return error;
- giterr_clear();
+ /* if directory is empty, can't advance into it, so skip it */
+ if (error == GIT_ENOTFOUND) {
+ giterr_clear();
+ error = iterator_advance(&info->nitem, info->new_iter);
+ }
- /* if directory is empty, can't advance into it, so either skip
- * it or ignore it
- */
- if (error == GIT_ENOTFOUND || contains_oitem)
- return iterator_advance(&info->nitem, info->new_iter);
- delta_type = GIT_DELTA_IGNORED;
+ return error;
}
}
diff --git a/src/index.c b/src/index.c
index 63e4796..31cb27d 100644
--- a/src/index.c
+++ b/src/index.c
@@ -3008,7 +3008,7 @@ int git_index_read_index(
if (error < 0) {
giterr_set(GITERR_INDEX, "failed to insert entry");
- return error;
+ goto done;
}
if (diff <= 0) {
diff --git a/src/merge_file.c b/src/merge_file.c
index 731f4b7..3f14a4f 100644
--- a/src/merge_file.c
+++ b/src/merge_file.c
@@ -134,8 +134,8 @@ static int merge_file__xdiff(
path = git_merge_file__best_path(
ancestor ? ancestor->path : NULL,
- ours ? ours->path : NULL,
- theirs ? theirs->path : NULL);
+ ours->path,
+ theirs->path);
if (path != NULL && (out->path = git__strdup(path)) == NULL) {
error = -1;
@@ -147,8 +147,8 @@ static int merge_file__xdiff(
out->len = mmbuffer.size;
out->mode = git_merge_file__best_mode(
ancestor ? ancestor->mode : 0,
- ours ? ours->mode : 0,
- theirs ? theirs->mode : 0);
+ ours->mode,
+ theirs->mode);
done:
if (error < 0)
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 9d9bffd..3c33160 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -91,7 +91,7 @@ static int object_mkdir(const git_buf *name, const loose_backend *be)
static size_t get_binary_object_header(obj_hdr *hdr, git_buf *obj)
{
- unsigned char c;
+ unsigned long c;
unsigned char *data = (unsigned char *)obj->ptr;
size_t shift, size, used = 0;