builtin/remote: remove postfixcmp() and use suffixcmp() instead

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>

Christian Couder committed Dec 1, 2013 at 08:49 UTC 3fb5aead2971c6181dbf143295c427175b8bf082
1 file changed +3 -11
builtin/remote.c
+3 -11
@@ -80,14 +80,6 @@ static int verbose;
80 static int show_all(void);
81 static int prune_remote(const char *remote, int dry_run);
82
83 -static inline int postfixcmp(const char *string, const char *postfix)
84 -{
85 - int len1 = strlen(string), len2 = strlen(postfix);
86 - if (len1 < len2)
87 - return 1;
88 - return strcmp(string + len1 - len2, postfix);
89 -}
90 -
83 static int fetch_remote(const char *name)
84 {
85 const char *argv[] = { "fetch", name, NULL, NULL };
@@ -277,13 +269,13 @@ static int config_read_branches(const char *key, const char *value, void *cb)
269 enum { REMOTE, MERGE, REBASE } type;
270
271 key += 7;
280 - if (!postfixcmp(key, ".remote")) {
272 + if (!suffixcmp(key, ".remote")) {
273 name = xstrndup(key, strlen(key) - 7);
274 type = REMOTE;
283 - } else if (!postfixcmp(key, ".merge")) {
275 + } else if (!suffixcmp(key, ".merge")) {
276 name = xstrndup(key, strlen(key) - 6);
277 type = MERGE;
286 - } else if (!postfixcmp(key, ".rebase")) {
278 + } else if (!suffixcmp(key, ".rebase")) {
279 name = xstrndup(key, strlen(key) - 7);
280 type = REBASE;
281 } else