aboutsummaryrefslogtreecommitdiff
path: root/t/t3301-notes.sh
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2015-10-08 11:54:43 +0900
committerJunio C Hamano <gitster@pobox.com>2016-01-12 15:10:01 -0800
commitee76f92fe883305c1260952f5b325b0503311fc9 (patch)
tree6cea77bd1955070b9f56832d803ac0b70448f59f /t/t3301-notes.sh
parent754884255bb580df159e58defa81cdd30b5c430c (diff)
downloadgit-ee76f92fe883305c1260952f5b325b0503311fc9.tar.gz
git-ee76f92fe883305c1260952f5b325b0503311fc9.tar.xz
notes: allow treeish expressions as notes ref
init_notes() is the main point of entry to the notes API. It ensures that the input can be used as ref, because it needs a ref to update to store notes tree after modifying it. There however are many use cases where notes tree is only read, e.g. "git log --notes=...". Any notes-shaped treeish could be used for such purpose, but it is not allowed due to existing restriction. Allow treeish expressions to be used in the case the notes tree is going to be used without write "permissions". Add a flag to distinguish whether the notes tree is intended to be used read-only, or will be updated. With this change, operations that use notes read-only can be fed any notes-shaped tree-ish can be used, e.g. git log --notes=notes@{1}. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3301-notes.sh')
-rwxr-xr-xt/t3301-notes.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index cd70274ea..2d200fdf3 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -83,6 +83,16 @@ test_expect_success 'edit existing notes' '
test_must_fail git notes show HEAD^
'
+test_expect_success 'show notes from treeish' '
+ test "b3" = "$(git notes --ref commits^{tree} show)" &&
+ test "b4" = "$(git notes --ref commits@{1} show)"
+'
+
+test_expect_success 'cannot edit notes from non-ref' '
+ test_must_fail git notes --ref commits^{tree} edit &&
+ test_must_fail git notes --ref commits@{1} edit
+'
+
test_expect_success 'cannot "git notes add -m" where notes already exists' '
test_must_fail git notes add -m "b2" &&
test_path_is_missing .git/NOTES_EDITMSG &&