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 'git log --no-notes resets default state' '
273 git log -1 --notes --notes=alternate \
274 --no-notes --notes=alternate \
276 ! grep xyzzy output &&
277 grep alternate output
280 test_expect_success 'git log --no-notes resets ref list' '
281 git log -1 --notes --notes=alternate \
285 ! grep alternate output
288 test_expect_success 'create -m notes (setup)' '
293 git notes add -m spam -m "foo
299 cat > expect-m << EOF
300 commit bd1753200303d0a0344be813e504253b3d98e74d
301 Author: A U Thor <author@example.com>
302 Date: Thu Apr 7 15:17:13 2005 -0700
314 printf "\n" >> expect-m
315 cat expect-F >> expect-m
317 test_expect_success 'show -m notes' '
318 git log -4 > output &&
319 test_cmp expect-m output
322 test_expect_success 'remove note with add -f -F /dev/null (setup)' '
323 git notes add -f -F /dev/null
326 cat > expect-rm-F << EOF
327 commit bd1753200303d0a0344be813e504253b3d98e74d
328 Author: A U Thor <author@example.com>
329 Date: Thu Apr 7 15:17:13 2005 -0700
334 printf "\n" >> expect-rm-F
335 cat expect-F >> expect-rm-F
337 test_expect_success 'verify note removal with -F /dev/null' '
338 git log -4 > output &&
339 test_cmp expect-rm-F output &&
340 test_must_fail git notes show
343 test_expect_success 'do not create empty note with -m "" (setup)' '
347 test_expect_success 'verify non-creation of note with -m ""' '
348 git log -4 > output &&
349 test_cmp expect-rm-F output &&
350 test_must_fail git notes show
353 cat > expect-combine_m_and_F << EOF
365 test_expect_success 'create note with combination of -m and -F' '
366 echo "xyzzy" > note_a &&
367 echo "zyxxy" > note_b &&
368 git notes add -m "foo" -F note_a -m "bar" -F note_b -m "baz" &&
369 git notes show > output &&
370 test_cmp expect-combine_m_and_F output
373 test_expect_success 'remove note with "git notes remove" (setup)' '
374 git notes remove HEAD^ &&
378 cat > expect-rm-remove << EOF
379 commit bd1753200303d0a0344be813e504253b3d98e74d
380 Author: A U Thor <author@example.com>
381 Date: Thu Apr 7 15:17:13 2005 -0700
385 commit 15023535574ded8b1a89052b32673f84cf9582b8
386 Author: A U Thor <author@example.com>
387 Date: Thu Apr 7 15:16:13 2005 -0700
392 printf "\n" >> expect-rm-remove
393 cat expect-multiline >> expect-rm-remove
395 test_expect_success 'verify note removal with "git notes remove"' '
396 git log -4 > output &&
397 test_cmp expect-rm-remove output &&
398 test_must_fail git notes show HEAD^
402 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
403 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
406 test_expect_success 'removing non-existing note should not create new commit' '
407 git rev-parse --verify refs/notes/commits > before_commit &&
408 test_must_fail git notes remove HEAD^ &&
409 git rev-parse --verify refs/notes/commits > after_commit &&
410 test_cmp before_commit after_commit
413 test_expect_success 'list notes with "git notes list"' '
414 git notes list > output &&
415 test_cmp expect output
418 test_expect_success 'list notes with "git notes"' '
419 git notes > output &&
420 test_cmp expect output
424 c18dc024e14f08d18d14eea0d747ff692d66d6a3
427 test_expect_success 'list specific note with "git notes list <object>"' '
428 git notes list HEAD^^ > output &&
429 test_cmp expect output
435 test_expect_success 'listing non-existing notes fails' '
436 test_must_fail git notes list HEAD > output &&
437 test_cmp expect output
443 More notes appended with git notes append
446 test_expect_success 'append to existing note with "git notes append"' '
447 git notes add -m "Initial set of notes" &&
448 git notes append -m "More notes appended with git notes append" &&
449 git notes show > output &&
450 test_cmp expect output
453 cat > expect_list << EOF
454 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
455 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
456 4b6ad22357cc8a1296720574b8d2fbc22fab0671 bd1753200303d0a0344be813e504253b3d98e74d
459 test_expect_success '"git notes list" does not expand to "git notes list HEAD"' '
460 git notes list > output &&
461 test_cmp expect_list output
464 test_expect_success 'appending empty string does not change existing note' '
465 git notes append -m "" &&
466 git notes show > output &&
467 test_cmp expect output
470 test_expect_success 'git notes append == add when there is no existing note' '
471 git notes remove HEAD &&
472 test_must_fail git notes list HEAD &&
473 git notes append -m "Initial set of notes
475 More notes appended with git notes append" &&
476 git notes show > output &&
477 test_cmp expect output
480 test_expect_success 'appending empty string to non-existing note does not create note' '
481 git notes remove HEAD &&
482 test_must_fail git notes list HEAD &&
483 git notes append -m "" &&
484 test_must_fail git notes list HEAD
487 test_expect_success 'create other note on a different notes ref (setup)' '
492 GIT_NOTES_REF="refs/notes/other" git notes add -m "other note"
495 cat > expect-other << EOF
496 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
497 Author: A U Thor <author@example.com>
498 Date: Thu Apr 7 15:18:13 2005 -0700
506 cat > expect-not-other << EOF
507 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
508 Author: A U Thor <author@example.com>
509 Date: Thu Apr 7 15:18:13 2005 -0700
514 test_expect_success 'Do not show note on other ref by default' '
515 git log -1 > output &&
516 test_cmp expect-not-other output
519 test_expect_success 'Do show note when ref is given in GIT_NOTES_REF' '
520 GIT_NOTES_REF="refs/notes/other" git log -1 > output &&
521 test_cmp expect-other output
524 test_expect_success 'Do show note when ref is given in core.notesRef config' '
525 git config core.notesRef "refs/notes/other" &&
526 git log -1 > output &&
527 test_cmp expect-other output
530 test_expect_success 'Do not show note when core.notesRef is overridden' '
531 GIT_NOTES_REF="refs/notes/wrong" git log -1 > output &&
532 test_cmp expect-not-other output
535 cat > expect-both << EOF
536 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
537 Author: A U Thor <author@example.com>
538 Date: Thu Apr 7 15:18:13 2005 -0700
548 commit bd1753200303d0a0344be813e504253b3d98e74d
549 Author: A U Thor <author@example.com>
550 Date: Thu Apr 7 15:17:13 2005 -0700
555 replacement for deleted note
558 test_expect_success 'Show all notes when notes.displayRef=refs/notes/*' '
559 GIT_NOTES_REF=refs/notes/commits git notes add \
560 -m"replacement for deleted note" HEAD^ &&
561 GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
562 git config --unset core.notesRef &&
563 git config notes.displayRef "refs/notes/*" &&
564 git log -2 > output &&
565 test_cmp expect-both output
568 test_expect_success 'core.notesRef is implicitly in notes.displayRef' '
569 git config core.notesRef refs/notes/commits &&
570 git config notes.displayRef refs/notes/other &&
571 git log -2 > output &&
572 test_cmp expect-both output
575 test_expect_success 'notes.displayRef can be given more than once' '
576 git config --unset core.notesRef &&
577 git config notes.displayRef refs/notes/commits &&
578 git config --add notes.displayRef refs/notes/other &&
579 git log -2 > output &&
580 test_cmp expect-both output
583 cat > expect-both-reversed << EOF
584 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
585 Author: A U Thor <author@example.com>
586 Date: Thu Apr 7 15:18:13 2005 -0700
597 test_expect_success 'notes.displayRef respects order' '
598 git config core.notesRef refs/notes/other &&
599 git config --unset-all notes.displayRef &&
600 git config notes.displayRef refs/notes/commits &&
601 git log -1 > output &&
602 test_cmp expect-both-reversed output
605 test_expect_success 'GIT_NOTES_DISPLAY_REF works' '
606 git config --unset-all core.notesRef &&
607 git config --unset-all notes.displayRef &&
608 GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
609 git log -2 > output &&
610 test_cmp expect-both output
613 cat > expect-none << EOF
614 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
615 Author: A U Thor <author@example.com>
616 Date: Thu Apr 7 15:18:13 2005 -0700
620 commit bd1753200303d0a0344be813e504253b3d98e74d
621 Author: A U Thor <author@example.com>
622 Date: Thu Apr 7 15:17:13 2005 -0700
627 test_expect_success 'GIT_NOTES_DISPLAY_REF overrides config' '
628 git config notes.displayRef "refs/notes/*" &&
629 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output &&
630 test_cmp expect-none output
633 test_expect_success '--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
634 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output &&
635 test_cmp expect-both output
638 cat > expect-commits << EOF
639 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
640 Author: A U Thor <author@example.com>
641 Date: Thu Apr 7 15:18:13 2005 -0700
649 test_expect_success '--no-standard-notes' '
650 git log --no-standard-notes --show-notes=commits -1 > output &&
651 test_cmp expect-commits output
654 test_expect_success '--standard-notes' '
655 git log --no-standard-notes --show-notes=commits \
656 --standard-notes -2 > output &&
657 test_cmp expect-both output
660 test_expect_success '--show-notes=ref accumulates' '
661 git log --show-notes=other --show-notes=commits \
662 --no-standard-notes -1 > output &&
663 test_cmp expect-both-reversed output
666 test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' '
667 git config core.notesRef refs/notes/other &&
668 echo "Note on a tree" > expect &&
669 git notes add -m "Note on a tree" HEAD: &&
670 git notes show HEAD: > actual &&
671 test_cmp expect actual &&
672 echo "Note on a blob" > expect &&
673 filename=$(git ls-tree --name-only HEAD | head -n1) &&
674 git notes add -m "Note on a blob" HEAD:$filename &&
675 git notes show HEAD:$filename > actual &&
676 test_cmp expect actual &&
677 echo "Note on a tag" > expect &&
678 git tag -a -m "This is an annotated tag" foobar HEAD^ &&
679 git notes add -m "Note on a tag" foobar &&
680 git notes show foobar > actual &&
681 test_cmp expect actual
685 commit 2ede89468182a62d0bde2583c736089bcf7d7e92
686 Author: A U Thor <author@example.com>
687 Date: Thu Apr 7 15:19:13 2005 -0700
695 test_expect_success 'create note from other note with "git notes add -C"' '
700 git notes add -C $(git notes list HEAD^) &&
701 git log -1 > actual &&
702 test_cmp expect actual &&
703 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
706 test_expect_success 'create note from non-existing note with "git notes add -C" fails' '
711 test_must_fail git notes add -C deadbeef &&
712 test_must_fail git notes list HEAD
716 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
717 Author: A U Thor <author@example.com>
718 Date: Thu Apr 7 15:21:13 2005 -0700
726 test_expect_success 'create note from other note with "git notes add -c"' '
731 MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
732 git log -1 > actual &&
733 test_cmp expect actual
736 test_expect_success 'create note from non-existing note with "git notes add -c" fails' '
740 git commit -m 10th &&
742 MSG="yet another note" &&
744 test_must_fail git notes add -c deadbeef
746 test_must_fail git notes list HEAD
750 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
751 Author: A U Thor <author@example.com>
752 Date: Thu Apr 7 15:21:13 2005 -0700
762 test_expect_success 'append to note from other note with "git notes append -C"' '
763 git notes append -C $(git notes list HEAD^) HEAD^ &&
764 git log -1 HEAD^ > actual &&
765 test_cmp expect actual
769 commit ffed603236bfa3891c49644257a83598afe8ae5a
770 Author: A U Thor <author@example.com>
771 Date: Thu Apr 7 15:22:13 2005 -0700
779 test_expect_success 'create note from other note with "git notes append -c"' '
780 MSG="other note" git notes append -c $(git notes list HEAD^) &&
781 git log -1 > actual &&
782 test_cmp expect actual
786 commit ffed603236bfa3891c49644257a83598afe8ae5a
787 Author: A U Thor <author@example.com>
788 Date: Thu Apr 7 15:22:13 2005 -0700
798 test_expect_success 'append to note from other note with "git notes append -c"' '
799 MSG="yet another note" git notes append -c $(git notes list HEAD) &&
800 git log -1 > actual &&
801 test_cmp expect actual
805 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
806 Author: A U Thor <author@example.com>
807 Date: Thu Apr 7 15:23:13 2005 -0700
817 test_expect_success 'copy note with "git notes copy"' '
821 git commit -m 11th &&
822 git notes copy HEAD^ HEAD &&
823 git log -1 > actual &&
824 test_cmp expect actual &&
825 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
828 test_expect_success 'prevent overwrite with "git notes copy"' '
829 test_must_fail git notes copy HEAD~2 HEAD &&
830 git log -1 > actual &&
831 test_cmp expect actual &&
832 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
836 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
837 Author: A U Thor <author@example.com>
838 Date: Thu Apr 7 15:23:13 2005 -0700
848 test_expect_success 'allow overwrite with "git notes copy -f"' '
849 git notes copy -f HEAD~2 HEAD &&
850 git log -1 > actual &&
851 test_cmp expect actual &&
852 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
855 test_expect_success 'cannot copy note from object without notes' '
859 git commit -m 12th &&
863 git commit -m 13th &&
864 test_must_fail git notes copy HEAD^ HEAD
868 commit e5d4fb5698d564ab8c73551538ecaf2b0c666185
869 Author: A U Thor <author@example.com>
870 Date: Thu Apr 7 15:25:13 2005 -0700
879 commit 7038787dfe22a14c3867ce816dbba39845359719
880 Author: A U Thor <author@example.com>
881 Date: Thu Apr 7 15:24:13 2005 -0700
891 test_expect_success 'git notes copy --stdin' '
892 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
893 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
894 git notes copy --stdin &&
895 git log -2 > output &&
896 test_cmp expect output &&
897 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
898 test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
902 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
903 Author: A U Thor <author@example.com>
904 Date: Thu Apr 7 15:27:13 2005 -0700
908 commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
909 Author: A U Thor <author@example.com>
910 Date: Thu Apr 7 15:26:13 2005 -0700
915 test_expect_success 'git notes copy --for-rewrite (unconfigured)' '
918 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
919 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
920 git notes copy --for-rewrite=foo &&
921 git log -2 > output &&
922 test_cmp expect output
926 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
927 Author: A U Thor <author@example.com>
928 Date: Thu Apr 7 15:27:13 2005 -0700
937 commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
938 Author: A U Thor <author@example.com>
939 Date: Thu Apr 7 15:26:13 2005 -0700
949 test_expect_success 'git notes copy --for-rewrite (enabled)' '
950 git config notes.rewriteMode overwrite &&
951 git config notes.rewriteRef "refs/notes/*" &&
952 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
953 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
954 git notes copy --for-rewrite=foo &&
955 git log -2 > output &&
956 test_cmp expect output
959 test_expect_success 'git notes copy --for-rewrite (disabled)' '
960 git config notes.rewrite.bar false &&
961 echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
962 git notes copy --for-rewrite=bar &&
963 git log -2 > output &&
964 test_cmp expect output
968 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
969 Author: A U Thor <author@example.com>
970 Date: Thu Apr 7 15:27:13 2005 -0700
978 test_expect_success 'git notes copy --for-rewrite (overwrite)' '
979 git notes add -f -m"a fresh note" HEAD^ &&
980 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
981 git notes copy --for-rewrite=foo &&
982 git log -1 > output &&
983 test_cmp expect output
986 test_expect_success 'git notes copy --for-rewrite (ignore)' '
987 git config notes.rewriteMode ignore &&
988 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
989 git notes copy --for-rewrite=foo &&
990 git log -1 > output &&
991 test_cmp expect output
995 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
996 Author: A U Thor <author@example.com>
997 Date: Thu Apr 7 15:27:13 2005 -0700
1007 test_expect_success 'git notes copy --for-rewrite (append)' '
1008 git notes add -f -m"another fresh note" HEAD^ &&
1009 git config notes.rewriteMode concatenate &&
1010 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1011 git notes copy --for-rewrite=foo &&
1012 git log -1 > output &&
1013 test_cmp expect output
1017 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1018 Author: A U Thor <author@example.com>
1019 Date: Thu Apr 7 15:27:13 2005 -0700
1033 test_expect_success 'git notes copy --for-rewrite (append two to one)' '
1034 git notes add -f -m"append 1" HEAD^ &&
1035 git notes add -f -m"append 2" HEAD^^ &&
1036 (echo $(git rev-parse HEAD^) $(git rev-parse HEAD);
1037 echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
1038 git notes copy --for-rewrite=foo &&
1039 git log -1 > output &&
1040 test_cmp expect output
1043 test_expect_success 'git notes copy --for-rewrite (append empty)' '
1044 git notes remove HEAD^ &&
1045 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1046 git notes copy --for-rewrite=foo &&
1047 git log -1 > output &&
1048 test_cmp expect output
1052 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1053 Author: A U Thor <author@example.com>
1054 Date: Thu Apr 7 15:27:13 2005 -0700
1062 test_expect_success 'GIT_NOTES_REWRITE_MODE works' '
1063 git notes add -f -m"replacement note 1" HEAD^ &&
1064 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1065 GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
1066 git log -1 > output &&
1067 test_cmp expect output
1071 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1072 Author: A U Thor <author@example.com>
1073 Date: Thu Apr 7 15:27:13 2005 -0700
1081 test_expect_success 'GIT_NOTES_REWRITE_REF works' '
1082 git config notes.rewriteMode overwrite &&
1083 git notes add -f -m"replacement note 2" HEAD^ &&
1084 git config --unset-all notes.rewriteRef &&
1085 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1086 GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
1087 git notes copy --for-rewrite=foo &&
1088 git log -1 > output &&
1089 test_cmp expect output
1092 test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
1093 git config notes.rewriteRef refs/notes/other &&
1094 git notes add -f -m"replacement note 3" HEAD^ &&
1095 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1096 GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
1097 git log -1 > output &&
1098 test_cmp expect output
1101 test_expect_success 'git notes copy diagnoses too many or too few parameters' '
1102 test_must_fail git notes copy &&
1103 test_must_fail git notes copy one two three
1106 test_expect_success 'git notes get-ref (no overrides)' '
1107 git config --unset core.notesRef &&
1108 sane_unset GIT_NOTES_REF &&
1109 test "$(git notes get-ref)" = "refs/notes/commits"
1112 test_expect_success 'git notes get-ref (core.notesRef)' '
1113 git config core.notesRef refs/notes/foo &&
1114 test "$(git notes get-ref)" = "refs/notes/foo"
1117 test_expect_success 'git notes get-ref (GIT_NOTES_REF)' '
1118 test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar"
1121 test_expect_success 'git notes get-ref (--ref)' '
1122 test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"