| line |
true |
false |
branch |
|
54
|
32 |
0 |
for (len = quoted; len < ctx->parse_ctx.line_len; len++) { |
|
55
|
32 |
0 |
if (!quoted && git__isspace(ctx->parse_ctx.line[len])) |
|
|
28 |
4 |
if (!quoted && git__isspace(ctx->parse_ctx.line[len])) |
|
57
|
0 |
28 |
else if (quoted && !inquote && ctx->parse_ctx.line[len] == '"') { |
|
|
0 |
0 |
else if (quoted && !inquote && ctx->parse_ctx.line[len] == '"') { |
|
|
0 |
0 |
else if (quoted && !inquote && ctx->parse_ctx.line[len] == '"') { |
|
62
|
28 |
0 |
inquote = (!inquote && ctx->parse_ctx.line[len] == '\\'); |
|
|
0 |
28 |
inquote = (!inquote && ctx->parse_ctx.line[len] == '\\'); |
|
72
|
0 |
8 |
if ((error = git_buf_put(path, ctx->parse_ctx.line, path_len)) < 0) |
|
79
|
8 |
0 |
if (path->size > 0 && path->ptr[0] == '"' && |
|
|
0 |
8 |
if (path->size > 0 && path->ptr[0] == '"' && |
|
|
0 |
0 |
if (path->size > 0 && path->ptr[0] == '"' && |
|
85
|
0 |
8 |
if (!path->size) |
|
97
|
0 |
4 |
if ((error = parse_header_path_buf(&path, ctx, header_path_len(ctx))) < 0) |
|
112
|
0 |
2 |
if (patch->old_path) { |
|
118
|
0 |
2 |
if ((error = parse_header_path_buf(&old_path, ctx, ctx->parse_ctx.line_len - 1)) < 0) |
|
134
|
0 |
2 |
if (patch->new_path) { |
|
140
|
0 |
2 |
if ((error = parse_header_path_buf(&new_path, ctx, ctx->parse_ctx.line_len - 1)) < 0) |
|
153
|
0 |
2 |
if ((git_parse_advance_digit(&m, &ctx->parse_ctx, 8)) < 0) |
|
156
|
0 |
2 |
if (m > UINT16_MAX) |
|
171
|
32 |
0 |
for (len = 0; len < ctx->parse_ctx.line_len && len < GIT_OID_HEXSZ; len++) { |
|
|
32 |
0 |
for (len = 0; len < ctx->parse_ctx.line_len && len < GIT_OID_HEXSZ; len++) { |
|
172
|
4 |
28 |
if (!git__isxdigit(ctx->parse_ctx.line[len])) |
|
176
|
4 |
0 |
if (len < GIT_OID_MINPREFIXLEN || len > GIT_OID_HEXSZ || |
|
193
|
2 |
0 |
if (parse_header_oid(&patch->base.delta->old_file.id, |
|
194
|
2 |
0 |
&patch->base.delta->old_file.id_abbrev, ctx) < 0 || |
|
195
|
0 |
2 |
git_parse_advance_expected_str(&ctx->parse_ctx, "..") < 0 || |
|
200
|
2 |
0 |
if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ' ') { |
|
|
1 |
1 |
if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ' ') { |
|
205
|
0 |
1 |
if (parse_header_mode(&mode, ctx) < 0) |
|
208
|
1 |
0 |
if (!patch->base.delta->new_file.mode) |
|
211
|
1 |
0 |
if (!patch->base.delta->old_file.mode) |
|
262
|
0 |
0 |
if (parse_header_path_buf(&path, ctx, header_path_len(ctx)) < 0) |
|
304
|
0 |
0 |
if (git_parse_advance_digit(&val, &ctx->parse_ctx, 10) < 0) |
|
307
|
0 |
0 |
if (git_parse_advance_expected_str(&ctx->parse_ctx, "%") < 0) |
|
310
|
0 |
0 |
if (val < 0 || val > 100) |
|
|
0 |
0 |
if (val < 0 || val > 100) |
|
320
|
0 |
0 |
if (parse_header_percent(&patch->base.delta->similarity, ctx) < 0) |
|
332
|
0 |
0 |
if (parse_header_percent(&dissimilarity, ctx) < 0) |
|
343
|
0 |
2 |
if (parse_header_path(&patch->header_old_path, ctx) < 0) |
|
440
|
11 |
0 |
for (; ctx->parse_ctx.remain_len > 0; git_parse_advance_line(&ctx->parse_ctx)) { |
|
443
|
11 |
0 |
if (ctx->parse_ctx.line_len == 0 || ctx->parse_ctx.line[ctx->parse_ctx.line_len - 1] != '\n') |
|
|
11 |
0 |
if (ctx->parse_ctx.line_len == 0 || ctx->parse_ctx.line[ctx->parse_ctx.line_len - 1] != '\n') |
|
446
|
108 |
0 |
for (i = 0; i < ARRAY_SIZE(transitions); i++) { |
|
457
|
2 |
9 |
if (transition->fn == NULL) |
|
462
|
0 |
9 |
if ((error = transition->fn(patch, ctx)) < 0) |
|
467
|
9 |
0 |
if (git_parse_advance_expected_str(&ctx->parse_ctx, "\n") < 0 || |
|
|
0 |
9 |
if (git_parse_advance_expected_str(&ctx->parse_ctx, "\n") < 0 || |
|
477
|
0 |
9 |
if (!found) { |
|
484
|
0 |
0 |
if (state != STATE_END) { |
|
497
|
6 |
0 |
if (git_parse_advance_digit(&num, &ctx->parse_ctx, 10) < 0 || !git__is_int(num)) |
|
|
0 |
6 |
if (git_parse_advance_digit(&num, &ctx->parse_ctx, 10) < 0 || !git__is_int(num)) |
|
518
|
2 |
0 |
if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ',') { |
|
|
1 |
1 |
if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ',') { |
|
528
|
2 |
0 |
if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ',') { |
|
|
1 |
1 |
if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ',') { |
|
534
|
0 |
2 |
if (git_parse_advance_expected_str(&ctx->parse_ctx, " @@") < 0) |
|
539
|
1 |
1 |
if (!hunk->hunk.old_lines && !hunk->hunk.new_lines) |
|
|
0 |
1 |
if (!hunk->hunk.old_lines && !hunk->hunk.new_lines) |
|
543
|
0 |
2 |
if (hunk->hunk.header_len > (GIT_DIFF_HUNK_HEADER_SIZE - 1)) |
|
559
|
0 |
0 |
if (origin == GIT_DIFF_LINE_ADDITION) |
|
561
|
0 |
0 |
if (origin == GIT_DIFF_LINE_DELETION) |
|
578
|
5 |
0 |
for (; |
|
579
|
4 |
1 |
ctx->parse_ctx.remain_len > 1 && |
|
588
|
3 |
0 |
git__sub_int_overflow(&old_lineno, old_lineno, oldlines) || |
|
589
|
0 |
3 |
git__add_int_overflow(&new_lineno, hunk->hunk.new_start, hunk->hunk.new_lines) || |
|
596
|
3 |
0 |
if (ctx->parse_ctx.line_len == 0 || ctx->parse_ctx.line[ctx->parse_ctx.line_len - 1] != '\n') { |
|
|
0 |
3 |
if (ctx->parse_ctx.line_len == 0 || ctx->parse_ctx.line[ctx->parse_ctx.line_len - 1] != '\n') { |
|
633
|
0 |
0 |
if (!oldlines) { |
|
647
|
2 |
1 |
line = git_array_alloc(patch->base.lines); |
|
|
1 |
0 |
line = git_array_alloc(patch->base.lines); |
|
648
|
0 |
3 |
GIT_ERROR_CHECK_ALLOC(line); |
|
654
|
0 |
3 |
GIT_ERROR_CHECK_ALLOC(line->content); |
|
666
|
2 |
0 |
if (oldlines || newlines) { |
|
|
0 |
2 |
if (oldlines || newlines) { |
|
679
|
0 |
2 |
if (git_parse_ctx_contains_s(&ctx->parse_ctx, "\\ ") && |
|
|
0 |
0 |
if (git_parse_ctx_contains_s(&ctx->parse_ctx, "\\ ") && |
|
682
|
0 |
0 |
line = git_array_get(patch->base.lines, git_array_size(patch->base.lines) - 1); |
|
684
|
0 |
0 |
if (line->content_len < 1) { |
|
689
|
0 |
0 |
line = git_array_alloc(patch->base.lines); |
|
|
0 |
0 |
line = git_array_alloc(patch->base.lines); |
|
690
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(line); |
|
696
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(line->content); |
|
718
|
15 |
0 |
for (; ctx->parse_ctx.remain_len > 0; git_parse_advance_line(&ctx->parse_ctx)) { |
|
720
|
4 |
11 |
if (ctx->parse_ctx.line_len < 6) |
|
725
|
0 |
11 |
if (git_parse_ctx_contains_s(&ctx->parse_ctx, "@@ -")) { |
|
732
|
0 |
0 |
if (parse_hunk_header(&hunk, ctx) < 0) { |
|
743
|
1 |
10 |
if (ctx->parse_ctx.remain_len < ctx->parse_ctx.line_len + 6) |
|
747
|
2 |
8 |
if (git_parse_ctx_contains_s(&ctx->parse_ctx, "diff --git ")) { |
|
772
|
0 |
0 |
if (git_parse_ctx_contains_s(&ctx->parse_ctx, "literal ")) { |
|
775
|
0 |
0 |
} else if (git_parse_ctx_contains_s(&ctx->parse_ctx, "delta ")) { |
|
785
|
0 |
0 |
git_parse_advance_nl(&ctx->parse_ctx) < 0 || len < 0) { |
|
790
|
0 |
0 |
while (ctx->parse_ctx.line_len) { |
|
796
|
0 |
0 |
if (c == '\n') |
|
798
|
0 |
0 |
else if (c >= 'A' && c <= 'Z') |
|
|
0 |
0 |
else if (c >= 'A' && c <= 'Z') |
|
800
|
0 |
0 |
else if (c >= 'a' && c <= 'z') |
|
|
0 |
0 |
else if (c >= 'a' && c <= 'z') |
|
803
|
0 |
0 |
if (!decoded_len) { |
|
812
|
0 |
0 |
if (!encoded_len || !ctx->parse_ctx.line_len || encoded_len > ctx->parse_ctx.line_len - 1) { |
|
|
0 |
0 |
if (!encoded_len || !ctx->parse_ctx.line_len || encoded_len > ctx->parse_ctx.line_len - 1) { |
|
|
0 |
0 |
if (!encoded_len || !ctx->parse_ctx.line_len || encoded_len > ctx->parse_ctx.line_len - 1) { |
|
817
|
0 |
0 |
if ((error = git_buf_decode_base85( |
|
821
|
0 |
0 |
if (decoded.size - decoded_orig != decoded_len) { |
|
828
|
0 |
0 |
if (git_parse_advance_nl(&ctx->parse_ctx) < 0) { |
|
856
|
0 |
0 |
if ((error = parse_patch_binary_side( |
|
860
|
0 |
0 |
if (git_parse_advance_nl(&ctx->parse_ctx) < 0) |
|
865
|
0 |
0 |
if ((error = parse_patch_binary_side( |
|
869
|
0 |
0 |
if (git_parse_advance_nl(&ctx->parse_ctx) < 0) |
|
882
|
0 |
0 |
const char *old = patch->old_path ? patch->old_path : patch->header_old_path; |
|
883
|
0 |
0 |
const char *new = patch->new_path ? patch->new_path : patch->header_new_path; |
|
885
|
0 |
0 |
if (!old || !new) |
|
|
0 |
0 |
if (!old || !new) |
|
888
|
0 |
0 |
if (patch->base.delta->status == GIT_DELTA_ADDED) |
|
890
|
0 |
0 |
else if (patch->base.delta->status == GIT_DELTA_DELETED) |
|
894
|
0 |
0 |
git_parse_advance_expected_str(&ctx->parse_ctx, old) < 0 || |
|
895
|
0 |
0 |
git_parse_advance_expected_str(&ctx->parse_ctx, " and ") < 0 || |
|
896
|
0 |
0 |
git_parse_advance_expected_str(&ctx->parse_ctx, new) < 0 || |
|
897
|
0 |
0 |
git_parse_advance_expected_str(&ctx->parse_ctx, " differ") < 0 || |
|
913
|
2 |
2 |
while (git_parse_ctx_contains_s(&ctx->parse_ctx, "@@ -")) { |
|
914
|
2 |
0 |
hunk = git_array_alloc(patch->base.hunks); |
|
|
0 |
0 |
hunk = git_array_alloc(patch->base.hunks); |
|
915
|
0 |
2 |
GIT_ERROR_CHECK_ALLOC(hunk); |
|
922
|
2 |
0 |
if ((error = parse_hunk_header(hunk, ctx)) < 0 || |
|
|
2 |
0 |
if ((error = parse_hunk_header(hunk, ctx)) < 0 || |
|
936
|
0 |
2 |
if (git_parse_ctx_contains_s(&ctx->parse_ctx, "GIT binary patch")) |
|
938
|
0 |
2 |
else if (git_parse_ctx_contains_s(&ctx->parse_ctx, "Binary files ")) |
|
950
|
4 |
0 |
if (!one || !two) |
|
|
0 |
4 |
if (!one || !two) |
|
953
|
1 |
3 |
if (two_null && strcmp(two, "/dev/null") != 0) |
|
|
0 |
1 |
if (two_null && strcmp(two, "/dev/null") != 0) |
|
956
|
3 |
1 |
else if (!two_null && strcmp(one, two) != 0) |
|
|
0 |
3 |
else if (!two_null && strcmp(one, two) != 0) |
|
975
|
0 |
4 |
if (prefix_len == 0) |
|
979
|
0 |
4 |
while (*path == '/') |
|
982
|
12 |
0 |
while (*path && remain_len) { |
|
|
8 |
4 |
while (*path && remain_len) { |
|
983
|
4 |
4 |
if (*path == '/') |
|
989
|
4 |
0 |
if (remain_len || !*path) |
|
|
0 |
4 |
if (remain_len || !*path) |
|
998
|
0 |
4 |
return (*out == NULL) ? -1 : 0; |
|
1008
|
2 |
0 |
if (patch->old_path && !patch->new_path) |
|
|
0 |
2 |
if (patch->old_path && !patch->new_path) |
|
1011
|
0 |
2 |
if (!patch->old_path && patch->new_path) |
|
|
0 |
0 |
if (!patch->old_path && patch->new_path) |
|
1019
|
1 |
1 |
prefixed_old = (!added && patch->old_path) ? patch->old_path : patch->header_old_path; |
|
|
1 |
0 |
prefixed_old = (!added && patch->old_path) ? patch->old_path : patch->header_old_path; |
|
1020
|
2 |
0 |
prefixed_new = (!deleted && patch->new_path) ? patch->new_path : patch->header_new_path; |
|
|
2 |
0 |
prefixed_new = (!deleted && patch->new_path) ? patch->new_path : patch->header_new_path; |
|
1022
|
2 |
0 |
if ((prefixed_old && check_prefix(&patch->old_prefix, &old_prefixlen, patch, prefixed_old) < 0) || |
|
|
2 |
0 |
if ((prefixed_old && check_prefix(&patch->old_prefix, &old_prefixlen, patch, prefixed_old) < 0) || |
|
|
2 |
0 |
if ((prefixed_old && check_prefix(&patch->old_prefix, &old_prefixlen, patch, prefixed_old) < 0) || |
|
1023
|
0 |
2 |
(prefixed_new && check_prefix(&patch->new_prefix, &new_prefixlen, patch, prefixed_new) < 0)) |
|
1027
|
0 |
2 |
if (patch->rename_old_path) |
|
1029
|
2 |
0 |
else if (prefixed_old) |
|
1034
|
0 |
2 |
if (patch->rename_new_path) |
|
1036
|
2 |
0 |
else if (prefixed_new) |
|
1041
|
0 |
2 |
if (!patch->base.delta->old_file.path && |
|
|
0 |
0 |
if (!patch->base.delta->old_file.path && |
|
1052
|
0 |
2 |
if (check_filenames(patch) < 0) |
|
1055
|
2 |
0 |
if (delta->old_file.path && |
|
|
2 |
0 |
if (delta->old_file.path && |
|
1056
|
0 |
2 |
delta->status != GIT_DELTA_DELETED && |
|
1060
|
1 |
1 |
if (delta->status == GIT_DELTA_MODIFIED && |
|
|
1 |
0 |
if (delta->status == GIT_DELTA_MODIFIED && |
|
1061
|
1 |
0 |
!(delta->flags & GIT_DIFF_FLAG_BINARY) && |
|
1062
|
0 |
1 |
delta->new_file.mode == delta->old_file.mode && |
|
1066
|
1 |
1 |
if (delta->status == GIT_DELTA_ADDED) { |
|
1071
|
0 |
2 |
if (delta->status == GIT_DELTA_DELETED) { |
|
1087
|
0 |
1 |
if ((ctx = git__calloc(1, sizeof(git_patch_parse_ctx))) == NULL) |
|
1090
|
0 |
1 |
if ((git_parse_ctx_init(&ctx->parse_ctx, content, content_len)) < 0) { |
|
1095
|
0 |
1 |
if (opts) |
|
1106
|
0 |
1 |
if (!ctx) |
|
1115
|
1 |
3 |
GIT_REFCOUNT_DEC(ctx, patch_parse_ctx_free); |
|
|
1 |
0 |
GIT_REFCOUNT_DEC(ctx, patch_parse_ctx_free); |
|
1123
|
0 |
2 |
if ((p = git_vector_get(&diff->patches, idx)) == NULL) |
|
1138
|
0 |
3 |
if (!patch) |
|
1146
|
3 |
3 |
git_array_foreach(patch->base.lines, i, line) |
|
|
3 |
0 |
git_array_foreach(patch->base.lines, i, line) |
|
1170
|
3 |
0 |
assert(out && ctx); |
|
|
0 |
3 |
assert(out && ctx); |
|
1175
|
0 |
3 |
GIT_ERROR_CHECK_ALLOC(patch); |
|
1183
|
0 |
3 |
GIT_ERROR_CHECK_ALLOC(patch->base.delta); |
|
1190
|
2 |
1 |
if ((error = parse_patch_header(patch, ctx)) < 0 || |
|
|
2 |
0 |
if ((error = parse_patch_header(patch, ctx)) < 0 || |
|
1191
|
2 |
0 |
(error = parse_patch_body(patch, ctx)) < 0 || |
|
1206
|
1 |
2 |
if (error < 0) |
|
1222
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(ctx); |