Skip to content

Commit 3fb5aea

Browse files
chriscoolgitster
authored andcommitted
builtin/remote: remove postfixcmp() and use suffixcmp() instead
Commit 8cc5b29 (git merge -X<option>, 25 Nov 2009) introduced suffixcmp() with nearly the same implementation as postfixcmp() that already existed since commit 211c896 (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 <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a4552ce commit 3fb5aea

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

builtin/remote.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ static int verbose;
8080
static int show_all(void);
8181
static int prune_remote(const char *remote, int dry_run);
8282

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-
9183
static int fetch_remote(const char *name)
9284
{
9385
const char *argv[] = { "fetch", name, NULL, NULL };
@@ -277,13 +269,13 @@ static int config_read_branches(const char *key, const char *value, void *cb)
277269
enum { REMOTE, MERGE, REBASE } type;
278270

279271
key += 7;
280-
if (!postfixcmp(key, ".remote")) {
272+
if (!suffixcmp(key, ".remote")) {
281273
name = xstrndup(key, strlen(key) - 7);
282274
type = REMOTE;
283-
} else if (!postfixcmp(key, ".merge")) {
275+
} else if (!suffixcmp(key, ".merge")) {
284276
name = xstrndup(key, strlen(key) - 6);
285277
type = MERGE;
286-
} else if (!postfixcmp(key, ".rebase")) {
278+
} else if (!suffixcmp(key, ".rebase")) {
287279
name = xstrndup(key, strlen(key) - 7);
288280
type = REBASE;
289281
} else

0 commit comments

Comments
 (0)