Merge branch 'bp/name-hash-dirname-fix'

"git add" files in the same directory, but spelling the directory
path in different cases on case insensitive filesystem, corrupted
the name hash data structure and led to unexpected results.  This
has been corrected.

* bp/name-hash-dirname-fix:
  name-hash: properly fold directory names in adjust_dirname_case()
This commit is contained in:
Junio C Hamano 2018-02-27 10:33:53 -08:00
Родитель ee9db32d42 c95525e90d
Коммит 2ac76d8d9d
2 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@ -699,12 +699,12 @@ void adjust_dirname_case(struct index_state *istate, char *name)
if (*ptr == '/') {
struct dir_entry *dir;
ptr++;
dir = find_dir_entry(istate, name, ptr - name + 1);
dir = find_dir_entry(istate, name, ptr - name);
if (dir) {
memcpy((void *)startPtr, dir->name + (startPtr - name), ptr - startPtr);
startPtr = ptr;
startPtr = ptr + 1;
}
ptr++;
}
}
}

Просмотреть файл

@ -80,7 +80,21 @@ test_expect_success 'merge (case change)' '
git merge topic
'
test_expect_success CASE_INSENSITIVE_FS 'add directory (with different case)' '
git reset --hard initial &&
mkdir -p dir1/dir2 &&
echo >dir1/dir2/a &&
echo >dir1/dir2/b &&
git add dir1/dir2/a &&
git add dir1/DIR2/b &&
git ls-files >actual &&
cat >expected <<-\EOF &&
camelcase
dir1/dir2/a
dir1/dir2/b
EOF
test_cmp expected actual
'
test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
git reset --hard initial &&