MCPcopy Index your code
hub / github.com/git/git / edit_hunk_loop

Function edit_hunk_loop

add-patch.c:1390–1433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1388}
1389
1390static int edit_hunk_loop(struct add_p_state *s,
1391 struct file_diff *file_diff, struct hunk *hunk)
1392{
1393 size_t plain_len = s->plain.len, colored_len = s->colored.len;
1394 struct hunk backup;
1395
1396 backup = *hunk;
1397
1398 for (;;) {
1399 int res = edit_hunk_manually(s, hunk);
1400 if (res == 0) {
1401 /* abandoned */
1402 *hunk = backup;
1403 return -1;
1404 }
1405
1406 if (res > 0) {
1407 hunk->delta +=
1408 recount_edited_hunk(s, hunk,
1409 backup.header.old_count,
1410 backup.header.new_count);
1411 if (!run_apply_check(s, file_diff))
1412 return 0;
1413 }
1414
1415 /* Drop edits (they were appended to s->plain) */
1416 strbuf_setlen(&s->plain, plain_len);
1417 strbuf_setlen(&s->colored, colored_len);
1418 *hunk = backup;
1419
1420 /*
1421 * TRANSLATORS: do not translate [y/n]
1422 * The program will only accept that input at this point.
1423 * Consider translating (saying "no" discards!) as
1424 * (saying "n" for "no" discards!) if the translation
1425 * of the word "no" does not start with n.
1426 */
1427 res = prompt_yesno(s, _("Your edited hunk does not apply. "
1428 "Edit again (saying \"no\" discards!) "
1429 "[y/n]? "));
1430 if (res < 1)
1431 return -1;
1432 }
1433}
1434
1435static int apply_for_checkout(struct add_p_state *s, struct strbuf *diff,
1436 int is_reverse)

Callers 1

patch_update_fileFunction · 0.85

Calls 5

edit_hunk_manuallyFunction · 0.85
recount_edited_hunkFunction · 0.85
run_apply_checkFunction · 0.85
strbuf_setlenFunction · 0.85
prompt_yesnoFunction · 0.85

Tested by

no test coverage detected