Merge branch 'nd/clone-case-smashing-warning'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 11:39:02 +0000 (20:39 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 11:39:03 +0000 (20:39 +0900)
Recently added check for case smashing filesystems did not
correctly utilize the cached stat information, leading to false
breakage detected by our test suite, which has been corrected.

* nd/clone-case-smashing-warning:
clone: fix colliding file detection on APFS

1  2 
entry.c
t/t5601-clone.sh
diff --combined entry.c
index 5d136c5d55e0811b70fdb10f59ea506ceb1b273b,d3fb6ee0e31e8595ad1d0ac3f3a2297c46041d89..0a3c451f5f0f08deabe20b4ca1858825f2b29f3f
+++ b/entry.c
@@@ -266,7 -266,7 +266,7 @@@ static int write_entry(struct cache_ent
        const struct submodule *sub;
  
        if (ce_mode_s_ifmt == S_IFREG) {
 -              struct stream_filter *filter = get_stream_filter(ce->name,
 +              struct stream_filter *filter = get_stream_filter(state->istate, ce->name,
                                                                 &ce->oid);
                if (filter &&
                    !streaming_write_entry(ce, path, filter,
                 * Convert from git internal format to working tree format
                 */
                if (dco && dco->state != CE_NO_DELAY) {
 -                      ret = async_convert_to_working_tree(ce->name, new_blob,
 +                      ret = async_convert_to_working_tree(state->istate, ce->name, new_blob,
                                                            size, &buf, dco);
                        if (ret && string_list_has_string(&dco->paths, ce->name)) {
                                free(new_blob);
                                goto delayed;
                        }
                } else
 -                      ret = convert_to_working_tree(ce->name, new_blob, size, &buf);
 +                      ret = convert_to_working_tree(state->istate, ce->name, new_blob, size, &buf);
  
                if (ret) {
                        free(new_blob);
@@@ -404,7 -404,7 +404,7 @@@ static void mark_colliding_entries(cons
  {
        int i, trust_ino = check_stat;
  
- #if defined(GIT_WINDOWS_NATIVE)
+ #if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)
        trust_ino = 0;
  #endif
  
                if (dup->ce_flags & (CE_MATCHED | CE_VALID | CE_SKIP_WORKTREE))
                        continue;
  
-               if ((trust_ino && dup->ce_stat_data.sd_ino == st->st_ino) ||
+               if ((trust_ino && !match_stat_data(&dup->ce_stat_data, st)) ||
                    (!trust_ino && !fspathcmp(ce->name, dup->name))) {
                        dup->ce_flags |= CE_MATCHED;
                        break;
@@@ -450,8 -450,7 +450,8 @@@ int checkout_entry(struct cache_entry *
  
        if (!check_path(path.buf, path.len, &st, state->base_dir_len)) {
                const struct submodule *sub;
 -              unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE);
 +              unsigned changed = ie_match_stat(state->istate, ce, &st,
 +                                               CE_MATCH_IGNORE_VALID | CE_MATCH_IGNORE_SKIP_WORKTREE);
                /*
                 * Needs to be checked before !changed returns early,
                 * as the possibly empty directory was not changed
diff --combined t/t5601-clone.sh
index f1a49e94f5fe56a0c175b0e5354ce1d5300cb382,3888c9751f8b8f35a2c85df8be8328c5a57bdbad..c28d51bd59259a3cf2ceb7b3b14e5171901145b2
@@@ -618,7 -618,7 +618,7 @@@ hex2oct () 
  test_expect_success 'clone on case-insensitive fs' '
        git init icasefs &&
        (
 -              cd icasefs
 +              cd icasefs &&
                o=$(git hash-object -w --stdin </dev/null | hex2oct) &&
                t=$(printf "100644 X\0${o}100644 x\0${o}" |
                        git hash-object -w -t tree --stdin) &&
        )
  '
  
- test_expect_success !MINGW,!CYGWIN,CASE_INSENSITIVE_FS 'colliding file detection' '
+ test_expect_success !MINGW,CASE_INSENSITIVE_FS 'colliding file detection' '
        grep X icasefs/warning &&
        grep x icasefs/warning &&
        test_i18ngrep "the following paths have collided" icasefs/warning