summaryrefslogtreecommitdiff
path: root/t/t3301-notes.sh
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2010-03-12 17:04:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-13 05:55:39 (GMT)
commit894a9d333e9e2015cad00d95250b7c5d3acea8b6 (patch)
tree2bab79483f959c7661e87ef70b1976ab9aa65bdb /t/t3301-notes.sh
parent6ceeaee7ea5bb754c76ce93c5b289f72d69fdb92 (diff)
downloadgit-894a9d333e9e2015cad00d95250b7c5d3acea8b6.zip
git-894a9d333e9e2015cad00d95250b7c5d3acea8b6.tar.gz
git-894a9d333e9e2015cad00d95250b7c5d3acea8b6.tar.bz2
Support showing notes from more than one notes tree
With this patch, you can set notes.displayRef to a glob that points at your favourite notes refs, e.g., [notes] displayRef = refs/notes/* Then git-log and friends will show notes from all trees. Thanks to Junio C Hamano for lots of feedback, which greatly influenced the design of the entire series and this commit in particular. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3301-notes.sh')
-rwxr-xr-xt/t3301-notes.sh148
1 files changed, 140 insertions, 8 deletions
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 90178f9..cb7166f 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -415,7 +415,7 @@ Date: Thu Apr 7 15:18:13 2005 -0700
6th
-Notes:
+Notes (other):
other note
EOF
@@ -448,7 +448,139 @@ test_expect_success 'Do not show note when core.notesRef is overridden' '
test_cmp expect-not-other output
'
+cat > expect-both << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:18:13 2005 -0700
+
+ 6th
+
+Notes:
+ order test
+
+Notes (other):
+ other note
+
+commit bd1753200303d0a0344be813e504253b3d98e74d
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:17:13 2005 -0700
+
+ 5th
+
+Notes:
+ replacement for deleted note
+EOF
+
+test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
+ 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" &&
+ git config --unset core.notesRef &&
+ git config notes.displayRef "refs/notes/*" &&
+ git log -2 > output &&
+ test_cmp expect-both output
+'
+
+test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
+ git config core.notesRef refs/notes/commits &&
+ git config notes.displayRef refs/notes/other &&
+ git log -2 > output &&
+ test_cmp expect-both output
+'
+
+test_expect_success 'notes.displayRef can be given more than once' '
+ git config --unset core.notesRef &&
+ git config notes.displayRef refs/notes/commits &&
+ git config --add notes.displayRef refs/notes/other &&
+ git log -2 > output &&
+ test_cmp expect-both output
+'
+
+cat > expect-both-reversed << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:18:13 2005 -0700
+
+ 6th
+
+Notes (other):
+ other note
+
+Notes:
+ order test
+EOF
+
+test_expect_success 'notes.displayRef respects order' '
+ git config core.notesRef refs/notes/other &&
+ git config --unset-all notes.displayRef &&
+ git config notes.displayRef refs/notes/commits &&
+ git log -1 > output &&
+ test_cmp expect-both-reversed output
+'
+
+test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
+ git config --unset-all core.notesRef &&
+ git config --unset-all notes.displayRef &&
+ GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
+ git log -2 > output &&
+ test_cmp expect-both output
+'
+
+cat > expect-none << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:18:13 2005 -0700
+
+ 6th
+
+commit bd1753200303d0a0344be813e504253b3d98e74d
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:17:13 2005 -0700
+
+ 5th
+EOF
+
+test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
+ git config notes.displayRef "refs/notes/*" &&
+ GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output &&
+ test_cmp expect-none output
+'
+
+test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
+ GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output &&
+ test_cmp expect-both output
+'
+
+cat > expect-commits << EOF
+commit 387a89921c73d7ed72cd94d179c1c7048ca47756
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:18:13 2005 -0700
+
+ 6th
+
+Notes:
+ order test
+EOF
+
+test_expect_success '--no-standard-notes' '
+ git log --no-standard-notes --show-notes=commits -1 > output &&
+ test_cmp expect-commits output
+'
+
+test_expect_success '--standard-notes' '
+ git log --no-standard-notes --show-notes=commits \
+ --standard-notes -2 > output &&
+ test_cmp expect-both output
+'
+
+test_expect_success '--show-notes=ref accumulates' '
+ git log --show-notes=other --show-notes=commits \
+ --no-standard-notes -1 > output &&
+ test_cmp expect-both-reversed output
+'
+
test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
+ git config core.notesRef refs/notes/other &&
echo "Note on a tree" > expect
git notes add -m "Note on a tree" HEAD: &&
git notes show HEAD: > actual &&
@@ -472,7 +604,7 @@ Date: Thu Apr 7 15:19:13 2005 -0700
7th
-Notes:
+Notes (other):
other note
EOF
@@ -503,7 +635,7 @@ Date: Thu Apr 7 15:21:13 2005 -0700
9th
-Notes:
+Notes (other):
yet another note
EOF
@@ -533,7 +665,7 @@ Date: Thu Apr 7 15:21:13 2005 -0700
9th
-Notes:
+Notes (other):
yet another note
$whitespace
yet another note
@@ -552,7 +684,7 @@ Date: Thu Apr 7 15:22:13 2005 -0700
10th
-Notes:
+Notes (other):
other note
EOF
@@ -569,7 +701,7 @@ Date: Thu Apr 7 15:22:13 2005 -0700
10th
-Notes:
+Notes (other):
other note
$whitespace
yet another note
@@ -588,7 +720,7 @@ Date: Thu Apr 7 15:23:13 2005 -0700
11th
-Notes:
+Notes (other):
other note
$whitespace
yet another note
@@ -619,7 +751,7 @@ Date: Thu Apr 7 15:23:13 2005 -0700
11th
-Notes:
+Notes (other):
yet another note
$whitespace
yet another note