MCPcopy Create free account
hub / github.com/git/git / find_and_replace

Function find_and_replace

builtin/fetch.c:761–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761static 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
788static void print_compact(struct display_state *display_state,
789 const char *remote, const char *local)

Callers 1

print_compactFunction · 0.85

Calls 2

ends_withFunction · 0.85
strbuf_spliceFunction · 0.85

Tested by

no test coverage detected