1418
"e - manually edit the current hunk\n"
1419
"p - print the current hunk\n"
1420
"P - print the current hunk using the pager\n"
1421
- "? - print help\n");
1421
+ "> - go to the next file, roll over at the bottom\n"
1422
+ "< - go to the previous file, roll over at the top\n"
1423
+ "? - print help\n"
1424
+ "HUNKS SUMMARY - Hunks: %d, USE: %d, SKIP: %d\n");
1425
1426
static void apply_patch(struct add_p_state *s, struct file_diff *file_diff)
1427
{
1486
char ch;
1487
int colored = !!s->colored.len, use_pager = 0;
1488
enum prompt_mode_type prompt_mode_type;
1489
+ int all_decided = 0;
1490
struct file_diff *file_diff = s->file_diff + idx;
1491
size_t patch_update_resp = idx;
1492
1505
ALLOW_GOTO_NEXT_UNDECIDED_HUNK = 1 << 3,
1506
ALLOW_SEARCH_AND_GOTO = 1 << 4,
1507
ALLOW_SPLIT = 1 << 5,
1504
- ALLOW_EDIT = 1 << 6
1508
+ ALLOW_EDIT = 1 << 6,
1509
+ ALLOW_GOTO_PREVIOUS_FILE = 1 << 7,
1510
+ ALLOW_GOTO_NEXT_FILE = 1 << 8
1511
} permitted = 0;
1512
1513
if (hunk_index >= file_diff->hunk_nr)
1539
/* Everything decided? */
1540
if (undecided_previous < 0 && undecided_next < 0 &&
1541
hunk->use != UNDECIDED_HUNK) {
1536
- patch_update_resp++;
1537
- break;
1542
+ if (!s->s.auto_advance)
1543
+ all_decided = 1;
1544
+ else {
1545
+ patch_update_resp++;
1546
+ break;
1547
+ }
1548
}
1549
strbuf_reset(&s->buf);
1550
if (file_diff->hunk_nr) {
1593
permitted |= ALLOW_EDIT;
1594
strbuf_addstr(&s->buf, ",e");
1595
}
1596
+ if (!s->s.auto_advance && s->file_diff_nr > 1) {
1597
+ permitted |= ALLOW_GOTO_NEXT_FILE;
1598
+ strbuf_addstr(&s->buf, ",>");
1599
+ }
1600
+ if (!s->s.auto_advance && s->file_diff_nr > 1) {
1601
+ permitted |= ALLOW_GOTO_PREVIOUS_FILE;
1602
+ strbuf_addstr(&s->buf, ",<");
1603
+ }
1604
strbuf_addstr(&s->buf, ",p,P");
1605
}
1606
if (file_diff->deleted)
1671
} else if (ch == 'q') {
1672
patch_update_resp = s->file_diff_nr;
1673
break;
1674
+ } else if (!s->s.auto_advance && s->answer.buf[0] == '>') {
1675
+ if (permitted & ALLOW_GOTO_NEXT_FILE) {
1676
+ if (patch_update_resp == s->file_diff_nr - 1)
1677
+ patch_update_resp = 0;
1678
+ else
1679
+ patch_update_resp++;
1680
+ break;
1681
+ } else {
1682
+ err(s, _("No next file"));
1683
+ continue;
1684
+ }
1685
+ } else if (!s->s.auto_advance && s->answer.buf[0] == '<') {
1686
+ if (permitted & ALLOW_GOTO_PREVIOUS_FILE) {
1687
+ if (patch_update_resp == 0)
1688
+ patch_update_resp = s->file_diff_nr - 1;
1689
+ else
1690
+ patch_update_resp--;
1691
+ break;
1692
+ } else {
1693
+ err(s, _("No previous file"));
1694
+ continue;
1695
+ }
1696
} else if (s->answer.buf[0] == 'K') {
1697
if (permitted & ALLOW_GOTO_PREVIOUS_HUNK)
1698
hunk_index = dec_mod(hunk_index,
1838
* commands shown in the prompt that are not
1839
* always available.
1840
*/
1841
+ if (all_decided && !strncmp(p, "HUNKS SUMMARY", 13)) {
1842
+ int total = file_diff->hunk_nr, used = 0, skipped = 0;
1843
+
1844
+ for (i = 0; i < file_diff->hunk_nr; i++) {
1845
+ if (file_diff->hunk[i].use == USE_HUNK)
1846
+ used += 1;
1847
+ if (file_diff->hunk[i].use == SKIP_HUNK)
1848
+ skipped += 1;
1849
+ }
1850
+ color_fprintf_ln(stdout, s->s.help_color, _(p),
1851
+ total, used, skipped);
1852
+ }
1853
if (*p != '?' && !strchr(s->buf.buf, *p))
1854
continue;
1855
1862
}
1863
}
1864
1813
- apply_patch(s, file_diff);
1865
+ if (s->s.auto_advance)
1866
+ apply_patch(s, file_diff);
1867
1868
putchar('\n');
1869
return patch_update_resp;
1924
if ((i = patch_update_file(&s, i)) == s.file_diff_nr)
1925
break;
1926
}
1927
+ if (!s.s.auto_advance)
1928
+ for (i = 0; i < s.file_diff_nr; i++)
1929
+ apply_patch(&s, s.file_diff + i);
1930
1931
if (s.file_diff_nr == 0)
1932
err(&s, _("No changes."));