Merge branch 'br/commit-tree-fully-spelled-gpg-sign-option'
[gitweb.git] / builtin / fetch.c
index 61a443031d9ace9f2019e1c02ff265e7da0ec960..39c42106109f35f49550133580bf34b6eb60aa26 100644 (file)
@@ -629,9 +629,14 @@ static int find_and_replace(struct strbuf *haystack,
                            const char *needle,
                            const char *placeholder)
 {
-       const char *p = strstr(haystack->buf, needle);
+       const char *p = NULL;
        int plen, nlen;
 
+       nlen = strlen(needle);
+       if (ends_with(haystack->buf, needle))
+               p = haystack->buf + haystack->len - nlen;
+       else
+               p = strstr(haystack->buf, needle);
        if (!p)
                return 0;
 
@@ -639,7 +644,6 @@ static int find_and_replace(struct strbuf *haystack,
                return 0;
 
        plen = strlen(p);
-       nlen = strlen(needle);
        if (plen > nlen && p[nlen] != '/')
                return 0;