From: Junio C Hamano Date: Wed, 17 Dec 2014 19:42:28 +0000 (-0800) Subject: Sync with v2.0.5 X-Git-Tag: v2.1.4~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58f1d950e373afe35ed8661045914d23e973d067;p=git Sync with v2.0.5 * maint-2.0: Git 2.0.5 Git 1.9.5 Git 1.8.5.6 fsck: complain about NTFS ".git" aliases in trees read-cache: optionally disallow NTFS .git variants path: add is_ntfs_dotgit() helper fsck: complain about HFS+ ".git" aliases in trees read-cache: optionally disallow HFS+ .git variants utf8: add is_hfs_dotgit() helper fsck: notice .git case-insensitively t1450: refactor ".", "..", and ".git" fsck tests verify_dotfile(): reject .git case-insensitively read-tree: add tests for confusing paths like ".." and ".git" unpack-trees: propagate errors adding entries to the index --- 58f1d950e373afe35ed8661045914d23e973d067 diff --cc Documentation/git.txt index 5627845114,674ecf9a3b..ffde2b80b9 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@@ -43,17 -43,10 +43,18 @@@ unreleased) version of Git, that is ava branch of the `git.git` repository. Documentation for older releases are available here: +* link:v2.1.3/git.html[documentation for release 2.1.3] + +* release notes for + link:RelNotes/2.1.3.txt[2.1.3], + link:RelNotes/2.1.2.txt[2.1.2], + link:RelNotes/2.1.1.txt[2.1.1], + link:RelNotes/2.1.0.txt[2.1]. + - * link:v2.0.4/git.html[documentation for release 2.0.4] + * link:v2.0.5/git.html[documentation for release 2.0.5] * release notes for + link:RelNotes/2.0.5.txt[2.0.5], link:RelNotes/2.0.4.txt[2.0.4], link:RelNotes/2.0.3.txt[2.0.3], link:RelNotes/2.0.2.txt[2.0.2], diff --cc cache.h index dcf3a2afe9,f23fdbee96..a258d805cd --- a/cache.h +++ b/cache.h @@@ -847,6 -812,8 +849,7 @@@ int normalize_path_copy(char *dst, cons int longest_ancestor_length(const char *path, struct string_list *prefixes); char *strip_path_suffix(const char *path, const char *suffix); int daemon_avoid_alias(const char *path); -int offset_1st_component(const char *path); + extern int is_ntfs_dotgit(const char *name); /* object replacement */ #define LOOKUP_REPLACE_OBJECT 1 diff --cc config.mak.uname index 15ee15e98c,aba56dcfad..0941e30a67 --- a/config.mak.uname +++ b/config.mak.uname @@@ -368,8 -362,9 +369,9 @@@ ifeq ($(uname_S),Windows EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj PTHREAD_LIBS = lib = + BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1 ifndef DEBUG - BASIC_CFLAGS += -GL -Os -MT + BASIC_CFLAGS += -GL -Os -MD BASIC_LDFLAGS += -LTCG AR += -LTCG else diff --cc path.c index 3afcdb432a,f10c91a927..757d0b057d --- a/path.c +++ b/path.c @@@ -821,3 -821,43 +821,36 @@@ int daemon_avoid_alias(const char *p } } } + -int offset_1st_component(const char *path) -{ - if (has_dos_drive_prefix(path)) - return 2 + is_dir_sep(path[2]); - return is_dir_sep(path[0]); -} - + static int only_spaces_and_periods(const char *path, size_t len, size_t skip) + { + if (len < skip) + return 0; + len -= skip; + path += skip; + while (len-- > 0) { + char c = *(path++); + if (c != ' ' && c != '.') + return 0; + } + return 1; + } + + int is_ntfs_dotgit(const char *name) + { + int len; + + for (len = 0; ; len++) + if (!name[len] || name[len] == '\\' || is_dir_sep(name[len])) { + if (only_spaces_and_periods(name, len, 4) && + !strncasecmp(name, ".git", 4)) + return 1; + if (only_spaces_and_periods(name, len, 5) && + !strncasecmp(name, "git~1", 5)) + return 1; + if (name[len] != '\\') + return 0; + name += len + 1; + len = -1; + } + } diff --cc read-cache.c index 6f0057fe66,36a6f73fed..f042693856 --- a/read-cache.c +++ b/read-cache.c @@@ -14,8 -14,7 +14,9 @@@ #include "resolve-undo.h" #include "strbuf.h" #include "varint.h" +#include "split-index.h" +#include "sigchain.h" + #include "utf8.h" static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, unsigned int options); diff --cc t/t1450-fsck.sh index b52397afd3,983568a4b9..426f753fe3 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@@ -271,91 -251,40 +271,96 @@@ test_expect_success 'fsck notices submo ) ' - test_expect_success 'fsck notices "." and ".." in trees' ' - ( - git init dots && - cd dots && - blob=$(echo foo | git hash-object -w --stdin) && - tab=$(printf "\\t") && - git mktree <<-EOF && - 100644 blob $blob$tab. - 100644 blob $blob$tab.. - EOF - git fsck 2>out && - cat out && - grep "warning.*\\." out - ) - ' - - test_expect_success 'fsck notices ".git" in trees' ' - ( - git init dotgit && - cd dotgit && - blob=$(echo foo | git hash-object -w --stdin) && - tab=$(printf "\\t") && - git mktree <<-EOF && - 100644 blob $blob$tab.git - EOF - git fsck 2>out && - cat out && - grep "warning.*\\.git" out - ) - ' + while read name path pretty; do + while read mode type; do + : ${pretty:=$path} + test_expect_success "fsck notices $pretty as $type" ' + ( + git init $name-$type && + cd $name-$type && + echo content >file && + git add file && + git commit -m base && + blob=$(git rev-parse :file) && + tree=$(git rev-parse HEAD^{tree}) && + value=$(eval "echo \$$type") && + printf "$mode $type %s\t%s" "$value" "$path" >bad && + bad_tree=$(git mktree out && + cat out && + grep "warning.*tree $bad_tree" out + )' + done <<-\EOF + 100644 blob + 040000 tree + EOF + done <<-EOF + dot . + dotdot .. + dotgit .git + dotgit-case .GIT + dotgit-unicode .gI${u200c}T .gI{u200c}T + dotgit-case2 .Git + git-tilde1 git~1 + dotgitdot .git. + dot-backslash-case .\\\\.GIT\\\\foobar + dotgit-case-backslash .git\\\\foobar + EOF +# 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). +create_repo_missing () { + rm -rf missing && + git init missing && + ( + cd missing && + git commit -m one --allow-empty && + mkdir subdir && + echo content >subdir/file && + git add subdir/file && + git commit -m two && + unrelated=$(echo unrelated | git hash-object --stdin -w) && + git tag -m foo tag $unrelated && + sha1=$(git rev-parse --verify "$1") && + path=$(echo $sha1 | sed 's|..|&/|') && + rm .git/objects/$path + ) +} + +test_expect_success 'fsck notices missing blob' ' + create_repo_missing HEAD:subdir/file && + test_must_fail git -C missing fsck +' + +test_expect_success 'fsck notices missing subtree' ' + create_repo_missing HEAD:subdir && + test_must_fail git -C missing fsck +' + +test_expect_success 'fsck notices missing root tree' ' + create_repo_missing HEAD^{tree} && + test_must_fail git -C missing fsck +' + +test_expect_success 'fsck notices missing parent' ' + create_repo_missing HEAD^ && + test_must_fail git -C missing fsck +' + +test_expect_success 'fsck notices missing tagged object' ' + create_repo_missing tag^{blob} && + test_must_fail git -C missing fsck +' + +test_expect_success 'fsck notices ref pointing to missing commit' ' + create_repo_missing HEAD && + test_must_fail git -C missing fsck +' + +test_expect_success 'fsck notices ref pointing to missing tag' ' + create_repo_missing tag && + test_must_fail git -C missing fsck +' + test_done