summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-14 14:25:39 -0700
committerJunio C Hamano <gitster@pobox.com>2014-03-14 14:25:39 -0700
commitb37f81b7b676fe7ede3fa171535593337a8911c8 (patch)
tree56a6ed44d2331628297494b92999ec8f0bf89d59 /t
parentc923f603ea9288a8d44da994d9d0b4aea220dc99 (diff)
parentce8daa1eb863c9cdefb06feae2ee7c742ea89847 (diff)
downloadgit-b37f81b7b676fe7ede3fa171535593337a8911c8.tar.gz
Merge branch 'jh/note-trees-record-blobs'
"git notes -C <blob>" should not take an object that is not a blob. * jh/note-trees-record-blobs: notes: disallow reusing non-blob as a note object
Diffstat (limited to 't')
-rwxr-xr-xt/t3301-notes.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 16de05aff9..3bb79a47af 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -812,6 +812,33 @@ test_expect_success 'create note from non-existing note with "git notes add -C"
test_must_fail git notes list HEAD
'
+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
+'
+
+cat > expect << EOF
+commit 80d796defacd5db327b7a4e50099663902fbdc5c
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:20:13 2005 -0700
+
+ 8th
+
+Notes (other):
+ This is a blob object
+EOF
+
+test_expect_success 'create note from blob with "git notes add -C" reuses blob id' '
+ blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
+ git notes add -C $blob &&
+ git log -1 > actual &&
+ test_cmp expect actual &&
+ test "$(git notes list HEAD)" = "$blob"
+'
+
cat > expect << EOF
commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
Author: A U Thor <author@example.com>