3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test commit notes'
10 cat > fake_editor.sh << \EOF
15 chmod a+x fake_editor.sh
16 GIT_EDITOR=./fake_editor.sh
19 test_expect_success 'cannot annotate non-existing HEAD' '
20 (MSG=3 && export MSG && test_must_fail git notes add)
23 test_expect_success setup '
34 test_expect_success 'need valid notes ref' '
35 (MSG=1 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
36 test_must_fail git notes add) &&
37 (MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
38 test_must_fail git notes show)
41 test_expect_success 'refusing to add notes in refs/heads/' '
42 (MSG=1 GIT_NOTES_REF=refs/heads/bogus &&
43 export MSG GIT_NOTES_REF &&
44 test_must_fail git notes add)
47 test_expect_success 'refusing to edit notes in refs/remotes/' '
48 (MSG=1 GIT_NOTES_REF=refs/remotes/bogus &&
49 export MSG GIT_NOTES_REF &&
50 test_must_fail git notes edit)
53 # 1 indicates caught gracefully by die, 128 means git-show barked
54 test_expect_success 'handle empty notes gracefully' '
55 test_expect_code 1 git notes show
58 test_expect_success 'show non-existent notes entry with %N' '
63 git show -s --format='A%n%NB' >output &&
64 test_cmp expect output
67 test_expect_success 'create notes' '
68 git config core.notesRef refs/notes/commits &&
69 MSG=b4 git notes add &&
70 test ! -f .git/NOTES_EDITMSG &&
71 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
72 test b4 = $(git notes show) &&
74 test_must_fail git notes show HEAD^
77 test_expect_success 'show notes entry with %N' '
82 git show -s --format='A%n%NB' >output &&
83 test_cmp expect output
87 d423f8c refs/notes/commits@{0}: notes: Notes added by 'git notes add'
90 test_expect_success 'create reflog entry' '
91 git reflog show refs/notes/commits >output &&
92 test_cmp expect output
95 test_expect_success 'edit existing notes' '
96 MSG=b3 git notes edit &&
97 test ! -f .git/NOTES_EDITMSG &&
98 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
99 test b3 = $(git notes show) &&
101 test_must_fail git notes show HEAD^
104 test_expect_success 'cannot add note where one exists' '
105 ! MSG=b2 git notes add &&
106 test ! -f .git/NOTES_EDITMSG &&
107 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
108 test b3 = $(git notes show) &&
110 test_must_fail git notes show HEAD^
113 test_expect_success 'can overwrite existing note with "git notes add -f"' '
114 MSG=b1 git notes add -f &&
115 test ! -f .git/NOTES_EDITMSG &&
116 test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
117 test b1 = $(git notes show) &&
119 test_must_fail git notes show HEAD^
123 commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
124 Author: A U Thor <author@example.com>
125 Date: Thu Apr 7 15:14:13 2005 -0700
133 test_expect_success 'show notes' '
134 ! (git cat-file commit HEAD | grep b1) &&
135 git log -1 > output &&
136 test_cmp expect output
139 test_expect_success 'create multi-line notes (setup)' '
146 d3d3d3" git notes add
149 cat > expect-multiline << EOF
150 commit 1584215f1d29c65e99c6c6848626553fdd07fd75
151 Author: A U Thor <author@example.com>
152 Date: Thu Apr 7 15:15:13 2005 -0700
162 printf "\n" >> expect-multiline
163 cat expect >> expect-multiline
165 test_expect_success 'show multi-line notes' '
166 git log -2 > output &&
167 test_cmp expect-multiline output
169 test_expect_success 'create -F notes (setup)' '
174 echo "xyzzy" > note5 &&
175 git notes add -F note5
178 cat > expect-F << EOF
179 commit 15023535574ded8b1a89052b32673f84cf9582b8
180 Author: A U Thor <author@example.com>
181 Date: Thu Apr 7 15:16:13 2005 -0700
189 printf "\n" >> expect-F
190 cat expect-multiline >> expect-F
192 test_expect_success 'show -F notes' '
193 git log -3 > output &&
194 test_cmp expect-F output
198 commit 15023535574ded8b1a89052b32673f84cf9582b8
199 tree e070e3af51011e47b183c33adf9736736a525709
200 parent 1584215f1d29c65e99c6c6848626553fdd07fd75
201 author A U Thor <author@example.com> 1112912173 -0700
202 committer C O Mitter <committer@example.com> 1112912173 -0700
206 test_expect_success 'git log --pretty=raw does not show notes' '
207 git log -1 --pretty=raw >output &&
208 test_cmp expect output
216 test_expect_success 'git log --show-notes' '
217 git log -1 --pretty=raw --show-notes >output &&
218 test_cmp expect output
221 test_expect_success 'git log --no-notes' '
222 git log -1 --no-notes >output &&
226 test_expect_success 'git format-patch does not show notes' '
227 git format-patch -1 --stdout >output &&
231 test_expect_success 'git format-patch --show-notes does show notes' '
232 git format-patch --show-notes -1 --stdout >output &&
237 "" --pretty --pretty=raw --pretty=short --pretty=medium \
238 --pretty=full --pretty=fuller --pretty=format:%s --oneline
241 "") p= not= negate="" ;;
242 ?*) p="$pretty" not=" not" negate="!" ;;
244 test_expect_success "git show $pretty does$not show notes" '
245 git show $p >output &&
246 eval "$negate grep xyzzy output"
250 test_expect_success 'setup alternate notes ref' '
251 git notes --ref=alternate add -m alternate
254 test_expect_success 'git log --notes shows default notes' '
255 git log -1 --notes >output &&
257 ! grep alternate output
260 test_expect_success 'git log --notes=X shows only X' '
261 git log -1 --notes=alternate >output &&
262 ! grep xyzzy output &&
263 grep alternate output
266 test_expect_success 'git log --notes --notes=X shows both' '
267 git log -1 --notes --notes=alternate >output &&
269 grep alternate output
272 test_expect_success 'create -m notes (setup)' '
277 git notes add -m spam -m "foo
283 cat > expect-m << EOF
284 commit bd1753200303d0a0344be813e504253b3d98e74d
285 Author: A U Thor <author@example.com>
286 Date: Thu Apr 7 15:17:13 2005 -0700
298 printf "\n" >> expect-m
299 cat expect-F >> expect-m
301 test_expect_success 'show -m notes' '
302 git log -4 > output &&
303 test_cmp expect-m output
306 test_expect_success 'remove note with add -f -F /dev/null (setup)' '
307 git notes add -f -F /dev/null
310 cat > expect-rm-F << EOF
311 commit bd1753200303d0a0344be813e504253b3d98e74d
312 Author: A U Thor <author@example.com>
313 Date: Thu Apr 7 15:17:13 2005 -0700
318 printf "\n" >> expect-rm-F
319 cat expect-F >> expect-rm-F
321 test_expect_success 'verify note removal with -F /dev/null' '
322 git log -4 > output &&
323 test_cmp expect-rm-F output &&
324 test_must_fail git notes show
327 test_expect_success 'do not create empty note with -m "" (setup)' '
331 test_expect_success 'verify non-creation of note with -m ""' '
332 git log -4 > output &&
333 test_cmp expect-rm-F output &&
334 test_must_fail git notes show
337 cat > expect-combine_m_and_F << EOF
349 test_expect_success 'create note with combination of -m and -F' '
350 echo "xyzzy" > note_a &&
351 echo "zyxxy" > note_b &&
352 git notes add -m "foo" -F note_a -m "bar" -F note_b -m "baz" &&
353 git notes show > output &&
354 test_cmp expect-combine_m_and_F output
357 test_expect_success 'remove note with "git notes remove" (setup)' '
358 git notes remove HEAD^ &&
362 cat > expect-rm-remove << EOF
363 commit bd1753200303d0a0344be813e504253b3d98e74d
364 Author: A U Thor <author@example.com>
365 Date: Thu Apr 7 15:17:13 2005 -0700
369 commit 15023535574ded8b1a89052b32673f84cf9582b8
370 Author: A U Thor <author@example.com>
371 Date: Thu Apr 7 15:16:13 2005 -0700
376 printf "\n" >> expect-rm-remove
377 cat expect-multiline >> expect-rm-remove
379 test_expect_success 'verify note removal with "git notes remove"' '
380 git log -4 > output &&
381 test_cmp expect-rm-remove output &&
382 test_must_fail git notes show HEAD^
386 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
387 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
390 test_expect_success 'removing non-existing note should not create new commit' '
391 git rev-parse --verify refs/notes/commits > before_commit &&
392 test_must_fail git notes remove HEAD^ &&
393 git rev-parse --verify refs/notes/commits > after_commit &&
394 test_cmp before_commit after_commit
397 test_expect_success 'list notes with "git notes list"' '
398 git notes list > output &&
399 test_cmp expect output
402 test_expect_success 'list notes with "git notes"' '
403 git notes > output &&
404 test_cmp expect output
408 c18dc024e14f08d18d14eea0d747ff692d66d6a3
411 test_expect_success 'list specific note with "git notes list <object>"' '
412 git notes list HEAD^^ > output &&
413 test_cmp expect output
419 test_expect_success 'listing non-existing notes fails' '
420 test_must_fail git notes list HEAD > output &&
421 test_cmp expect output
427 More notes appended with git notes append
430 test_expect_success 'append to existing note with "git notes append"' '
431 git notes add -m "Initial set of notes" &&
432 git notes append -m "More notes appended with git notes append" &&
433 git notes show > output &&
434 test_cmp expect output
437 cat > expect_list << EOF
438 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
439 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
440 4b6ad22357cc8a1296720574b8d2fbc22fab0671 bd1753200303d0a0344be813e504253b3d98e74d
443 test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
444 git notes list > output &&
445 test_cmp expect_list output
448 test_expect_success 'appending empty string does not change existing note' '
449 git notes append -m "" &&
450 git notes show > output &&
451 test_cmp expect output
454 test_expect_success 'git notes append == add when there is no existing note' '
455 git notes remove HEAD &&
456 test_must_fail git notes list HEAD &&
457 git notes append -m "Initial set of notes
459 More notes appended with git notes append" &&
460 git notes show > output &&
461 test_cmp expect output
464 test_expect_success 'appending empty string to non-existing note does not create note' '
465 git notes remove HEAD &&
466 test_must_fail git notes list HEAD &&
467 git notes append -m "" &&
468 test_must_fail git notes list HEAD
471 test_expect_success 'create other note on a different notes ref (setup)' '
476 GIT_NOTES_REF="refs/notes/other" git notes add -m "other note"
479 cat > expect-other << EOF
480 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
481 Author: A U Thor <author@example.com>
482 Date: Thu Apr 7 15:18:13 2005 -0700
490 cat > expect-not-other << EOF
491 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
492 Author: A U Thor <author@example.com>
493 Date: Thu Apr 7 15:18:13 2005 -0700
498 test_expect_success 'Do not show note on other ref by default' '
499 git log -1 > output &&
500 test_cmp expect-not-other output
503 test_expect_success 'Do show note when ref is given in GIT_NOTES_REF' '
504 GIT_NOTES_REF="refs/notes/other" git log -1 > output &&
505 test_cmp expect-other output
508 test_expect_success 'Do show note when ref is given in core.notesRef config' '
509 git config core.notesRef "refs/notes/other" &&
510 git log -1 > output &&
511 test_cmp expect-other output
514 test_expect_success 'Do not show note when core.notesRef is overridden' '
515 GIT_NOTES_REF="refs/notes/wrong" git log -1 > output &&
516 test_cmp expect-not-other output
519 cat > expect-both << EOF
520 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
521 Author: A U Thor <author@example.com>
522 Date: Thu Apr 7 15:18:13 2005 -0700
532 commit bd1753200303d0a0344be813e504253b3d98e74d
533 Author: A U Thor <author@example.com>
534 Date: Thu Apr 7 15:17:13 2005 -0700
539 replacement for deleted note
542 test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
543 GIT_NOTES_REF=refs/notes/commits git notes add \
544 -m"replacement for deleted note" HEAD^ &&
545 GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
546 git config --unset core.notesRef &&
547 git config notes.displayRef "refs/notes/*" &&
548 git log -2 > output &&
549 test_cmp expect-both output
552 test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
553 git config core.notesRef refs/notes/commits &&
554 git config notes.displayRef refs/notes/other &&
555 git log -2 > output &&
556 test_cmp expect-both output
559 test_expect_success 'notes.displayRef can be given more than once' '
560 git config --unset core.notesRef &&
561 git config notes.displayRef refs/notes/commits &&
562 git config --add notes.displayRef refs/notes/other &&
563 git log -2 > output &&
564 test_cmp expect-both output
567 cat > expect-both-reversed << EOF
568 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
569 Author: A U Thor <author@example.com>
570 Date: Thu Apr 7 15:18:13 2005 -0700
581 test_expect_success 'notes.displayRef respects order' '
582 git config core.notesRef refs/notes/other &&
583 git config --unset-all notes.displayRef &&
584 git config notes.displayRef refs/notes/commits &&
585 git log -1 > output &&
586 test_cmp expect-both-reversed output
589 test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
590 git config --unset-all core.notesRef &&
591 git config --unset-all notes.displayRef &&
592 GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
593 git log -2 > output &&
594 test_cmp expect-both output
597 cat > expect-none << EOF
598 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
599 Author: A U Thor <author@example.com>
600 Date: Thu Apr 7 15:18:13 2005 -0700
604 commit bd1753200303d0a0344be813e504253b3d98e74d
605 Author: A U Thor <author@example.com>
606 Date: Thu Apr 7 15:17:13 2005 -0700
611 test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
612 git config notes.displayRef "refs/notes/*" &&
613 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output &&
614 test_cmp expect-none output
617 test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
618 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output &&
619 test_cmp expect-both output
622 cat > expect-commits << EOF
623 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
624 Author: A U Thor <author@example.com>
625 Date: Thu Apr 7 15:18:13 2005 -0700
633 test_expect_success '--no-standard-notes' '
634 git log --no-standard-notes --show-notes=commits -1 > output &&
635 test_cmp expect-commits output
638 test_expect_success '--standard-notes' '
639 git log --no-standard-notes --show-notes=commits \
640 --standard-notes -2 > output &&
641 test_cmp expect-both output
644 test_expect_success '--show-notes=ref accumulates' '
645 git log --show-notes=other --show-notes=commits \
646 --no-standard-notes -1 > output &&
647 test_cmp expect-both-reversed output
650 test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
651 git config core.notesRef refs/notes/other &&
652 echo "Note on a tree" > expect &&
653 git notes add -m "Note on a tree" HEAD: &&
654 git notes show HEAD: > actual &&
655 test_cmp expect actual &&
656 echo "Note on a blob" > expect &&
657 filename=$(git ls-tree --name-only HEAD | head -n1) &&
658 git notes add -m "Note on a blob" HEAD:$filename &&
659 git notes show HEAD:$filename > actual &&
660 test_cmp expect actual &&
661 echo "Note on a tag" > expect &&
662 git tag -a -m "This is an annotated tag" foobar HEAD^ &&
663 git notes add -m "Note on a tag" foobar &&
664 git notes show foobar > actual &&
665 test_cmp expect actual
669 commit 2ede89468182a62d0bde2583c736089bcf7d7e92
670 Author: A U Thor <author@example.com>
671 Date: Thu Apr 7 15:19:13 2005 -0700
679 test_expect_success 'create note from other note with "git notes add -C"' '
684 git notes add -C $(git notes list HEAD^) &&
685 git log -1 > actual &&
686 test_cmp expect actual &&
687 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
690 test_expect_success 'create note from non-existing note with "git notes add -C" fails' '
695 test_must_fail git notes add -C deadbeef &&
696 test_must_fail git notes list HEAD
700 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
701 Author: A U Thor <author@example.com>
702 Date: Thu Apr 7 15:21:13 2005 -0700
710 test_expect_success 'create note from other note with "git notes add -c"' '
715 MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
716 git log -1 > actual &&
717 test_cmp expect actual
720 test_expect_success 'create note from non-existing note with "git notes add -c" fails' '
724 git commit -m 10th &&
726 MSG="yet another note" &&
728 test_must_fail git notes add -c deadbeef
730 test_must_fail git notes list HEAD
734 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
735 Author: A U Thor <author@example.com>
736 Date: Thu Apr 7 15:21:13 2005 -0700
746 test_expect_success 'append to note from other note with "git notes append -C"' '
747 git notes append -C $(git notes list HEAD^) HEAD^ &&
748 git log -1 HEAD^ > actual &&
749 test_cmp expect actual
753 commit ffed603236bfa3891c49644257a83598afe8ae5a
754 Author: A U Thor <author@example.com>
755 Date: Thu Apr 7 15:22:13 2005 -0700
763 test_expect_success 'create note from other note with "git notes append -c"' '
764 MSG="other note" git notes append -c $(git notes list HEAD^) &&
765 git log -1 > actual &&
766 test_cmp expect actual
770 commit ffed603236bfa3891c49644257a83598afe8ae5a
771 Author: A U Thor <author@example.com>
772 Date: Thu Apr 7 15:22:13 2005 -0700
782 test_expect_success 'append to note from other note with "git notes append -c"' '
783 MSG="yet another note" git notes append -c $(git notes list HEAD) &&
784 git log -1 > actual &&
785 test_cmp expect actual
789 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
790 Author: A U Thor <author@example.com>
791 Date: Thu Apr 7 15:23:13 2005 -0700
801 test_expect_success 'copy note with "git notes copy"' '
805 git commit -m 11th &&
806 git notes copy HEAD^ HEAD &&
807 git log -1 > actual &&
808 test_cmp expect actual &&
809 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
812 test_expect_success 'prevent overwrite with "git notes copy"' '
813 test_must_fail git notes copy HEAD~2 HEAD &&
814 git log -1 > actual &&
815 test_cmp expect actual &&
816 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
820 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
821 Author: A U Thor <author@example.com>
822 Date: Thu Apr 7 15:23:13 2005 -0700
832 test_expect_success 'allow overwrite with "git notes copy -f"' '
833 git notes copy -f HEAD~2 HEAD &&
834 git log -1 > actual &&
835 test_cmp expect actual &&
836 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
839 test_expect_success 'cannot copy note from object without notes' '
843 git commit -m 12th &&
847 git commit -m 13th &&
848 test_must_fail git notes copy HEAD^ HEAD
852 commit e5d4fb5698d564ab8c73551538ecaf2b0c666185
853 Author: A U Thor <author@example.com>
854 Date: Thu Apr 7 15:25:13 2005 -0700
863 commit 7038787dfe22a14c3867ce816dbba39845359719
864 Author: A U Thor <author@example.com>
865 Date: Thu Apr 7 15:24:13 2005 -0700
875 test_expect_success 'git notes copy --stdin' '
876 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
877 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
878 git notes copy --stdin &&
879 git log -2 > output &&
880 test_cmp expect output &&
881 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
882 test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
886 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
887 Author: A U Thor <author@example.com>
888 Date: Thu Apr 7 15:27:13 2005 -0700
892 commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
893 Author: A U Thor <author@example.com>
894 Date: Thu Apr 7 15:26:13 2005 -0700
899 test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
902 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
903 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
904 git notes copy --for-rewrite=foo &&
905 git log -2 > output &&
906 test_cmp expect output
910 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
911 Author: A U Thor <author@example.com>
912 Date: Thu Apr 7 15:27:13 2005 -0700
921 commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
922 Author: A U Thor <author@example.com>
923 Date: Thu Apr 7 15:26:13 2005 -0700
933 test_expect_success 'git notes copy --for-rewrite (enabled)' '
934 git config notes.rewriteMode overwrite &&
935 git config notes.rewriteRef "refs/notes/*" &&
936 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
937 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
938 git notes copy --for-rewrite=foo &&
939 git log -2 > output &&
940 test_cmp expect output
943 test_expect_success 'git notes copy --for-rewrite (disabled)' '
944 git config notes.rewrite.bar false &&
945 echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
946 git notes copy --for-rewrite=bar &&
947 git log -2 > output &&
948 test_cmp expect output
952 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
953 Author: A U Thor <author@example.com>
954 Date: Thu Apr 7 15:27:13 2005 -0700
962 test_expect_success 'git notes copy --for-rewrite (overwrite)' '
963 git notes add -f -m"a fresh note" HEAD^ &&
964 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
965 git notes copy --for-rewrite=foo &&
966 git log -1 > output &&
967 test_cmp expect output
970 test_expect_success 'git notes copy --for-rewrite (ignore)' '
971 git config notes.rewriteMode ignore &&
972 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
973 git notes copy --for-rewrite=foo &&
974 git log -1 > output &&
975 test_cmp expect output
979 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
980 Author: A U Thor <author@example.com>
981 Date: Thu Apr 7 15:27:13 2005 -0700
991 test_expect_success 'git notes copy --for-rewrite (append)' '
992 git notes add -f -m"another fresh note" HEAD^ &&
993 git config notes.rewriteMode concatenate &&
994 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
995 git notes copy --for-rewrite=foo &&
996 git log -1 > output &&
997 test_cmp expect output
1001 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1002 Author: A U Thor <author@example.com>
1003 Date: Thu Apr 7 15:27:13 2005 -0700
1017 test_expect_success 'git notes copy --for-rewrite (append two to one)' '
1018 git notes add -f -m"append 1" HEAD^ &&
1019 git notes add -f -m"append 2" HEAD^^ &&
1020 (echo $(git rev-parse HEAD^) $(git rev-parse HEAD);
1021 echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
1022 git notes copy --for-rewrite=foo &&
1023 git log -1 > output &&
1024 test_cmp expect output
1027 test_expect_success 'git notes copy --for-rewrite (append empty)' '
1028 git notes remove HEAD^ &&
1029 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1030 git notes copy --for-rewrite=foo &&
1031 git log -1 > output &&
1032 test_cmp expect output
1036 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1037 Author: A U Thor <author@example.com>
1038 Date: Thu Apr 7 15:27:13 2005 -0700
1046 test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
1047 git notes add -f -m"replacement note 1" HEAD^ &&
1048 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1049 GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
1050 git log -1 > output &&
1051 test_cmp expect output
1055 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1056 Author: A U Thor <author@example.com>
1057 Date: Thu Apr 7 15:27:13 2005 -0700
1065 test_expect_success 'GIT_NOTES_REWRITE_REF works' '
1066 git config notes.rewriteMode overwrite &&
1067 git notes add -f -m"replacement note 2" HEAD^ &&
1068 git config --unset-all notes.rewriteRef &&
1069 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1070 GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
1071 git notes copy --for-rewrite=foo &&
1072 git log -1 > output &&
1073 test_cmp expect output
1076 test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
1077 git config notes.rewriteRef refs/notes/other &&
1078 git notes add -f -m"replacement note 3" HEAD^ &&
1079 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1080 GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
1081 git log -1 > output &&
1082 test_cmp expect output
1085 test_expect_success 'git notes copy diagnoses too many or too few parameters' '
1086 test_must_fail git notes copy &&
1087 test_must_fail git notes copy one two three
1090 test_expect_success 'git notes get-ref (no overrides)' '
1091 git config --unset core.notesRef &&
1092 sane_unset GIT_NOTES_REF &&
1093 test "$(git notes get-ref)" = "refs/notes/commits"
1096 test_expect_success 'git notes get-ref (core.notesRef)' '
1097 git config core.notesRef refs/notes/foo &&
1098 test "$(git notes get-ref)" = "refs/notes/foo"
1101 test_expect_success 'git notes get-ref (GIT_NOTES_REF)' '
1102 test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar"
1105 test_expect_success 'git notes get-ref (--ref)' '
1106 test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"