From: Junio C Hamano Date: Wed, 7 Jan 2015 21:28:10 +0000 (-0800) Subject: Merge branch 'maint-2.1' into maint X-Git-Tag: v2.2.2~7 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7ba46269a04de20032bd2dd614be6290cd65caab?ds=inline;hp=-c Merge branch 'maint-2.1' into maint * maint-2.1: is_hfs_dotgit: loosen over-eager match of \u{..47} --- 7ba46269a04de20032bd2dd614be6290cd65caab diff --combined t/t1450-fsck.sh index d00b70f99d,6475f10bc5..793aee9f0b --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@@ -214,44 -214,6 +214,44 @@@ test_expect_success 'tag pointing to so test_must_fail git fsck --tags ' +test_expect_success 'tag with incorrect tag name & missing tagger' ' + sha=$(git rev-parse HEAD) && + cat >wrong-tag <<-EOF && + object $sha + type commit + tag wrong name format + + This is an invalid tag. + EOF + + tag=$(git hash-object -t tag -w --stdin .git/refs/tags/wrong && + test_when_finished "git update-ref -d refs/tags/wrong" && + git fsck --tags 2>out && + grep "invalid .tag. name" out && + grep "expected .tagger. line" out +' + +test_expect_success 'tag with bad tagger' ' + sha=$(git rev-parse HEAD) && + cat >wrong-tag <<-EOF && + object $sha + type commit + tag not-quite-wrong + tagger Bad Tagger Name + + This is an invalid tag. + EOF + + tag=$(git hash-object --literally -t tag -w --stdin .git/refs/tags/wrong && + test_when_finished "git update-ref -d refs/tags/wrong" && + test_must_fail git fsck --tags 2>out && + grep "error in tag .*: invalid author/committer" out +' + test_expect_success 'cleaned up' ' git fsck >actual 2>&1 && test_cmp empty actual @@@ -345,6 -307,21 +345,21 @@@ dot-backslash-case .\\\\.GIT\\\\fooba dotgit-case-backslash .git\\\\foobar EOF + test_expect_success 'fsck allows .Ňit' ' + ( + git init not-dotgit && + cd not-dotgit && + echo content >file && + git add file && + git commit -m base && + blob=$(git rev-parse :file) && + printf "100644 blob $blob\t.\\305\\207it" >tree && + tree=$(git mktree err && + test_line_count = 0 err + ) + ' + # create a static test repo which is broken by omitting # one particular object ($1, which is looked up via rev-parse # in the new repository). diff --combined utf8.c index 9a3f4ad232,7d2d6a0117..520fbb4994 --- a/utf8.c +++ b/utf8.c @@@ -239,6 -239,13 +239,6 @@@ int is_utf8(const char *text return 1; } -static void strbuf_addchars(struct strbuf *sb, int c, size_t n) -{ - strbuf_grow(sb, n); - memset(sb->buf + sb->len, c, n); - strbuf_setlen(sb, sb->len + n); -} - static void strbuf_add_indented_text(struct strbuf *buf, const char *text, int indent, int indent2) { @@@ -375,9 -382,6 +375,9 @@@ void strbuf_utf8_replace(struct strbuf dst += n; } + if (src >= end) + break; + old = src; n = utf8_width((const char**)&src, NULL); if (!src) /* broken utf-8, do nothing */ @@@ -563,8 -567,8 +563,8 @@@ int mbs_chrlen(const char **text, size_ } /* - * Pick the next char from the stream, folding as an HFS+ filename comparison - * would. Note that this is _not_ complete by any means. It's just enough + * Pick the next char from the stream, ignoring codepoints an HFS+ would. + * Note that this is _not_ complete by any means. It's just enough * to make is_hfs_dotgit() work, and should not be used otherwise. */ static ucs_char_t next_hfs_char(const char **in) @@@ -601,12 -605,7 +601,7 @@@ continue; } - /* - * there's a great deal of other case-folding that occurs, - * but this is enough to catch anything that will convert - * to ".git" - */ - return tolower(out); + return out; } } @@@ -614,10 -613,23 +609,23 @@@ int is_hfs_dotgit(const char *path { ucs_char_t c; - if (next_hfs_char(&path) != '.' || - next_hfs_char(&path) != 'g' || - next_hfs_char(&path) != 'i' || - next_hfs_char(&path) != 't') + c = next_hfs_char(&path); + if (c != '.') + return 0; + c = next_hfs_char(&path); + + /* + * there's a great deal of other case-folding that occurs + * in HFS+, but this is enough to catch anything that will + * convert to ".git" + */ + if (c != 'g' && c != 'G') + return 0; + c = next_hfs_char(&path); + if (c != 'i' && c != 'I') + return 0; + c = next_hfs_char(&path); + if (c != 't' && c != 'T') return 0; c = next_hfs_char(&path); if (c && !is_dir_sep(c))