MCPcopy Create free account
hub / github.com/git/git / recount_edited_hunk

Function recount_edited_hunk

add-patch.c:1307–1343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1305}
1306
1307static ssize_t recount_edited_hunk(struct add_p_state *s, struct hunk *hunk,
1308 size_t orig_old_count, size_t orig_new_count)
1309{
1310 struct hunk_header *header = &hunk->header;
1311 size_t i;
1312 char ch, marker = ' ';
1313
1314 hunk->splittable_into = 0;
1315 header->old_count = header->new_count = 0;
1316 for (i = hunk->start; i < hunk->end; ) {
1317 ch = normalize_marker(&s->plain.buf[i]);
1318 switch (ch) {
1319 case '-':
1320 header->old_count++;
1321 if (marker == ' ')
1322 hunk->splittable_into++;
1323 marker = ch;
1324 break;
1325 case '+':
1326 header->new_count++;
1327 if (marker == ' ')
1328 hunk->splittable_into++;
1329 marker = ch;
1330 break;
1331 case ' ':
1332 header->old_count++;
1333 header->new_count++;
1334 marker = ch;
1335 break;
1336 }
1337
1338 i = find_next_line(&s->plain, i);
1339 }
1340
1341 return orig_old_count - orig_new_count
1342 - header->old_count + header->new_count;
1343}
1344
1345static int run_apply_check(struct add_p_state *s,
1346 struct file_diff *file_diff)

Callers 1

edit_hunk_loopFunction · 0.85

Calls 2

normalize_markerFunction · 0.85
find_next_lineFunction · 0.85

Tested by

no test coverage detected