builtin/remote: remove postfixcmp() and use suffixcmp() instead
authorChristian Couder <chriscool@tuxfamily.org>
Sun, 1 Dec 2013 07:49:15 +0000 (08:49 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Dec 2013 22:12:52 +0000 (14:12 -0800)
Commit 8cc5b290 (git merge -X<option>, 25 Nov 2009) introduced
suffixcmp() with nearly the same implementation as postfixcmp()
that already existed since commit 211c8968 (Make git-remote a
builtin, 29 Feb 2008).

The only difference between the two implementations is that,
when the string is smaller than the suffix, one implementation
returns 1 while the other one returns -1.

But, as postfixcmp() is only used to compare for equality, the
distinction does not matter and does not affect the correctness of
this patch.

As postfixcmp() has always been static in builtin/remote.c
and is used nowhere else, it makes more sense to remove it
and use suffixcmp() instead in builtin/remote.c, rather than
to remove suffixcmp().

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/remote.c
index 4e14891095e6ea016b9f44262ae300c42a75e1b2..9b3a98e415fc2170d2d528171f1beb2196850de0 100644 (file)
@@ -80,14 +80,6 @@ static int verbose;
 static int show_all(void);
 static int prune_remote(const char *remote, int dry_run);
 
-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 };
@@ -277,13 +269,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 (!suffixcmp(key, ".remote")) {
                        name = xstrndup(key, strlen(key) - 7);
                        type = REMOTE;
-               } else if (!postfixcmp(key, ".merge")) {
+               } else if (!suffixcmp(key, ".merge")) {
                        name = xstrndup(key, strlen(key) - 6);
                        type = MERGE;
-               } else if (!postfixcmp(key, ".rebase")) {
+               } else if (!suffixcmp(key, ".rebase")) {
                        name = xstrndup(key, strlen(key) - 7);
                        type = REBASE;
                } else