|
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 | /*
|
@@ -389,6 +399,7 @@ static int patch_update_file(struct add_p_state *s,
|
389 | 399 | char ch;
|
390 | 400 | struct child_process cp = CHILD_PROCESS_INIT;
|
391 | 401 | int colored = !!s->colored.len;
|
| 402 | + enum prompt_mode_type prompt_mode_type; |
392 | 403 |
|
393 | 404 | if (!file_diff->hunk_nr)
|
394 | 405 | return 0;
|
@@ -433,9 +444,16 @@ static int patch_update_file(struct add_p_state *s,
|
433 | 444 | strbuf_addstr(&s->buf, ",j");
|
434 | 445 | if (hunk_index + 1 < file_diff->hunk_nr)
|
435 | 446 | strbuf_addstr(&s->buf, ",J");
|
| 447 | + |
| 448 | + if (file_diff->deleted) |
| 449 | + prompt_mode_type = PROMPT_DELETION; |
| 450 | + else if (file_diff->mode_change && !hunk_index) |
| 451 | + prompt_mode_type = PROMPT_MODE_CHANGE; |
| 452 | + else |
| 453 | + prompt_mode_type = PROMPT_HUNK; |
| 454 | + |
436 | 455 | color_fprintf(stdout, s->s.prompt_color,
|
437 |
| - _("Stage this hunk [y,n,a,d%s,?]? "), |
438 |
| - s->buf.buf); |
| 456 | + _(prompt_mode[prompt_mode_type]), s->buf.buf); |
439 | 457 | fflush(stdout);
|
440 | 458 | if (strbuf_getline(&s->answer, stdin) == EOF)
|
441 | 459 | break;
|
|
0 commit comments