diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-12-18 10:40:12 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-18 10:40:12 -0800 |
commit | ef872ecb7b358af7de3611045ecd5625ce3678cd (patch) | |
tree | 7206afaa29cead8bebd259d66b842c41234d3a33 | |
parent | 2b1fbfbd87731652a29ea4d096ef2e04783667a7 (diff) | |
download | git-nd/more-skip-prefix.tar.gz |
SQUASH???nd/more-skip-prefix
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | git-compat-util.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index b72a80d8ae..59265affd8 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -356,8 +356,11 @@ extern int suffixcmp(const char *str, const char *suffix); static inline const char *skip_prefix_defval(const char *str, const char *prefix, const char *defval) { - size_t len = strlen(prefix); - return strncmp(str, prefix, len) ? defval : str + len; + for ( ; ; str++, prefix++) + if (!*prefix) + return str; + else if (*str != *prefix) + return defval; } static inline const char *skip_prefix(const char *str, const char *prefix) |