зеркало из https://github.com/microsoft/git.git
Merge branch 'mh/fast-import-notes-fix-new' into maint
"git fast-import" sometimes mishandled while rebalancing notes tree, which has been fixed. * mh/fast-import-notes-fix-new: fast-import: properly fanout notes when tree is imported
This commit is contained in:
Коммит
867ce0416c
|
@ -2218,13 +2218,17 @@ static uintmax_t do_change_note_fanout(
|
|||
char *fullpath, unsigned int fullpath_len,
|
||||
unsigned char fanout)
|
||||
{
|
||||
struct tree_content *t = root->tree;
|
||||
struct tree_content *t;
|
||||
struct tree_entry *e, leaf;
|
||||
unsigned int i, tmp_hex_sha1_len, tmp_fullpath_len;
|
||||
uintmax_t num_notes = 0;
|
||||
unsigned char sha1[20];
|
||||
char realpath[60];
|
||||
|
||||
if (!root->tree)
|
||||
load_tree(root);
|
||||
t = root->tree;
|
||||
|
||||
for (i = 0; t && i < t->entry_count; i++) {
|
||||
e = t->entries[i];
|
||||
tmp_hex_sha1_len = hex_sha1_len + e->name->str_len;
|
||||
|
@ -2276,8 +2280,6 @@ static uintmax_t do_change_note_fanout(
|
|||
leaf.tree);
|
||||
} else if (S_ISDIR(e->versions[1].mode)) {
|
||||
/* This is a subdir that may contain note entries */
|
||||
if (!e->tree)
|
||||
load_tree(e);
|
||||
num_notes += do_change_note_fanout(orig_root, e,
|
||||
hex_sha1, tmp_hex_sha1_len,
|
||||
fullpath, tmp_fullpath_len, fanout);
|
||||
|
|
|
@ -483,6 +483,48 @@ test_expect_success 'verify that lots of notes trigger a fanout scheme' '
|
|||
|
||||
'
|
||||
|
||||
# Create another notes tree from the one above
|
||||
SP=" "
|
||||
cat >>input <<INPUT_END
|
||||
commit refs/heads/other_commits
|
||||
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
||||
data <<COMMIT
|
||||
commit #$(($num_commit + 1))
|
||||
COMMIT
|
||||
|
||||
from refs/heads/many_commits
|
||||
M 644 inline file
|
||||
data <<EOF
|
||||
file contents in commit #$(($num_commit + 1))
|
||||
EOF
|
||||
|
||||
commit refs/notes/other_notes
|
||||
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
||||
data <<COMMIT
|
||||
committing one more note on a tree imported from a previous notes tree
|
||||
COMMIT
|
||||
|
||||
M 040000 $(git log --no-walk --format=%T refs/notes/many_notes)$SP
|
||||
N inline :$(($num_commit + 1))
|
||||
data <<EOF
|
||||
note for commit #$(($num_commit + 1))
|
||||
EOF
|
||||
INPUT_END
|
||||
|
||||
test_expect_success 'verify that importing a notes tree respects the fanout scheme' '
|
||||
git fast-import <input &&
|
||||
|
||||
# None of the entries in the top-level notes tree should be a full SHA1
|
||||
git ls-tree --name-only refs/notes/other_notes |
|
||||
while read path
|
||||
do
|
||||
if test $(expr length "$path") -ge 40
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
'
|
||||
|
||||
cat >>expect_non-note1 << EOF
|
||||
This is not a note, but rather a regular file residing in a notes tree
|
||||
EOF
|
||||
|
|
Загрузка…
Ссылка в новой задаче