| 759 | } |
| 760 | |
| 761 | static int find_and_replace(struct strbuf *haystack, |
| 762 | const char *needle, |
| 763 | const char *placeholder) |
| 764 | { |
| 765 | const char *p = NULL; |
| 766 | int plen, nlen; |
| 767 | |
| 768 | nlen = strlen(needle); |
| 769 | if (ends_with(haystack->buf, needle)) |
| 770 | p = haystack->buf + haystack->len - nlen; |
| 771 | else |
| 772 | p = strstr(haystack->buf, needle); |
| 773 | if (!p) |
| 774 | return 0; |
| 775 | |
| 776 | if (p > haystack->buf && p[-1] != '/') |
| 777 | return 0; |
| 778 | |
| 779 | plen = strlen(p); |
| 780 | if (plen > nlen && p[nlen] != '/') |
| 781 | return 0; |
| 782 | |
| 783 | strbuf_splice(haystack, p - haystack->buf, nlen, |
| 784 | placeholder, strlen(placeholder)); |
| 785 | return 1; |
| 786 | } |
| 787 | |
| 788 | static void print_compact(struct display_state *display_state, |
| 789 | const char *remote, const char *local) |
no test coverage detected