2009-12-07 14:27:26 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Johan Herland
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='test git fast-import of notes objects'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/master
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
first commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline foo
|
|
|
|
data <<EOF
|
|
|
|
file foo in first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 755 inline bar
|
|
|
|
data <<EOF
|
|
|
|
file bar in first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 644 inline baz/xyzzy
|
|
|
|
data <<EOF
|
|
|
|
file baz/xyzzy in first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/heads/master
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
second commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline foo
|
|
|
|
data <<EOF
|
|
|
|
file foo in second commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 755 inline baz/xyzzy
|
|
|
|
data <<EOF
|
|
|
|
file baz/xyzzy in second commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/heads/master
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
third commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline foo
|
|
|
|
data <<EOF
|
|
|
|
file foo in third commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/heads/master
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
fourth commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 755 inline bar
|
|
|
|
data <<EOF
|
|
|
|
file bar in fourth commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success 'set up master branch' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
git whatchanged master
|
|
|
|
'
|
|
|
|
|
|
|
|
commit4=$(git rev-parse refs/heads/master)
|
|
|
|
commit3=$(git rev-parse "$commit4^")
|
|
|
|
commit2=$(git rev-parse "$commit4~2")
|
|
|
|
commit1=$(git rev-parse "$commit4~3")
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/notes/test
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
first notes commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline $commit1
|
|
|
|
data <<EOF
|
|
|
|
first note for first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 755 inline $commit2
|
|
|
|
data <<EOF
|
|
|
|
first note for second commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EXPECT_END
|
|
|
|
fourth commit
|
|
|
|
third commit
|
|
|
|
second commit
|
|
|
|
first note for second commit
|
|
|
|
first commit
|
|
|
|
first note for first commit
|
|
|
|
EXPECT_END
|
|
|
|
|
|
|
|
test_expect_success 'add notes with simple M command' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/test git log | grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
2011-02-10 01:43:57 +03:00
|
|
|
feature notes
|
2009-12-07 14:27:26 +03:00
|
|
|
commit refs/notes/test
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
second notes commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/notes/test^0
|
|
|
|
N inline $commit3
|
|
|
|
data <<EOF
|
|
|
|
first note for third commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit4
|
|
|
|
data <<EOF
|
|
|
|
first note for fourth commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EXPECT_END
|
|
|
|
fourth commit
|
|
|
|
first note for fourth commit
|
|
|
|
third commit
|
|
|
|
first note for third commit
|
|
|
|
second commit
|
|
|
|
first note for second commit
|
|
|
|
first commit
|
|
|
|
first note for first commit
|
|
|
|
EXPECT_END
|
|
|
|
|
|
|
|
test_expect_success 'add notes with simple N command' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/test git log | grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/notes/test
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
third notes commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/notes/test^0
|
|
|
|
N inline $commit1
|
|
|
|
data <<EOF
|
|
|
|
second note for first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit2
|
|
|
|
data <<EOF
|
|
|
|
second note for second commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit3
|
|
|
|
data <<EOF
|
|
|
|
second note for third commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit4
|
|
|
|
data <<EOF
|
|
|
|
second note for fourth commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EXPECT_END
|
|
|
|
fourth commit
|
|
|
|
second note for fourth commit
|
|
|
|
third commit
|
|
|
|
second note for third commit
|
|
|
|
second commit
|
|
|
|
second note for second commit
|
|
|
|
first commit
|
|
|
|
second note for first commit
|
|
|
|
EXPECT_END
|
|
|
|
|
|
|
|
test_expect_success 'update existing notes with N command' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/test git log | grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/notes/test
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
fourth notes commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/notes/test^0
|
|
|
|
M 644 inline $(echo "$commit3" | sed "s|^..|&/|")
|
|
|
|
data <<EOF
|
|
|
|
prefix of note for third commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 644 inline $(echo "$commit4" | sed "s|^..|&/|")
|
|
|
|
data <<EOF
|
|
|
|
prefix of note for fourth commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 644 inline $(echo "$commit4" | sed "s|^\(..\)\(..\)|\1/\2/|")
|
|
|
|
data <<EOF
|
|
|
|
pre-prefix of note for fourth commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit1
|
|
|
|
data <<EOF
|
|
|
|
third note for first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit2
|
|
|
|
data <<EOF
|
|
|
|
third note for second commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit3
|
|
|
|
data <<EOF
|
|
|
|
third note for third commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit4
|
|
|
|
data <<EOF
|
|
|
|
third note for fourth commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
2010-11-10 00:49:44 +03:00
|
|
|
whitespace=" "
|
|
|
|
|
2009-12-07 14:27:26 +03:00
|
|
|
cat >expect <<EXPECT_END
|
|
|
|
fourth commit
|
|
|
|
pre-prefix of note for fourth commit
|
2010-11-10 00:49:44 +03:00
|
|
|
$whitespace
|
2009-12-07 14:27:26 +03:00
|
|
|
prefix of note for fourth commit
|
2010-11-10 00:49:44 +03:00
|
|
|
$whitespace
|
2009-12-07 14:27:26 +03:00
|
|
|
third note for fourth commit
|
|
|
|
third commit
|
|
|
|
prefix of note for third commit
|
2010-11-10 00:49:44 +03:00
|
|
|
$whitespace
|
2009-12-07 14:27:26 +03:00
|
|
|
third note for third commit
|
|
|
|
second commit
|
|
|
|
third note for second commit
|
|
|
|
first commit
|
|
|
|
third note for first commit
|
|
|
|
EXPECT_END
|
|
|
|
|
|
|
|
test_expect_success 'add concatentation notes with M command' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/test git log | grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/notes/test
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
fifth notes commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/notes/test^0
|
|
|
|
deleteall
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EXPECT_END
|
|
|
|
fourth commit
|
|
|
|
third commit
|
|
|
|
second commit
|
|
|
|
first commit
|
|
|
|
EXPECT_END
|
|
|
|
|
|
|
|
test_expect_success 'verify that deleteall also removes notes' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/test git log | grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/notes/test
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
sixth notes commit
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/notes/test^0
|
|
|
|
M 644 inline $commit1
|
|
|
|
data <<EOF
|
|
|
|
third note for first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 644 inline $commit3
|
|
|
|
data <<EOF
|
|
|
|
third note for third commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit1
|
|
|
|
data <<EOF
|
|
|
|
fourth note for first commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
N inline $commit3
|
|
|
|
data <<EOF
|
|
|
|
fourth note for third commit
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EXPECT_END
|
|
|
|
fourth commit
|
|
|
|
third commit
|
|
|
|
fourth note for third commit
|
|
|
|
second commit
|
|
|
|
first commit
|
|
|
|
fourth note for first commit
|
|
|
|
EXPECT_END
|
|
|
|
|
|
|
|
test_expect_success 'verify that later N commands override earlier M commands' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/test git log | grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
# Write fast-import commands to create the given number of commits
|
|
|
|
fast_import_commits () {
|
|
|
|
my_ref=$1
|
|
|
|
my_num_commits=$2
|
|
|
|
my_append_to_file=$3
|
|
|
|
my_i=0
|
|
|
|
while test $my_i -lt $my_num_commits
|
|
|
|
do
|
|
|
|
my_i=$(($my_i + 1))
|
|
|
|
test_tick
|
|
|
|
cat >>"$my_append_to_file" <<INPUT_END
|
|
|
|
commit $my_ref
|
|
|
|
mark :$my_i
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit #$my_i
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline file
|
|
|
|
data <<EOF
|
|
|
|
file contents in commit #$my_i
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Write fast-import commands to create the given number of notes annotating
|
|
|
|
# the commits created by fast_import_commits()
|
|
|
|
fast_import_notes () {
|
|
|
|
my_notes_ref=$1
|
|
|
|
my_num_commits=$2
|
|
|
|
my_append_to_file=$3
|
|
|
|
my_note_append=$4
|
|
|
|
test_tick
|
|
|
|
cat >>"$my_append_to_file" <<INPUT_END
|
|
|
|
commit $my_notes_ref
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
committing $my_num_commits notes
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
my_i=0
|
|
|
|
while test $my_i -lt $my_num_commits
|
|
|
|
do
|
|
|
|
my_i=$(($my_i + 1))
|
|
|
|
cat >>"$my_append_to_file" <<INPUT_END
|
|
|
|
N inline :$my_i
|
|
|
|
data <<EOF
|
|
|
|
note for commit #$my_i$my_note_append
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rm input expect
|
|
|
|
num_commits=400
|
|
|
|
# Create lots of commits
|
|
|
|
fast_import_commits "refs/heads/many_commits" $num_commits input
|
|
|
|
# Create one note per above commit
|
|
|
|
fast_import_notes "refs/notes/many_notes" $num_commits input
|
|
|
|
# Add a couple of non-notes as well
|
|
|
|
test_tick
|
|
|
|
cat >>input <<INPUT_END
|
|
|
|
commit refs/notes/many_notes
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
committing some non-notes to the notes tree
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 755 inline foobar/non-note.txt
|
|
|
|
data <<EOF
|
|
|
|
This is not a note, but rather a regular file residing in a notes tree
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 644 inline deadbeef
|
|
|
|
data <<EOF
|
|
|
|
Non-note file
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 644 inline de/adbeef
|
|
|
|
data <<EOF
|
|
|
|
Another non-note file
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
# Finally create the expected output from all these notes and commits
|
|
|
|
i=$num_commits
|
|
|
|
while test $i -gt 0
|
|
|
|
do
|
|
|
|
cat >>expect <<EXPECT_END
|
|
|
|
commit #$i
|
|
|
|
note for commit #$i
|
|
|
|
EXPECT_END
|
|
|
|
i=$(($i - 1))
|
|
|
|
done
|
|
|
|
|
|
|
|
test_expect_success 'add lots of commits and notes' '
|
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/many_notes git log refs/heads/many_commits |
|
|
|
|
grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'verify that lots of notes trigger a fanout scheme' '
|
|
|
|
|
|
|
|
# None of the entries in the top-level notes tree should be a full SHA1
|
|
|
|
git ls-tree --name-only refs/notes/many_notes |
|
|
|
|
while read path
|
|
|
|
do
|
|
|
|
if test $(expr length "$path") -ge 40
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
'
|
|
|
|
|
fast-import: properly fanout notes when tree is imported
In typical uses of fast-import, trees are inherited from a parent
commit. In that case, the tree_entry for the branch looks like:
.versions[1].sha1 = $some_sha1
.tree = <tree structure loaded from $some_sha1>
However, when trees are imported, rather than inherited, that is not the
case. One can import a tree with a filemodify command, replacing the
root tree object.
e.g.
"M 040000 $some_sha1 \n"
In this case, the tree_entry for the branch looks like:
.versions[1].sha1 = $some_sha1
.tree = NULL
When adding new notes with the notemodify command, do_change_note_fanout
is called to get a notes count, and to do so, it loops over the
tree_entry->tree, but doesn't do anything when the tree is NULL.
In the latter case above, it means do_change_note_fanout thinks the tree
contains no notes, and new notes are added with no fanout.
Interestingly, do_change_note_fanout does check whether subdirectories
have a NULL .tree, in which case it uses load_tree(). Which means the
right behaviour happens when using the filemodify command to import
subdirectories.
This change makes do_change_note_fanount call load_tree() whenever the
tree_entry it is given has no tree loaded, making all cases handled
equally.
Signed-off-by: Mike Hommey <mh@glandium.org>
Reviewed-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-12-21 00:04:48 +03:00
|
|
|
# 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
|
|
|
|
'
|
|
|
|
|
2009-12-07 14:27:26 +03:00
|
|
|
cat >>expect_non-note1 << EOF
|
|
|
|
This is not a note, but rather a regular file residing in a notes tree
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >>expect_non-note2 << EOF
|
|
|
|
Non-note file
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >>expect_non-note3 << EOF
|
|
|
|
Another non-note file
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'verify that non-notes are untouched by a fanout change' '
|
|
|
|
|
|
|
|
git cat-file -p refs/notes/many_notes:foobar/non-note.txt > actual &&
|
|
|
|
test_cmp expect_non-note1 actual &&
|
|
|
|
git cat-file -p refs/notes/many_notes:deadbeef > actual &&
|
|
|
|
test_cmp expect_non-note2 actual &&
|
|
|
|
git cat-file -p refs/notes/many_notes:de/adbeef > actual &&
|
|
|
|
test_cmp expect_non-note3 actual
|
|
|
|
|
|
|
|
'
|
2011-11-25 04:09:46 +04:00
|
|
|
|
|
|
|
# Change the notes for the three top commits
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/notes/many_notes
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
changing notes for the top three commits
|
|
|
|
COMMIT
|
|
|
|
from refs/notes/many_notes^0
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
rm expect
|
|
|
|
i=$num_commits
|
|
|
|
j=0
|
|
|
|
while test $j -lt 3
|
|
|
|
do
|
|
|
|
cat >>input <<INPUT_END
|
|
|
|
N inline refs/heads/many_commits~$j
|
|
|
|
data <<EOF
|
|
|
|
changed note for commit #$i
|
|
|
|
EOF
|
|
|
|
INPUT_END
|
|
|
|
cat >>expect <<EXPECT_END
|
|
|
|
commit #$i
|
|
|
|
changed note for commit #$i
|
|
|
|
EXPECT_END
|
|
|
|
i=$(($i - 1))
|
|
|
|
j=$(($j + 1))
|
|
|
|
done
|
|
|
|
|
2011-11-25 04:09:47 +04:00
|
|
|
test_expect_success 'change a few existing notes' '
|
2011-11-25 04:09:46 +04:00
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/many_notes git log -n3 refs/heads/many_commits |
|
|
|
|
grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2011-11-25 04:09:47 +04:00
|
|
|
test_expect_success 'verify that changing notes respect existing fanout' '
|
2011-11-25 04:09:46 +04:00
|
|
|
|
|
|
|
# None of the entries in the top-level notes tree should be a full SHA1
|
|
|
|
git ls-tree --name-only refs/notes/many_notes |
|
|
|
|
while read path
|
|
|
|
do
|
|
|
|
if test $(expr length "$path") -ge 40
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-12-07 14:27:26 +03:00
|
|
|
remaining_notes=10
|
|
|
|
test_tick
|
t9301: Fix testcase covering up a bug in fast-import's notes fanout handling
There is a bug in fast-import where the fanout levels of an existing notes
tree being loaded into the fast-import machinery is disregarded. Instead, any
tree loaded is assumed to have a fanout level of 0. If the true fanout level
is deeper, any attempt to remove a note from that tree will silently fail
(as the note will not be found at fanout level 0).
However, this bug was covered up by the way in which the t9301 testcase was
written: When generating the fast-import commands to test mass removal of
notes, we appended these commands to an already existing 'input' file which
happened to already contain the fast-import commands used in the previous
subtest to generate the very same notes tree. This would normally be harmless
(but suboptimal) as the notes created were identical to the notes already
present in the notes tree. But the act of repeating all the notes additions
caused the internal fast-import data structures to recalculate the fanout,
instead of hanging on to the initial (incorrect) fanout (that causes the bug
described above). Thus, the subsequent removal of notes in the same 'input'
file would succeed, thereby covering up the bug described above.
This patch creates a new 'input' file instead of appending to the file from
the previous subtest. Thus, we end up properly testing removal of notes that
were added by a previous fast-import command. As a side effect, the notes
removal can no longer refer to commits using the marks set by the previous
fast-import run, instead the commits names must be referenced directly.
The underlying fast-import bug is still present after this patch, but now we
have at least uncovered it. Therefore, the affected subtests are labeled as
expected failures until the underlying bug is fixed.
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-11-25 04:09:45 +04:00
|
|
|
cat >input <<INPUT_END
|
2009-12-07 14:27:26 +03:00
|
|
|
commit refs/notes/many_notes
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
removing all notes but $remaining_notes
|
|
|
|
COMMIT
|
|
|
|
from refs/notes/many_notes^0
|
|
|
|
INPUT_END
|
|
|
|
|
t9301: Fix testcase covering up a bug in fast-import's notes fanout handling
There is a bug in fast-import where the fanout levels of an existing notes
tree being loaded into the fast-import machinery is disregarded. Instead, any
tree loaded is assumed to have a fanout level of 0. If the true fanout level
is deeper, any attempt to remove a note from that tree will silently fail
(as the note will not be found at fanout level 0).
However, this bug was covered up by the way in which the t9301 testcase was
written: When generating the fast-import commands to test mass removal of
notes, we appended these commands to an already existing 'input' file which
happened to already contain the fast-import commands used in the previous
subtest to generate the very same notes tree. This would normally be harmless
(but suboptimal) as the notes created were identical to the notes already
present in the notes tree. But the act of repeating all the notes additions
caused the internal fast-import data structures to recalculate the fanout,
instead of hanging on to the initial (incorrect) fanout (that causes the bug
described above). Thus, the subsequent removal of notes in the same 'input'
file would succeed, thereby covering up the bug described above.
This patch creates a new 'input' file instead of appending to the file from
the previous subtest. Thus, we end up properly testing removal of notes that
were added by a previous fast-import command. As a side effect, the notes
removal can no longer refer to commits using the marks set by the previous
fast-import run, instead the commits names must be referenced directly.
The underlying fast-import bug is still present after this patch, but now we
have at least uncovered it. Therefore, the affected subtests are labeled as
expected failures until the underlying bug is fixed.
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-11-25 04:09:45 +04:00
|
|
|
i=$(($num_commits - $remaining_notes))
|
|
|
|
for sha1 in $(git rev-list -n $i refs/heads/many_commits)
|
2009-12-07 14:27:26 +03:00
|
|
|
do
|
|
|
|
cat >>input <<INPUT_END
|
t9301: Fix testcase covering up a bug in fast-import's notes fanout handling
There is a bug in fast-import where the fanout levels of an existing notes
tree being loaded into the fast-import machinery is disregarded. Instead, any
tree loaded is assumed to have a fanout level of 0. If the true fanout level
is deeper, any attempt to remove a note from that tree will silently fail
(as the note will not be found at fanout level 0).
However, this bug was covered up by the way in which the t9301 testcase was
written: When generating the fast-import commands to test mass removal of
notes, we appended these commands to an already existing 'input' file which
happened to already contain the fast-import commands used in the previous
subtest to generate the very same notes tree. This would normally be harmless
(but suboptimal) as the notes created were identical to the notes already
present in the notes tree. But the act of repeating all the notes additions
caused the internal fast-import data structures to recalculate the fanout,
instead of hanging on to the initial (incorrect) fanout (that causes the bug
described above). Thus, the subsequent removal of notes in the same 'input'
file would succeed, thereby covering up the bug described above.
This patch creates a new 'input' file instead of appending to the file from
the previous subtest. Thus, we end up properly testing removal of notes that
were added by a previous fast-import command. As a side effect, the notes
removal can no longer refer to commits using the marks set by the previous
fast-import run, instead the commits names must be referenced directly.
The underlying fast-import bug is still present after this patch, but now we
have at least uncovered it. Therefore, the affected subtests are labeled as
expected failures until the underlying bug is fixed.
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-11-25 04:09:45 +04:00
|
|
|
N 0000000000000000000000000000000000000000 $sha1
|
2009-12-07 14:27:26 +03:00
|
|
|
INPUT_END
|
|
|
|
done
|
|
|
|
|
|
|
|
i=$num_commits
|
|
|
|
rm expect
|
|
|
|
while test $i -gt 0
|
|
|
|
do
|
|
|
|
cat >>expect <<EXPECT_END
|
|
|
|
commit #$i
|
|
|
|
EXPECT_END
|
|
|
|
if test $i -le $remaining_notes
|
|
|
|
then
|
|
|
|
cat >>expect <<EXPECT_END
|
|
|
|
note for commit #$i
|
|
|
|
EXPECT_END
|
|
|
|
fi
|
|
|
|
i=$(($i - 1))
|
|
|
|
done
|
|
|
|
|
2011-11-25 04:09:47 +04:00
|
|
|
test_expect_success 'remove lots of notes' '
|
2009-12-07 14:27:26 +03:00
|
|
|
|
|
|
|
git fast-import <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/many_notes git log refs/heads/many_commits |
|
|
|
|
grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2011-11-25 04:09:47 +04:00
|
|
|
test_expect_success 'verify that removing notes trigger fanout consolidation' '
|
2009-12-07 14:27:26 +03:00
|
|
|
|
|
|
|
# All entries in the top-level notes tree should be a full SHA1
|
|
|
|
git ls-tree --name-only -r refs/notes/many_notes |
|
|
|
|
while read path
|
|
|
|
do
|
|
|
|
# Explicitly ignore the non-note paths
|
|
|
|
test "$path" = "foobar/non-note.txt" && continue
|
|
|
|
test "$path" = "deadbeef" && continue
|
|
|
|
test "$path" = "de/adbeef" && continue
|
|
|
|
|
|
|
|
if test $(expr length "$path") -ne 40
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'verify that non-notes are untouched by a fanout change' '
|
|
|
|
|
|
|
|
git cat-file -p refs/notes/many_notes:foobar/non-note.txt > actual &&
|
|
|
|
test_cmp expect_non-note1 actual &&
|
|
|
|
git cat-file -p refs/notes/many_notes:deadbeef > actual &&
|
|
|
|
test_cmp expect_non-note2 actual &&
|
|
|
|
git cat-file -p refs/notes/many_notes:de/adbeef > actual &&
|
|
|
|
test_cmp expect_non-note3 actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
|
|
|
|
rm input expect
|
|
|
|
num_notes_refs=10
|
|
|
|
num_commits=16
|
|
|
|
some_commits=8
|
|
|
|
# Create commits
|
|
|
|
fast_import_commits "refs/heads/more_commits" $num_commits input
|
|
|
|
# Create one note per above commit per notes ref
|
|
|
|
i=0
|
|
|
|
while test $i -lt $num_notes_refs
|
|
|
|
do
|
|
|
|
i=$(($i + 1))
|
|
|
|
fast_import_notes "refs/notes/more_notes_$i" $num_commits input
|
|
|
|
done
|
|
|
|
# Trigger branch reloading in git-fast-import by repeating the note creation
|
|
|
|
i=0
|
|
|
|
while test $i -lt $num_notes_refs
|
|
|
|
do
|
|
|
|
i=$(($i + 1))
|
|
|
|
fast_import_notes "refs/notes/more_notes_$i" $some_commits input " (2)"
|
|
|
|
done
|
|
|
|
# Finally create the expected output from the notes in refs/notes/more_notes_1
|
|
|
|
i=$num_commits
|
|
|
|
while test $i -gt 0
|
|
|
|
do
|
|
|
|
note_data="note for commit #$i"
|
|
|
|
if test $i -le $some_commits
|
|
|
|
then
|
|
|
|
note_data="$note_data (2)"
|
|
|
|
fi
|
|
|
|
cat >>expect <<EXPECT_END
|
|
|
|
commit #$i
|
|
|
|
$note_data
|
|
|
|
EXPECT_END
|
|
|
|
i=$(($i - 1))
|
|
|
|
done
|
|
|
|
|
|
|
|
test_expect_success "add notes to $num_commits commits in each of $num_notes_refs refs" '
|
|
|
|
|
|
|
|
git fast-import --active-branches=5 <input &&
|
|
|
|
GIT_NOTES_REF=refs/notes/more_notes_1 git log refs/heads/more_commits |
|
|
|
|
grep "^ " > actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|