* Given the string after "--- " or "+++ ", guess the appropriate * p_value for the given patch. */
| 745 | * p_value for the given patch. |
| 746 | */ |
| 747 | static int guess_p_value(struct apply_state *state, const char *nameline) |
| 748 | { |
| 749 | char *name, *cp; |
| 750 | int val = -1; |
| 751 | |
| 752 | if (is_dev_null(nameline)) |
| 753 | return -1; |
| 754 | name = find_name_traditional(&state->root, nameline, NULL, 0); |
| 755 | if (!name) |
| 756 | return -1; |
| 757 | cp = strchr(name, '/'); |
| 758 | if (!cp) |
| 759 | val = 0; |
| 760 | else if (state->prefix) { |
| 761 | /* |
| 762 | * Does it begin with "a/$our-prefix" and such? Then this is |
| 763 | * very likely to apply to our directory. |
| 764 | */ |
| 765 | if (starts_with(name, state->prefix)) |
| 766 | val = count_slashes(state->prefix); |
| 767 | else { |
| 768 | cp++; |
| 769 | if (starts_with(cp, state->prefix)) |
| 770 | val = count_slashes(state->prefix) + 1; |
| 771 | } |
| 772 | } |
| 773 | free(name); |
| 774 | return val; |
| 775 | } |
| 776 | |
| 777 | /* |
| 778 | * Does the ---/+++ line have the POSIX timestamp after the last HT? |
no test coverage detected