|
7 | 7 | #include "color.h"
|
8 | 8 | #include "diff.h"
|
9 | 9 |
|
| 10 | +enum prompt_mode_type { |
| 11 | + PROMPT_MODE_CHANGE = 0, PROMPT_DELETION, PROMPT_HUNK |
| 12 | +}; |
| 13 | + |
| 14 | +static const char *prompt_mode[] = { |
| 15 | + N_("Stage mode change [y,n,a,d%s,?]? "), |
| 16 | + N_("Stage deletion [y,n,a,d%s,?]? "), |
| 17 | + N_("Stage this hunk [y,n,a,d%s,?]? ") |
| 18 | +}; |
| 19 | + |
10 | 20 | struct hunk_header {
|
11 | 21 | unsigned long old_offset, old_count, new_offset, new_count;
|
12 | 22 | /*
|
@@ -422,6 +432,7 @@ static int patch_update_file(struct add_p_state *s,
|
422 | 432 | char ch;
|
423 | 433 | struct child_process cp = CHILD_PROCESS_INIT;
|
424 | 434 | int colored = !!s->colored.len;
|
| 435 | + enum prompt_mode_type prompt_mode_type; |
425 | 436 |
|
426 | 437 | if (!file_diff->hunk_nr)
|
427 | 438 | return 0;
|
@@ -466,13 +477,20 @@ static int patch_update_file(struct add_p_state *s,
|
466 | 477 | strbuf_addstr(&s->buf, ",j");
|
467 | 478 | if (hunk_index + 1 < file_diff->hunk_nr)
|
468 | 479 | strbuf_addstr(&s->buf, ",J");
|
| 480 | + |
| 481 | + if (file_diff->deleted) |
| 482 | + prompt_mode_type = PROMPT_DELETION; |
| 483 | + else if (file_diff->mode_change && !hunk_index) |
| 484 | + prompt_mode_type = PROMPT_MODE_CHANGE; |
| 485 | + else |
| 486 | + prompt_mode_type = PROMPT_HUNK; |
| 487 | + |
469 | 488 | color_fprintf(stdout, s->s.prompt_color,
|
470 | 489 | "(%"PRIuMAX"/%"PRIuMAX") ",
|
471 | 490 | (uintmax_t)hunk_index + 1,
|
472 | 491 | (uintmax_t)file_diff->hunk_nr);
|
473 | 492 | color_fprintf(stdout, s->s.prompt_color,
|
474 |
| - _("Stage this hunk [y,n,a,d%s,?]? "), |
475 |
| - s->buf.buf); |
| 493 | + _(prompt_mode[prompt_mode_type]), s->buf.buf); |
476 | 494 | fflush(stdout);
|
477 | 495 | if (strbuf_getline(&s->answer, stdin) == EOF)
|
478 | 496 | break;
|
|
0 commit comments