2009-10-09 12:21:58 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Johannes E. Schindelin
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Test commit notes'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
write_script fake_editor <<\EOF
|
|
|
|
echo "$MSG" >"$1"
|
|
|
|
echo "$MSG" >&2
|
2009-10-09 12:21:58 +02:00
|
|
|
EOF
|
2014-11-12 01:40:16 +01:00
|
|
|
GIT_EDITOR=./fake_editor
|
2010-02-13 22:28:20 +01:00
|
|
|
export GIT_EDITOR
|
2009-10-09 12:21:58 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
indent=" "
|
|
|
|
|
2009-10-09 12:21:58 +02:00
|
|
|
test_expect_success 'cannot annotate non-existing HEAD' '
|
2014-03-18 19:54:05 +01:00
|
|
|
test_must_fail env MSG=3 git notes add
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'setup' '
|
|
|
|
test_commit 1st &&
|
|
|
|
test_commit 2nd
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'need valid notes ref' '
|
2014-03-18 19:54:05 +01:00
|
|
|
test_must_fail env MSG=1 GIT_NOTES_REF=/ git notes show &&
|
|
|
|
test_must_fail env MSG=2 GIT_NOTES_REF=/ git notes show
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:32 +01:00
|
|
|
test_expect_success 'refusing to add notes in refs/heads/' '
|
2014-03-18 19:54:05 +01:00
|
|
|
test_must_fail env MSG=1 GIT_NOTES_REF=refs/heads/bogus git notes add
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:32 +01:00
|
|
|
test_expect_success 'refusing to edit notes in refs/remotes/' '
|
2014-03-18 19:54:05 +01:00
|
|
|
test_must_fail env MSG=1 GIT_NOTES_REF=refs/heads/bogus git notes edit
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
# 1 indicates caught gracefully by die, 128 means git-show barked
|
|
|
|
test_expect_success 'handle empty notes gracefully' '
|
2010-10-31 08:36:57 +01:00
|
|
|
test_expect_code 1 git notes show
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
|
|
|
|
2010-04-18 20:19:39 +02:00
|
|
|
test_expect_success 'show non-existent notes entry with %N' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_write_lines A B >expect &&
|
|
|
|
git show -s --format="A%n%NB" >actual &&
|
|
|
|
test_cmp expect actual
|
2010-04-18 20:19:39 +02:00
|
|
|
'
|
|
|
|
|
2009-10-09 12:21:58 +02:00
|
|
|
test_expect_success 'create notes' '
|
2010-02-13 22:28:32 +01:00
|
|
|
MSG=b4 git notes add &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_path_is_missing .git/NOTES_EDITMSG &&
|
|
|
|
git ls-tree -r refs/notes/commits >actual &&
|
|
|
|
test_line_count = 1 actual &&
|
|
|
|
test "b4" = "$(git notes show)" &&
|
2010-02-13 22:28:20 +01:00
|
|
|
git show HEAD^ &&
|
|
|
|
test_must_fail git notes show HEAD^
|
|
|
|
'
|
|
|
|
|
2010-04-18 20:19:39 +02:00
|
|
|
test_expect_success 'show notes entry with %N' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_write_lines A b4 B >expect &&
|
|
|
|
git show -s --format="A%n%NB" >actual &&
|
|
|
|
test_cmp expect actual
|
2010-04-18 20:19:39 +02:00
|
|
|
'
|
|
|
|
|
2010-03-29 15:05:58 +02:00
|
|
|
test_expect_success 'create reflog entry' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat <<-EOF >expect &&
|
|
|
|
a1d8fa6 refs/notes/commits@{0}: notes: Notes added by '\''git notes add'\''
|
|
|
|
EOF
|
|
|
|
git reflog show refs/notes/commits >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-29 15:05:57 +02:00
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:20 +01:00
|
|
|
test_expect_success 'edit existing notes' '
|
2010-02-13 22:28:32 +01:00
|
|
|
MSG=b3 git notes edit &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_path_is_missing .git/NOTES_EDITMSG &&
|
|
|
|
git ls-tree -r refs/notes/commits >actual &&
|
|
|
|
test_line_count = 1 actual &&
|
|
|
|
test "b3" = "$(git notes show)" &&
|
2010-02-13 22:28:32 +01:00
|
|
|
git show HEAD^ &&
|
|
|
|
test_must_fail git notes show HEAD^
|
|
|
|
'
|
|
|
|
|
2011-03-30 02:02:55 +02:00
|
|
|
test_expect_success 'cannot "git notes add -m" where notes already exists' '
|
|
|
|
test_must_fail git notes add -m "b2" &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_path_is_missing .git/NOTES_EDITMSG &&
|
|
|
|
git ls-tree -r refs/notes/commits >actual &&
|
|
|
|
test_line_count = 1 actual &&
|
|
|
|
test "b3" = "$(git notes show)" &&
|
2010-02-13 22:28:32 +01:00
|
|
|
git show HEAD^ &&
|
|
|
|
test_must_fail git notes show HEAD^
|
|
|
|
'
|
|
|
|
|
2011-03-30 02:02:55 +02:00
|
|
|
test_expect_success 'can overwrite existing note with "git notes add -f -m"' '
|
|
|
|
git notes add -f -m "b1" &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_path_is_missing .git/NOTES_EDITMSG &&
|
|
|
|
git ls-tree -r refs/notes/commits >actual &&
|
|
|
|
test_line_count = 1 actual &&
|
|
|
|
test "b1" = "$(git notes show)" &&
|
2011-03-30 02:02:55 +02:00
|
|
|
git show HEAD^ &&
|
|
|
|
test_must_fail git notes show HEAD^
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'add w/no options on existing note morphs into edit' '
|
|
|
|
MSG=b2 git notes add &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_path_is_missing .git/NOTES_EDITMSG &&
|
|
|
|
git ls-tree -r refs/notes/commits >actual &&
|
|
|
|
test_line_count = 1 actual &&
|
|
|
|
test "b2" = "$(git notes show)" &&
|
2011-03-30 02:02:55 +02:00
|
|
|
git show HEAD^ &&
|
|
|
|
test_must_fail git notes show HEAD^
|
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:32 +01:00
|
|
|
test_expect_success 'can overwrite existing note with "git notes add -f"' '
|
|
|
|
MSG=b1 git notes add -f &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_path_is_missing .git/NOTES_EDITMSG &&
|
|
|
|
git ls-tree -r refs/notes/commits >actual &&
|
|
|
|
test_line_count = 1 actual &&
|
|
|
|
test "b1" = "$(git notes show)" &&
|
2009-10-09 12:21:58 +02:00
|
|
|
git show HEAD^ &&
|
|
|
|
test_must_fail git notes show HEAD^
|
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'show notes' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 7a4ca6ee52a974a66cbaa78e33214535dff1d691
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:14:13 2005 -0700
|
2009-10-09 12:21:58 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}2nd
|
2009-10-09 12:21:58 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}b1
|
|
|
|
EOF
|
2009-10-09 12:21:58 +02:00
|
|
|
! (git cat-file commit HEAD | grep b1) &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'show multi-line notes' '
|
|
|
|
test_commit 3rd &&
|
|
|
|
MSG="b3${LF}c3c3c3c3${LF}d3d3d3" git notes add &&
|
|
|
|
cat >expect-multiline <<-EOF &&
|
|
|
|
commit d07d62e5208f22eb5695e7eb47667dc8b9860290
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:15:13 2005 -0700
|
2009-10-09 12:21:58 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}3rd
|
2009-10-09 12:21:58 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}b3
|
|
|
|
${indent}c3c3c3c3
|
|
|
|
${indent}d3d3d3
|
2009-10-09 12:21:58 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
EOF
|
|
|
|
cat expect >>expect-multiline &&
|
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect-multiline actual
|
2009-10-09 12:21:58 +02:00
|
|
|
'
|
2009-10-09 12:22:01 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'show -F notes' '
|
|
|
|
test_commit 4th &&
|
|
|
|
echo "xyzzy" >note5 &&
|
|
|
|
git notes add -F note5 &&
|
|
|
|
cat >expect-F <<-EOF &&
|
|
|
|
commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:16:13 2005 -0700
|
2009-10-09 12:22:01 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}4th
|
2009-10-09 12:22:01 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}xyzzy
|
2009-10-09 12:22:01 +02:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
EOF
|
|
|
|
cat expect-multiline >>expect-F &&
|
|
|
|
git log -3 >actual &&
|
|
|
|
test_cmp expect-F actual
|
2009-10-09 12:22:01 +02:00
|
|
|
'
|
2009-10-09 12:21:58 +02:00
|
|
|
|
2011-03-30 02:02:55 +02:00
|
|
|
test_expect_success 'Re-adding -F notes without -f fails' '
|
2014-11-12 01:40:16 +01:00
|
|
|
echo "zyxxy" >note5 &&
|
2011-03-30 02:02:55 +02:00
|
|
|
test_must_fail git notes add -F note5 &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -3 >actual &&
|
|
|
|
test_cmp expect-F actual
|
2011-03-30 02:02:55 +02:00
|
|
|
'
|
|
|
|
|
2010-01-20 22:59:36 +01:00
|
|
|
test_expect_success 'git log --pretty=raw does not show notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11
|
|
|
|
tree 05ac65288c4c4b3b709a020ae94b2ece2f2201ae
|
|
|
|
parent d07d62e5208f22eb5695e7eb47667dc8b9860290
|
|
|
|
author A U Thor <author@example.com> 1112912173 -0700
|
|
|
|
committer C O Mitter <committer@example.com> 1112912173 -0700
|
|
|
|
|
|
|
|
${indent}4th
|
|
|
|
EOF
|
|
|
|
git log -1 --pretty=raw >actual &&
|
|
|
|
test_cmp expect actual
|
2010-01-20 22:59:36 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git log --show-notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >>expect <<-EOF &&
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}xyzzy
|
|
|
|
EOF
|
|
|
|
git log -1 --pretty=raw --show-notes >actual &&
|
|
|
|
test_cmp expect actual
|
2010-01-20 22:59:36 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git log --no-notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 --no-notes >actual &&
|
|
|
|
! grep xyzzy actual
|
2010-01-20 22:59:36 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git format-patch does not show notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git format-patch -1 --stdout >actual &&
|
|
|
|
! grep xyzzy actual
|
2010-01-20 22:59:36 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git format-patch --show-notes does show notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git format-patch --show-notes -1 --stdout >actual &&
|
|
|
|
grep xyzzy actual
|
2010-01-20 22:59:36 +01:00
|
|
|
'
|
|
|
|
|
2010-01-21 23:57:41 +01:00
|
|
|
for pretty in \
|
|
|
|
"" --pretty --pretty=raw --pretty=short --pretty=medium \
|
|
|
|
--pretty=full --pretty=fuller --pretty=format:%s --oneline
|
2010-01-20 22:59:36 +01:00
|
|
|
do
|
|
|
|
case "$pretty" in
|
|
|
|
"") p= not= negate="" ;;
|
2010-01-21 23:57:41 +01:00
|
|
|
?*) p="$pretty" not=" not" negate="!" ;;
|
2010-01-20 22:59:36 +01:00
|
|
|
esac
|
|
|
|
test_expect_success "git show $pretty does$not show notes" '
|
2014-11-12 01:40:16 +01:00
|
|
|
git show $p >actual &&
|
|
|
|
eval "$negate grep xyzzy actual"
|
2010-01-20 22:59:36 +01:00
|
|
|
'
|
|
|
|
done
|
|
|
|
|
2011-03-29 22:57:47 +02:00
|
|
|
test_expect_success 'setup alternate notes ref' '
|
|
|
|
git notes --ref=alternate add -m alternate
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git log --notes shows default notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 --notes >actual &&
|
|
|
|
grep xyzzy actual &&
|
|
|
|
! grep alternate actual
|
2011-03-29 22:57:47 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git log --notes=X shows only X' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 --notes=alternate >actual &&
|
|
|
|
! grep xyzzy actual &&
|
|
|
|
grep alternate actual
|
2011-03-29 22:57:47 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git log --notes --notes=X shows both' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 --notes --notes=alternate >actual &&
|
|
|
|
grep xyzzy actual &&
|
|
|
|
grep alternate actual
|
2011-03-29 22:57:47 +02:00
|
|
|
'
|
|
|
|
|
2011-03-29 22:59:42 +02:00
|
|
|
test_expect_success 'git log --no-notes resets default state' '
|
|
|
|
git log -1 --notes --notes=alternate \
|
|
|
|
--no-notes --notes=alternate \
|
2014-11-12 01:40:16 +01:00
|
|
|
>actual &&
|
|
|
|
! grep xyzzy actual &&
|
|
|
|
grep alternate actual
|
2011-03-29 22:59:42 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git log --no-notes resets ref list' '
|
|
|
|
git log -1 --notes --notes=alternate \
|
|
|
|
--no-notes --notes \
|
2014-11-12 01:40:16 +01:00
|
|
|
>actual &&
|
|
|
|
grep xyzzy actual &&
|
|
|
|
! grep alternate actual
|
2010-02-13 22:28:20 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'show -m notes' '
|
|
|
|
test_commit 5th &&
|
|
|
|
git notes add -m spam -m "foo${LF}bar${LF}baz" &&
|
|
|
|
cat >expect-m <<-EOF &&
|
|
|
|
commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:17:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}5th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}spam
|
|
|
|
${indent}
|
|
|
|
${indent}foo
|
|
|
|
${indent}bar
|
|
|
|
${indent}baz
|
|
|
|
|
|
|
|
EOF
|
|
|
|
cat expect-F >>expect-m &&
|
|
|
|
git log -4 >actual &&
|
|
|
|
test_cmp expect-m actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'remove note with add -f -F /dev/null' '
|
|
|
|
git notes add -f -F /dev/null &&
|
|
|
|
cat >expect-rm-F <<-EOF &&
|
|
|
|
commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:17:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}5th
|
|
|
|
|
|
|
|
EOF
|
|
|
|
cat expect-F >>expect-rm-F &&
|
|
|
|
git log -4 >actual &&
|
|
|
|
test_cmp expect-rm-F actual &&
|
2010-07-21 01:18:34 +02:00
|
|
|
test_must_fail git notes show
|
2010-02-13 22:28:24 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'do not create empty note with -m ""' '
|
|
|
|
git notes add -m "" &&
|
|
|
|
git log -4 >actual &&
|
|
|
|
test_cmp expect-rm-F actual &&
|
2010-07-21 01:18:34 +02:00
|
|
|
test_must_fail git notes show
|
2010-02-13 22:28:24 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'create note with combination of -m and -F' '
|
|
|
|
cat >expect-combine_m_and_F <<-EOF &&
|
|
|
|
foo
|
2010-02-13 22:28:35 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
xyzzy
|
2010-02-13 22:28:35 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
bar
|
2010-02-13 22:28:35 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
zyxxy
|
2010-02-13 22:28:35 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
baz
|
|
|
|
EOF
|
|
|
|
echo "xyzzy" >note_a &&
|
|
|
|
echo "zyxxy" >note_b &&
|
2010-02-13 22:28:35 +01:00
|
|
|
git notes add -m "foo" -F note_a -m "bar" -F note_b -m "baz" &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes show >actual &&
|
|
|
|
test_cmp expect-combine_m_and_F actual
|
2010-02-13 22:28:35 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'remove note with "git notes remove"' '
|
2010-02-13 22:28:35 +01:00
|
|
|
git notes remove HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes remove &&
|
|
|
|
cat >expect-rm-remove <<-EOF &&
|
|
|
|
commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:17:13 2005 -0700
|
2010-02-13 22:28:25 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}5th
|
2010-02-13 22:28:25 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
commit 0f7aa3ec6325aeb88b910453bb3eb37c49d75c11
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:16:13 2005 -0700
|
2010-02-13 22:28:25 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}4th
|
2010-02-13 22:28:25 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
EOF
|
|
|
|
cat expect-multiline >>expect-rm-remove &&
|
|
|
|
git log -4 >actual &&
|
|
|
|
test_cmp expect-rm-remove actual &&
|
2010-07-21 01:18:34 +02:00
|
|
|
test_must_fail git notes show HEAD^
|
2010-02-13 22:28:25 +01:00
|
|
|
'
|
|
|
|
|
2010-08-31 17:56:50 +02:00
|
|
|
test_expect_success 'removing non-existing note should not create new commit' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git rev-parse --verify refs/notes/commits >before_commit &&
|
2010-08-31 17:56:50 +02:00
|
|
|
test_must_fail git notes remove HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git rev-parse --verify refs/notes/commits >after_commit &&
|
2010-08-31 17:56:50 +02:00
|
|
|
test_cmp before_commit after_commit
|
|
|
|
'
|
|
|
|
|
2011-05-19 00:44:37 +02:00
|
|
|
test_expect_success 'removing more than one' '
|
|
|
|
before=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test_when_finished "git update-ref refs/notes/commits $before" &&
|
|
|
|
|
|
|
|
# We have only two -- add another and make sure it stays
|
|
|
|
git notes add -m "extra" &&
|
|
|
|
git notes list HEAD >after-removal-expect &&
|
|
|
|
git notes remove HEAD^^ HEAD^^^ &&
|
|
|
|
git notes list | sed -e "s/ .*//" >actual &&
|
|
|
|
test_cmp after-removal-expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'removing is atomic' '
|
|
|
|
before=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test_when_finished "git update-ref refs/notes/commits $before" &&
|
|
|
|
test_must_fail git notes remove HEAD^^ HEAD^^^ HEAD^ &&
|
|
|
|
after=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test "$before" = "$after"
|
|
|
|
'
|
|
|
|
|
2011-05-19 01:02:58 +02:00
|
|
|
test_expect_success 'removing with --ignore-missing' '
|
|
|
|
before=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test_when_finished "git update-ref refs/notes/commits $before" &&
|
|
|
|
|
|
|
|
# We have only two -- add another and make sure it stays
|
|
|
|
git notes add -m "extra" &&
|
|
|
|
git notes list HEAD >after-removal-expect &&
|
|
|
|
git notes remove --ignore-missing HEAD^^ HEAD^^^ HEAD^ &&
|
|
|
|
git notes list | sed -e "s/ .*//" >actual &&
|
|
|
|
test_cmp after-removal-expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'removing with --ignore-missing but bogus ref' '
|
|
|
|
before=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test_when_finished "git update-ref refs/notes/commits $before" &&
|
|
|
|
test_must_fail git notes remove --ignore-missing HEAD^^ HEAD^^^ NO-SUCH-COMMIT &&
|
|
|
|
after=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test "$before" = "$after"
|
|
|
|
'
|
|
|
|
|
2011-05-19 01:44:30 +02:00
|
|
|
test_expect_success 'remove reads from --stdin' '
|
|
|
|
before=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test_when_finished "git update-ref refs/notes/commits $before" &&
|
|
|
|
|
|
|
|
# We have only two -- add another and make sure it stays
|
|
|
|
git notes add -m "extra" &&
|
|
|
|
git notes list HEAD >after-removal-expect &&
|
|
|
|
git rev-parse HEAD^^ HEAD^^^ >input &&
|
|
|
|
git notes remove --stdin <input &&
|
|
|
|
git notes list | sed -e "s/ .*//" >actual &&
|
|
|
|
test_cmp after-removal-expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'remove --stdin is also atomic' '
|
|
|
|
before=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test_when_finished "git update-ref refs/notes/commits $before" &&
|
|
|
|
git rev-parse HEAD^^ HEAD^^^ HEAD^ >input &&
|
|
|
|
test_must_fail git notes remove --stdin <input &&
|
|
|
|
after=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test "$before" = "$after"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'removing with --stdin --ignore-missing' '
|
|
|
|
before=$(git rev-parse --verify refs/notes/commits) &&
|
|
|
|
test_when_finished "git update-ref refs/notes/commits $before" &&
|
|
|
|
|
|
|
|
# We have only two -- add another and make sure it stays
|
|
|
|
git notes add -m "extra" &&
|
|
|
|
git notes list HEAD >after-removal-expect &&
|
|
|
|
git rev-parse HEAD^^ HEAD^^^ HEAD^ >input &&
|
|
|
|
git notes remove --ignore-missing --stdin <input &&
|
|
|
|
git notes list | sed -e "s/ .*//" >actual &&
|
|
|
|
test_cmp after-removal-expect actual
|
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:30 +01:00
|
|
|
test_expect_success 'list notes with "git notes list"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691
|
|
|
|
c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290
|
|
|
|
EOF
|
|
|
|
git notes list >actual &&
|
|
|
|
test_cmp expect actual
|
2010-02-13 22:28:30 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'list notes with "git notes"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes >actual &&
|
|
|
|
test_cmp expect actual
|
2010-02-13 22:28:30 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'list specific note with "git notes list <object>"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
c18dc024e14f08d18d14eea0d747ff692d66d6a3
|
|
|
|
EOF
|
|
|
|
git notes list HEAD^^ >actual &&
|
|
|
|
test_cmp expect actual
|
2010-02-13 22:28:30 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'listing non-existing notes fails' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
EOF
|
|
|
|
test_must_fail git notes list HEAD >actual &&
|
|
|
|
test_cmp expect actual
|
2010-02-13 22:28:30 +01:00
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:33 +01:00
|
|
|
test_expect_success 'append to existing note with "git notes append"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
Initial set of notes
|
|
|
|
|
|
|
|
More notes appended with git notes append
|
|
|
|
EOF
|
2010-02-13 22:28:33 +01:00
|
|
|
git notes add -m "Initial set of notes" &&
|
|
|
|
git notes append -m "More notes appended with git notes append" &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes show >actual &&
|
|
|
|
test_cmp expect actual
|
2010-02-13 22:28:33 +01:00
|
|
|
'
|
|
|
|
|
2010-02-27 09:59:22 +01:00
|
|
|
test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect_list <<-EOF &&
|
|
|
|
c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691
|
|
|
|
4b6ad22357cc8a1296720574b8d2fbc22fab0671 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
|
|
|
|
c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290
|
|
|
|
EOF
|
|
|
|
git notes list >actual &&
|
|
|
|
test_cmp expect_list actual
|
2010-02-27 09:59:22 +01:00
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:33 +01:00
|
|
|
test_expect_success 'appending empty string does not change existing note' '
|
|
|
|
git notes append -m "" &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes show >actual &&
|
|
|
|
test_cmp expect actual
|
2010-02-13 22:28:33 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes append == add when there is no existing note' '
|
|
|
|
git notes remove HEAD &&
|
|
|
|
test_must_fail git notes list HEAD &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes append -m "Initial set of notes${LF}${LF}More notes appended with git notes append" &&
|
|
|
|
git notes show >actual &&
|
|
|
|
test_cmp expect actual
|
2010-02-13 22:28:33 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'appending empty string to non-existing note does not create note' '
|
|
|
|
git notes remove HEAD &&
|
|
|
|
test_must_fail git notes list HEAD &&
|
|
|
|
git notes append -m "" &&
|
|
|
|
test_must_fail git notes list HEAD
|
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:20 +01:00
|
|
|
test_expect_success 'create other note on a different notes ref (setup)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_commit 6th &&
|
|
|
|
GIT_NOTES_REF="refs/notes/other" git notes add -m "other note" &&
|
|
|
|
cat >expect-not-other <<-EOF &&
|
|
|
|
commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:18:13 2005 -0700
|
2010-02-13 22:28:20 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}6th
|
|
|
|
EOF
|
|
|
|
cp expect-not-other expect-other &&
|
|
|
|
cat >>expect-other <<-EOF
|
2010-02-13 22:28:20 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes (other):
|
|
|
|
${indent}other note
|
|
|
|
EOF
|
|
|
|
'
|
2010-02-13 22:28:11 +01:00
|
|
|
|
|
|
|
test_expect_success 'Do not show note on other ref by default' '
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect-not-other actual
|
2010-02-13 22:28:11 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'Do show note when ref is given in GIT_NOTES_REF' '
|
2014-11-12 01:40:16 +01:00
|
|
|
GIT_NOTES_REF="refs/notes/other" git log -1 >actual &&
|
|
|
|
test_cmp expect-other actual
|
2010-02-13 22:28:11 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'Do show note when ref is given in core.notesRef config' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config core.notesRef "refs/notes/other" &&
|
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect-other actual
|
2010-02-13 22:28:11 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'Do not show note when core.notesRef is overridden' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config core.notesRef "refs/notes/other" &&
|
|
|
|
GIT_NOTES_REF="refs/notes/wrong" git log -1 >actual &&
|
|
|
|
test_cmp expect-not-other actual
|
2010-02-13 22:28:11 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
|
|
|
|
cat >expect-both <<-EOF &&
|
|
|
|
commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:18:13 2005 -0700
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}6th
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}order test
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes (other):
|
|
|
|
${indent}other note
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:17:13 2005 -0700
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}5th
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}replacement for deleted note
|
|
|
|
EOF
|
2010-03-12 18:04:26 +01:00
|
|
|
GIT_NOTES_REF=refs/notes/commits git notes add \
|
|
|
|
-m"replacement for deleted note" HEAD^ &&
|
|
|
|
GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_unconfig core.notesRef &&
|
|
|
|
test_config notes.displayRef "refs/notes/*" &&
|
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect-both actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config core.notesRef refs/notes/commits &&
|
|
|
|
test_config notes.displayRef refs/notes/other &&
|
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect-both actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'notes.displayRef can be given more than once' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_unconfig core.notesRef &&
|
|
|
|
test_config notes.displayRef refs/notes/commits &&
|
2010-03-12 18:04:26 +01:00
|
|
|
git config --add notes.displayRef refs/notes/other &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect-both actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'notes.displayRef respects order' '
|
|
|
|
cat >expect-both-reversed <<-EOF &&
|
|
|
|
commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:18:13 2005 -0700
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}6th
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes (other):
|
|
|
|
${indent}other note
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}order test
|
|
|
|
EOF
|
|
|
|
test_config core.notesRef refs/notes/other &&
|
|
|
|
test_config notes.displayRef refs/notes/commits &&
|
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect-both-reversed actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
|
|
|
|
GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect-both actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
|
|
|
|
cat >expect-none <<-EOF &&
|
|
|
|
commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:18:13 2005 -0700
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}6th
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
commit 7f9ad8836c775acb134c0a055fc55fb4cd1ba361
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:17:13 2005 -0700
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}5th
|
|
|
|
EOF
|
|
|
|
test_config notes.displayRef "refs/notes/*" &&
|
|
|
|
GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 >actual &&
|
|
|
|
test_cmp expect-none actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
|
2014-11-12 01:40:16 +01:00
|
|
|
GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 >actual &&
|
|
|
|
test_cmp expect-both actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success '--no-standard-notes' '
|
2015-01-22 12:59:36 +01:00
|
|
|
cat >expect-commits <<-EOF &&
|
2014-11-12 01:40:16 +01:00
|
|
|
commit 2c125331118caba0ff8238b7f4958ac6e93fe39c
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:18:13 2005 -0700
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}6th
|
2010-03-12 18:04:26 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}order test
|
|
|
|
EOF
|
|
|
|
git log --no-standard-notes --show-notes=commits -1 >actual &&
|
|
|
|
test_cmp expect-commits actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '--standard-notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.displayRef "refs/notes/*" &&
|
2010-03-12 18:04:26 +01:00
|
|
|
git log --no-standard-notes --show-notes=commits \
|
2014-11-12 01:40:16 +01:00
|
|
|
--standard-notes -2 >actual &&
|
|
|
|
test_cmp expect-both actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '--show-notes=ref accumulates' '
|
|
|
|
git log --show-notes=other --show-notes=commits \
|
2014-11-12 01:40:16 +01:00
|
|
|
--no-standard-notes -1 >actual &&
|
|
|
|
test_cmp expect-both-reversed actual
|
2010-03-12 18:04:26 +01:00
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:21 +01:00
|
|
|
test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config core.notesRef refs/notes/other &&
|
|
|
|
echo "Note on a tree" >expect &&
|
2010-02-13 22:28:32 +01:00
|
|
|
git notes add -m "Note on a tree" HEAD: &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes show HEAD: >actual &&
|
2010-02-13 22:28:21 +01:00
|
|
|
test_cmp expect actual &&
|
2014-11-12 01:40:16 +01:00
|
|
|
echo "Note on a blob" >expect &&
|
2010-02-13 22:28:21 +01:00
|
|
|
filename=$(git ls-tree --name-only HEAD | head -n1) &&
|
2010-02-13 22:28:32 +01:00
|
|
|
git notes add -m "Note on a blob" HEAD:$filename &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes show HEAD:$filename >actual &&
|
2010-02-13 22:28:21 +01:00
|
|
|
test_cmp expect actual &&
|
2014-11-12 01:40:16 +01:00
|
|
|
echo "Note on a tag" >expect &&
|
2010-02-13 22:28:21 +01:00
|
|
|
git tag -a -m "This is an annotated tag" foobar HEAD^ &&
|
2010-02-13 22:28:32 +01:00
|
|
|
git notes add -m "Note on a tag" foobar &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git notes show foobar >actual &&
|
2010-02-13 22:28:21 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'create note from other note with "git notes add -C"' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit fb01e0ca8c33b6cc0c6451dde747f97df567cb5c
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:19:13 2005 -0700
|
2010-02-13 22:28:36 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}7th
|
2010-02-13 22:28:36 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}order test
|
|
|
|
EOF
|
|
|
|
test_commit 7th &&
|
2010-02-13 22:28:36 +01:00
|
|
|
git notes add -C $(git notes list HEAD^) &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2010-02-13 22:28:36 +01:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'create note from non-existing note with "git notes add -C" fails' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_commit 8th &&
|
2010-02-13 22:28:36 +01:00
|
|
|
test_must_fail git notes add -C deadbeef &&
|
|
|
|
test_must_fail git notes list HEAD
|
|
|
|
'
|
|
|
|
|
2014-02-12 10:54:16 +01:00
|
|
|
test_expect_success 'create note from non-blob with "git notes add -C" fails' '
|
|
|
|
commit=$(git rev-parse --verify HEAD) &&
|
|
|
|
tree=$(git rev-parse --verify HEAD:) &&
|
|
|
|
test_must_fail git notes add -C $commit &&
|
|
|
|
test_must_fail git notes add -C $tree &&
|
|
|
|
test_must_fail git notes list HEAD
|
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'create note from blob with "git notes add -C" reuses blob id' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 9a4c31c7f722b5d517e92c64e932dd751e1413bf
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:20:13 2005 -0700
|
2014-02-12 10:54:16 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}8th
|
2014-02-12 10:54:16 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}This is a blob object
|
|
|
|
EOF
|
2014-02-12 10:54:16 +01:00
|
|
|
blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
|
|
|
|
git notes add -C $blob &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2014-02-12 10:54:16 +01:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test "$(git notes list HEAD)" = "$blob"
|
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'create note from other note with "git notes add -c"' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:21:13 2005 -0700
|
2010-02-13 22:28:36 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}9th
|
2010-02-13 22:28:36 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}yet another note
|
|
|
|
EOF
|
|
|
|
test_commit 9th &&
|
2010-02-13 22:28:36 +01:00
|
|
|
MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2010-02-13 22:28:36 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'create note from non-existing note with "git notes add -c" fails' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_commit 10th &&
|
2014-03-18 19:54:05 +01:00
|
|
|
test_must_fail env MSG="yet another note" git notes add -c deadbeef &&
|
2010-02-13 22:28:36 +01:00
|
|
|
test_must_fail git notes list HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'append to note from other note with "git notes append -C"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 2e0db4bc649e174d667a1cde19e725cf897a5bd2
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:21:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}9th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}yet another note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
|
|
|
EOF
|
2010-02-13 22:28:36 +01:00
|
|
|
git notes append -C $(git notes list HEAD^) HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 HEAD^ >actual &&
|
2010-02-13 22:28:36 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'create note from other note with "git notes append -c"' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:22:13 2005 -0700
|
2010-02-13 22:28:36 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}10th
|
2010-02-13 22:28:36 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}other note
|
|
|
|
EOF
|
2010-02-13 22:28:36 +01:00
|
|
|
MSG="other note" git notes append -c $(git notes list HEAD^) &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2010-02-13 22:28:36 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'append to note from other note with "git notes append -c"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 7c3b87ab368f81e11b1ea87b2ab99a71ccd25406
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:22:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}10th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}other note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
|
|
|
EOF
|
2010-02-13 22:28:36 +01:00
|
|
|
MSG="yet another note" git notes append -c $(git notes list HEAD) &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2010-02-13 22:28:36 +01:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2010-02-13 22:28:38 +01:00
|
|
|
test_expect_success 'copy note with "git notes copy"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:23:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}11th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}other note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
|
|
|
EOF
|
|
|
|
test_commit 11th &&
|
2010-02-13 22:28:38 +01:00
|
|
|
git notes copy HEAD^ HEAD &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2010-02-13 22:28:38 +01:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'prevent overwrite with "git notes copy"' '
|
|
|
|
test_must_fail git notes copy HEAD~2 HEAD &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2010-02-13 22:28:38 +01:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'allow overwrite with "git notes copy -f"' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit a446fff8777efdc6eb8f4b7c8a5ff699484df0d5
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:23:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}11th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}yet another note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
|
|
|
EOF
|
2010-02-13 22:28:38 +01:00
|
|
|
git notes copy -f HEAD~2 HEAD &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
2010-02-13 22:28:38 +01:00
|
|
|
test_cmp expect actual &&
|
|
|
|
test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'cannot copy note from object without notes' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_commit 12th &&
|
|
|
|
test_commit 13th &&
|
2010-02-13 22:28:38 +01:00
|
|
|
test_must_fail git notes copy HEAD^ HEAD
|
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'git notes copy --stdin' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit e871aa61182b1d95d0a6fb75445d891722863b6b
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:25:13 2005 -0700
|
2010-03-12 18:04:31 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}13th
|
2010-03-12 18:04:31 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}yet another note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
2010-03-12 18:04:31 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
commit 65e263ded02ae4e8839bc151095113737579dc12
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:24:13 2005 -0700
|
2010-03-12 18:04:31 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}12th
|
2010-03-12 18:04:31 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}other note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
|
|
|
EOF
|
2010-03-12 18:04:31 +01:00
|
|
|
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
|
|
|
|
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
|
|
|
|
git notes copy --stdin &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect actual &&
|
2010-03-12 18:04:31 +01:00
|
|
|
test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
|
|
|
|
test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
|
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:27:13 2005 -0700
|
2010-03-12 18:04:32 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}15th
|
2010-03-12 18:04:32 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
commit 07c85d77059393ed0154b8c96906547a59dfcddd
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:26:13 2005 -0700
|
2010-03-12 18:04:32 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}14th
|
|
|
|
EOF
|
2010-03-12 18:04:32 +01:00
|
|
|
test_commit 14th &&
|
|
|
|
test_commit 15th &&
|
|
|
|
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
|
|
|
|
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes copy --for-rewrite (enabled)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:27:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}15th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}yet another note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
|
|
|
|
|
|
|
commit 07c85d77059393ed0154b8c96906547a59dfcddd
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:26:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}14th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}other note
|
|
|
|
${indent}
|
|
|
|
${indent}yet another note
|
|
|
|
EOF
|
|
|
|
test_config notes.rewriteMode overwrite &&
|
|
|
|
test_config notes.rewriteRef "refs/notes/*" &&
|
2010-03-12 18:04:32 +01:00
|
|
|
(echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
|
|
|
|
echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes copy --for-rewrite (disabled)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewrite.bar false &&
|
2010-03-12 18:04:32 +01:00
|
|
|
echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
|
|
|
|
git notes copy --for-rewrite=bar &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -2 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'git notes copy --for-rewrite (overwrite)' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:27:13 2005 -0700
|
2010-03-12 18:04:32 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}15th
|
2010-03-12 18:04:32 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}a fresh note
|
|
|
|
EOF
|
2010-03-12 18:04:32 +01:00
|
|
|
git notes add -f -m"a fresh note" HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewriteMode overwrite &&
|
|
|
|
test_config notes.rewriteRef "refs/notes/*" &&
|
2010-03-12 18:04:32 +01:00
|
|
|
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes copy --for-rewrite (ignore)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewriteMode ignore &&
|
|
|
|
test_config notes.rewriteRef "refs/notes/*" &&
|
2010-03-12 18:04:32 +01:00
|
|
|
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes copy --for-rewrite (append)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:27:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}15th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}a fresh note
|
|
|
|
${indent}
|
|
|
|
${indent}another fresh note
|
|
|
|
EOF
|
2010-03-12 18:04:32 +01:00
|
|
|
git notes add -f -m"another fresh note" HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewriteMode concatenate &&
|
|
|
|
test_config notes.rewriteRef "refs/notes/*" &&
|
2010-03-12 18:04:32 +01:00
|
|
|
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes copy --for-rewrite (append two to one)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:27:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}15th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}a fresh note
|
|
|
|
${indent}
|
|
|
|
${indent}another fresh note
|
|
|
|
${indent}
|
|
|
|
${indent}append 1
|
|
|
|
${indent}
|
|
|
|
${indent}append 2
|
|
|
|
EOF
|
2010-03-12 18:04:32 +01:00
|
|
|
git notes add -f -m"append 1" HEAD^ &&
|
|
|
|
git notes add -f -m"append 2" HEAD^^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewriteMode concatenate &&
|
|
|
|
test_config notes.rewriteRef "refs/notes/*" &&
|
2010-03-12 18:04:32 +01:00
|
|
|
(echo $(git rev-parse HEAD^) $(git rev-parse HEAD);
|
|
|
|
echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes copy --for-rewrite (append empty)' '
|
|
|
|
git notes remove HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewriteMode concatenate &&
|
|
|
|
test_config notes.rewriteRef "refs/notes/*" &&
|
2010-03-12 18:04:32 +01:00
|
|
|
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:27:13 2005 -0700
|
|
|
|
|
|
|
|
${indent}15th
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
${indent}replacement note 1
|
|
|
|
EOF
|
|
|
|
test_config notes.rewriteMode concatenate &&
|
|
|
|
test_config notes.rewriteRef "refs/notes/*" &&
|
2010-03-12 18:04:32 +01:00
|
|
|
git notes add -f -m"replacement note 1" HEAD^ &&
|
|
|
|
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
|
|
|
|
GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
test_expect_success 'GIT_NOTES_REWRITE_REF works' '
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
commit 4acf42e847e7fffbbf89ee365c20ac7caf40de89
|
|
|
|
Author: A U Thor <author@example.com>
|
|
|
|
Date: Thu Apr 7 15:27:13 2005 -0700
|
2010-03-12 18:04:32 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
${indent}15th
|
2010-03-12 18:04:32 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
${indent}replacement note 2
|
|
|
|
EOF
|
2010-03-12 18:04:32 +01:00
|
|
|
git notes add -f -m"replacement note 2" HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewriteMode overwrite &&
|
|
|
|
test_unconfig notes.rewriteRef &&
|
2010-03-12 18:04:32 +01:00
|
|
|
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
|
|
|
|
GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
|
|
|
|
git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
|
|
|
|
git notes add -f -m"replacement note 3" HEAD^ &&
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config notes.rewriteMode overwrite &&
|
|
|
|
test_config notes.rewriteRef refs/notes/other &&
|
2010-03-12 18:04:32 +01:00
|
|
|
echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
|
|
|
|
GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
|
2014-11-12 01:40:16 +01:00
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
2010-03-12 18:04:32 +01:00
|
|
|
'
|
2010-06-28 10:59:07 +02:00
|
|
|
|
|
|
|
test_expect_success 'git notes copy diagnoses too many or too few parameters' '
|
|
|
|
test_must_fail git notes copy &&
|
|
|
|
test_must_fail git notes copy one two three
|
|
|
|
'
|
|
|
|
|
2015-09-23 00:15:03 +02:00
|
|
|
test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' '
|
|
|
|
test_unconfig core.notesRef &&
|
|
|
|
sane_unset GIT_NOTES_REF &&
|
|
|
|
test "$(git notes --ref=refs/heads/master get-ref)" = "refs/notes/refs/heads/master"
|
|
|
|
'
|
|
|
|
|
2010-11-09 22:49:57 +01:00
|
|
|
test_expect_success 'git notes get-ref (no overrides)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_unconfig core.notesRef &&
|
2011-01-06 01:30:02 +01:00
|
|
|
sane_unset GIT_NOTES_REF &&
|
2010-11-09 22:49:57 +01:00
|
|
|
test "$(git notes get-ref)" = "refs/notes/commits"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes get-ref (core.notesRef)' '
|
2014-11-12 01:40:16 +01:00
|
|
|
test_config core.notesRef refs/notes/foo &&
|
2010-11-09 22:49:57 +01:00
|
|
|
test "$(git notes get-ref)" = "refs/notes/foo"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes get-ref (GIT_NOTES_REF)' '
|
|
|
|
test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar"
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git notes get-ref (--ref)' '
|
|
|
|
test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"
|
|
|
|
'
|
|
|
|
|
2014-11-09 13:30:48 +01:00
|
|
|
test_expect_success 'setup testing of empty notes' '
|
|
|
|
test_unconfig core.notesRef &&
|
|
|
|
test_commit 16th &&
|
2014-11-12 01:40:14 +01:00
|
|
|
empty_blob=$(git hash-object -w /dev/null) &&
|
|
|
|
echo "$empty_blob" >expect_empty
|
2014-11-09 13:30:48 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
while read cmd
|
|
|
|
do
|
|
|
|
test_expect_success "'git notes $cmd' removes empty note" "
|
|
|
|
test_might_fail git notes remove HEAD &&
|
|
|
|
MSG= git notes $cmd &&
|
|
|
|
test_must_fail git notes list HEAD
|
|
|
|
"
|
2014-11-12 01:40:14 +01:00
|
|
|
|
|
|
|
test_expect_success "'git notes $cmd --allow-empty' stores empty note" "
|
|
|
|
test_might_fail git notes remove HEAD &&
|
|
|
|
MSG= git notes $cmd --allow-empty &&
|
|
|
|
git notes list HEAD >actual &&
|
|
|
|
test_cmp expect_empty actual
|
|
|
|
"
|
2014-11-09 13:30:48 +01:00
|
|
|
done <<\EOF
|
|
|
|
add
|
|
|
|
add -F /dev/null
|
|
|
|
add -m ""
|
|
|
|
add -c "$empty_blob"
|
|
|
|
add -C "$empty_blob"
|
|
|
|
append
|
|
|
|
append -F /dev/null
|
|
|
|
append -m ""
|
|
|
|
append -c "$empty_blob"
|
|
|
|
append -C "$empty_blob"
|
|
|
|
edit
|
|
|
|
EOF
|
|
|
|
|
2014-11-12 01:40:15 +01:00
|
|
|
test_expect_success 'empty notes are displayed by git log' '
|
|
|
|
test_commit 17th &&
|
|
|
|
git log -1 >expect &&
|
2014-11-12 01:40:16 +01:00
|
|
|
cat >>expect <<-EOF &&
|
2014-11-12 01:40:15 +01:00
|
|
|
|
2014-11-12 01:40:16 +01:00
|
|
|
Notes:
|
|
|
|
EOF
|
2014-11-12 01:40:15 +01:00
|
|
|
git notes add -C "$empty_blob" --allow-empty &&
|
|
|
|
git log -1 >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2009-10-09 12:21:58 +02:00
|
|
|
test_done
|