]> git.ipfire.org Git - thirdparty/git.git/commitdiff
convert: fix handling of dashless UTF prefix in validate_encoding()
authorRené Scharfe <l.s.r@web.de>
Fri, 4 Oct 2019 19:25:50 +0000 (21:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 6 Oct 2019 00:43:01 +0000 (09:43 +0900)
Strip "UTF" and an optional dash from the start of 'upper' without
passing a NULL pointer to skip_prefix() in the second call, as it cannot
handle that.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
convert.c

index 5d0307fc1004f215c48a6f653e21da41bee71baa..8646ee46a3574eca12d624984f65deea15e2a76d 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -289,8 +289,8 @@ static int validate_encoding(const char *path, const char *enc,
                        const char *stripped = NULL;
                        char *upper = xstrdup_toupper(enc);
                        upper[strlen(upper)-2] = '\0';
-                       if (!skip_prefix(upper, "UTF-", &stripped))
-                               skip_prefix(stripped, "UTF", &stripped);
+                       if (skip_prefix(upper, "UTF", &stripped))
+                               skip_prefix(stripped, "-", &stripped);
                        advise(advise_msg, path, stripped);
                        free(upper);
                        if (die_on_error)
@@ -309,8 +309,8 @@ static int validate_encoding(const char *path, const char *enc,
                                "working-tree-encoding.");
                        const char *stripped = NULL;
                        char *upper = xstrdup_toupper(enc);
-                       if (!skip_prefix(upper, "UTF-", &stripped))
-                               skip_prefix(stripped, "UTF", &stripped);
+                       if (skip_prefix(upper, "UTF", &stripped))
+                               skip_prefix(stripped, "-", &stripped);
                        advise(advise_msg, path, stripped, stripped);
                        free(upper);
                        if (die_on_error)