gc: config option for running --auto in background
[gitweb.git] / builtin / remote.c
index 119e9151ad7fb2a9bcc52d5673a7d51c8d24aacf..b3ab4cf8f6517c715845db7e17c67cad5f50d730 100644 (file)
@@ -78,14 +78,6 @@ static const char * const builtin_remote_seturl_usage[] = {
 
 static int verbose;
 
-static inline int postfixcmp(const char *string, const char *postfix)
-{
-       int len1 = strlen(string), len2 = strlen(postfix);
-       if (len1 < len2)
-               return 1;
-       return strcmp(string + len1 - len2, postfix);
-}
-
 static int fetch_remote(const char *name)
 {
        const char *argv[] = { "fetch", name, NULL, NULL };
@@ -267,7 +259,7 @@ static const char *abbrev_ref(const char *name, const char *prefix)
 
 static int config_read_branches(const char *key, const char *value, void *cb)
 {
-       if (!prefixcmp(key, "branch.")) {
+       if (starts_with(key, "branch.")) {
                const char *orig_key = key;
                char *name;
                struct string_list_item *item;
@@ -275,13 +267,13 @@ static int config_read_branches(const char *key, const char *value, void *cb)
                enum { REMOTE, MERGE, REBASE } type;
 
                key += 7;
-               if (!postfixcmp(key, ".remote")) {
+               if (ends_with(key, ".remote")) {
                        name = xstrndup(key, strlen(key) - 7);
                        type = REMOTE;
-               } else if (!postfixcmp(key, ".merge")) {
+               } else if (ends_with(key, ".merge")) {
                        name = xstrndup(key, strlen(key) - 6);
                        type = MERGE;
-               } else if (!postfixcmp(key, ".rebase")) {
+               } else if (ends_with(key, ".rebase")) {
                        name = xstrndup(key, strlen(key) - 7);
                        type = REBASE;
                } else
@@ -537,9 +529,9 @@ static int add_branch_for_removal(const char *refname,
        }
 
        /* don't delete non-remote-tracking refs */
-       if (prefixcmp(refname, "refs/remotes/")) {
+       if (!starts_with(refname, "refs/remotes/")) {
                /* advise user how to delete local branches */
-               if (!prefixcmp(refname, "refs/heads/"))
+               if (starts_with(refname, "refs/heads/"))
                        string_list_append(branches->skipped,
                                           abbrev_branch(refname));
                /* silently skip over other non-remote refs */
@@ -574,7 +566,7 @@ static int read_remote_branches(const char *refname,
        const char *symref;
 
        strbuf_addf(&buf, "refs/remotes/%s/", rename->old);
-       if (!prefixcmp(refname, buf.buf)) {
+       if (starts_with(refname, buf.buf)) {
                item = string_list_append(rename->remote_branches, xstrdup(refname));
                symref = resolve_ref_unsafe(refname, orig_sha1, 1, &flag);
                if (flag & REF_ISSYMREF)