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 git notes show ; test 1 = $?
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
'create -m notes (setup)' '
255 git notes add -m spam -m "foo
261 cat > expect-m
<< EOF
262 commit bd1753200303d0a0344be813e504253b3d98e74d
263 Author: A U Thor <author@example.com>
264 Date: Thu Apr 7 15:17:13 2005 -0700
276 printf "\n" >> expect-m
277 cat expect-F
>> expect-m
279 test_expect_success
'show -m notes' '
280 git log -4 > output &&
281 test_cmp expect-m output
284 test_expect_success
'remove note with add -f -F /dev/null (setup)' '
285 git notes add -f -F /dev/null
288 cat > expect-rm-F
<< EOF
289 commit bd1753200303d0a0344be813e504253b3d98e74d
290 Author: A U Thor <author@example.com>
291 Date: Thu Apr 7 15:17:13 2005 -0700
296 printf "\n" >> expect-rm-F
297 cat expect-F
>> expect-rm-F
299 test_expect_success
'verify note removal with -F /dev/null' '
300 git log -4 > output &&
301 test_cmp expect-rm-F output &&
305 test_expect_success
'do not create empty note with -m "" (setup)' '
309 test_expect_success
'verify non-creation of note with -m ""' '
310 git log -4 > output &&
311 test_cmp expect-rm-F output &&
315 cat > expect-combine_m_and_F
<< EOF
327 test_expect_success
'create note with combination of -m and -F' '
328 echo "xyzzy" > note_a &&
329 echo "zyxxy" > note_b &&
330 git notes add -m "foo" -F note_a -m "bar" -F note_b -m "baz" &&
331 git notes show > output &&
332 test_cmp expect-combine_m_and_F output
335 test_expect_success
'remove note with "git notes remove" (setup)' '
336 git notes remove HEAD^ &&
340 cat > expect-rm-remove
<< EOF
341 commit bd1753200303d0a0344be813e504253b3d98e74d
342 Author: A U Thor <author@example.com>
343 Date: Thu Apr 7 15:17:13 2005 -0700
347 commit 15023535574ded8b1a89052b32673f84cf9582b8
348 Author: A U Thor <author@example.com>
349 Date: Thu Apr 7 15:16:13 2005 -0700
354 printf "\n" >> expect-rm-remove
355 cat expect-multiline
>> expect-rm-remove
357 test_expect_success
'verify note removal with "git notes remove"' '
358 git log -4 > output &&
359 test_cmp expect-rm-remove output &&
360 ! git notes show HEAD^
364 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
365 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
368 test_expect_success
'list notes with "git notes list"' '
369 git notes list > output &&
370 test_cmp expect output
373 test_expect_success
'list notes with "git notes"' '
374 git notes > output &&
375 test_cmp expect output
379 c18dc024e14f08d18d14eea0d747ff692d66d6a3
382 test_expect_success
'list specific note with "git notes list <object>"' '
383 git notes list HEAD^^ > output &&
384 test_cmp expect output
390 test_expect_success
'listing non-existing notes fails' '
391 test_must_fail git notes list HEAD > output &&
392 test_cmp expect output
398 More notes appended with git notes append
401 test_expect_success
'append to existing note with "git notes append"' '
402 git notes add -m "Initial set of notes" &&
403 git notes append -m "More notes appended with git notes append" &&
404 git notes show > output &&
405 test_cmp expect output
408 cat > expect_list
<< EOF
409 c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75
410 c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5
411 4b6ad22357cc8a1296720574b8d2fbc22fab0671 bd1753200303d0a0344be813e504253b3d98e74d
414 test_expect_success
'"git notes list" does not expand to "git notes list HEAD"' '
415 git notes list > output &&
416 test_cmp expect_list output
419 test_expect_success
'appending empty string does not change existing note' '
420 git notes append -m "" &&
421 git notes show > output &&
422 test_cmp expect output
425 test_expect_success
'git notes append == add when there is no existing note' '
426 git notes remove HEAD &&
427 test_must_fail git notes list HEAD &&
428 git notes append -m "Initial set of notes
430 More notes appended with git notes append" &&
431 git notes show > output &&
432 test_cmp expect output
435 test_expect_success
'appending empty string to non-existing note does not create note' '
436 git notes remove HEAD &&
437 test_must_fail git notes list HEAD &&
438 git notes append -m "" &&
439 test_must_fail git notes list HEAD
442 test_expect_success
'create other note on a different notes ref (setup)' '
447 GIT_NOTES_REF="refs/notes/other" git notes add -m "other note"
450 cat > expect-other
<< EOF
451 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
452 Author: A U Thor <author@example.com>
453 Date: Thu Apr 7 15:18:13 2005 -0700
461 cat > expect-not-other
<< EOF
462 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
463 Author: A U Thor <author@example.com>
464 Date: Thu Apr 7 15:18:13 2005 -0700
469 test_expect_success
'Do not show note on other ref by default' '
470 git log -1 > output &&
471 test_cmp expect-not-other output
474 test_expect_success
'Do show note when ref is given in GIT_NOTES_REF' '
475 GIT_NOTES_REF="refs/notes/other" git log -1 > output &&
476 test_cmp expect-other output
479 test_expect_success
'Do show note when ref is given in core.notesRef config' '
480 git config core.notesRef "refs/notes/other" &&
481 git log -1 > output &&
482 test_cmp expect-other output
485 test_expect_success
'Do not show note when core.notesRef is overridden' '
486 GIT_NOTES_REF="refs/notes/wrong" git log -1 > output &&
487 test_cmp expect-not-other output
490 cat > expect-both
<< EOF
491 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
492 Author: A U Thor <author@example.com>
493 Date: Thu Apr 7 15:18:13 2005 -0700
503 commit bd1753200303d0a0344be813e504253b3d98e74d
504 Author: A U Thor <author@example.com>
505 Date: Thu Apr 7 15:17:13 2005 -0700
510 replacement for deleted note
513 test_expect_success
'Show all notes when notes.displayRef=refs/notes/*' '
514 GIT_NOTES_REF=refs/notes/commits git notes add \
515 -m"replacement for deleted note" HEAD^ &&
516 GIT_NOTES_REF=refs/notes/commits git notes add -m"order test" &&
517 git config --unset core.notesRef &&
518 git config notes.displayRef "refs/notes/*" &&
519 git log -2 > output &&
520 test_cmp expect-both output
523 test_expect_success
'core.notesRef is implicitly in notes.displayRef' '
524 git config core.notesRef refs/notes/commits &&
525 git config notes.displayRef refs/notes/other &&
526 git log -2 > output &&
527 test_cmp expect-both output
530 test_expect_success
'notes.displayRef can be given more than once' '
531 git config --unset core.notesRef &&
532 git config notes.displayRef refs/notes/commits &&
533 git config --add notes.displayRef refs/notes/other &&
534 git log -2 > output &&
535 test_cmp expect-both output
538 cat > expect-both-reversed
<< EOF
539 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
540 Author: A U Thor <author@example.com>
541 Date: Thu Apr 7 15:18:13 2005 -0700
552 test_expect_success
'notes.displayRef respects order' '
553 git config core.notesRef refs/notes/other &&
554 git config --unset-all notes.displayRef &&
555 git config notes.displayRef refs/notes/commits &&
556 git log -1 > output &&
557 test_cmp expect-both-reversed output
560 test_expect_success
'GIT_NOTES_DISPLAY_REF works' '
561 git config --unset-all core.notesRef &&
562 git config --unset-all notes.displayRef &&
563 GIT_NOTES_DISPLAY_REF=refs/notes/commits:refs/notes/other \
564 git log -2 > output &&
565 test_cmp expect-both output
568 cat > expect-none
<< EOF
569 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
570 Author: A U Thor <author@example.com>
571 Date: Thu Apr 7 15:18:13 2005 -0700
575 commit bd1753200303d0a0344be813e504253b3d98e74d
576 Author: A U Thor <author@example.com>
577 Date: Thu Apr 7 15:17:13 2005 -0700
582 test_expect_success
'GIT_NOTES_DISPLAY_REF overrides config' '
583 git config notes.displayRef "refs/notes/*" &&
584 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log -2 > output &&
585 test_cmp expect-none output
588 test_expect_success
'--show-notes=* adds to GIT_NOTES_DISPLAY_REF' '
589 GIT_NOTES_REF= GIT_NOTES_DISPLAY_REF= git log --show-notes=* -2 > output &&
590 test_cmp expect-both output
593 cat > expect-commits
<< EOF
594 commit 387a89921c73d7ed72cd94d179c1c7048ca47756
595 Author: A U Thor <author@example.com>
596 Date: Thu Apr 7 15:18:13 2005 -0700
604 test_expect_success
'--no-standard-notes' '
605 git log --no-standard-notes --show-notes=commits -1 > output &&
606 test_cmp expect-commits output
609 test_expect_success
'--standard-notes' '
610 git log --no-standard-notes --show-notes=commits \
611 --standard-notes -2 > output &&
612 test_cmp expect-both output
615 test_expect_success
'--show-notes=ref accumulates' '
616 git log --show-notes=other --show-notes=commits \
617 --no-standard-notes -1 > output &&
618 test_cmp expect-both-reversed output
621 test_expect_success
'Allow notes on non-commits (trees, blobs, tags)' '
622 git config core.notesRef refs/notes/other &&
623 echo "Note on a tree" > expect
624 git notes add -m "Note on a tree" HEAD: &&
625 git notes show HEAD: > actual &&
626 test_cmp expect actual &&
627 echo "Note on a blob" > expect
628 filename=$(git ls-tree --name-only HEAD | head -n1) &&
629 git notes add -m "Note on a blob" HEAD:$filename &&
630 git notes show HEAD:$filename > actual &&
631 test_cmp expect actual &&
632 echo "Note on a tag" > expect
633 git tag -a -m "This is an annotated tag" foobar HEAD^ &&
634 git notes add -m "Note on a tag" foobar &&
635 git notes show foobar > actual &&
636 test_cmp expect actual
640 commit 2ede89468182a62d0bde2583c736089bcf7d7e92
641 Author: A U Thor <author@example.com>
642 Date: Thu Apr 7 15:19:13 2005 -0700
650 test_expect_success
'create note from other note with "git notes add -C"' '
655 git notes add -C $(git notes list HEAD^) &&
656 git log -1 > actual &&
657 test_cmp expect actual &&
658 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
661 test_expect_success
'create note from non-existing note with "git notes add -C" fails' '
666 test_must_fail git notes add -C deadbeef &&
667 test_must_fail git notes list HEAD
671 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
672 Author: A U Thor <author@example.com>
673 Date: Thu Apr 7 15:21:13 2005 -0700
681 test_expect_success
'create note from other note with "git notes add -c"' '
686 MSG="yet another note" git notes add -c $(git notes list HEAD^^) &&
687 git log -1 > actual &&
688 test_cmp expect actual
691 test_expect_success
'create note from non-existing note with "git notes add -c" fails' '
695 git commit -m 10th &&
697 MSG="yet another note" &&
699 test_must_fail git notes add -c deadbeef
701 test_must_fail git notes list HEAD
705 commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
706 Author: A U Thor <author@example.com>
707 Date: Thu Apr 7 15:21:13 2005 -0700
717 test_expect_success
'append to note from other note with "git notes append -C"' '
718 git notes append -C $(git notes list HEAD^) HEAD^ &&
719 git log -1 HEAD^ > actual &&
720 test_cmp expect actual
724 commit ffed603236bfa3891c49644257a83598afe8ae5a
725 Author: A U Thor <author@example.com>
726 Date: Thu Apr 7 15:22:13 2005 -0700
734 test_expect_success
'create note from other note with "git notes append -c"' '
735 MSG="other note" git notes append -c $(git notes list HEAD^) &&
736 git log -1 > actual &&
737 test_cmp expect actual
741 commit ffed603236bfa3891c49644257a83598afe8ae5a
742 Author: A U Thor <author@example.com>
743 Date: Thu Apr 7 15:22:13 2005 -0700
753 test_expect_success
'append to note from other note with "git notes append -c"' '
754 MSG="yet another note" git notes append -c $(git notes list HEAD) &&
755 git log -1 > actual &&
756 test_cmp expect actual
760 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
761 Author: A U Thor <author@example.com>
762 Date: Thu Apr 7 15:23:13 2005 -0700
772 test_expect_success
'copy note with "git notes copy"' '
776 git commit -m 11th &&
777 git notes copy HEAD^ HEAD &&
778 git log -1 > actual &&
779 test_cmp expect actual &&
780 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
783 test_expect_success
'prevent overwrite with "git notes copy"' '
784 test_must_fail git notes copy HEAD~2 HEAD &&
785 git log -1 > actual &&
786 test_cmp expect actual &&
787 test "$(git notes list HEAD)" = "$(git notes list HEAD^)"
791 commit 6352c5e33dbcab725fe0579be16aa2ba8eb369be
792 Author: A U Thor <author@example.com>
793 Date: Thu Apr 7 15:23:13 2005 -0700
803 test_expect_success
'allow overwrite with "git notes copy -f"' '
804 git notes copy -f HEAD~2 HEAD &&
805 git log -1 > actual &&
806 test_cmp expect actual &&
807 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)"
810 test_expect_success
'cannot copy note from object without notes' '
814 git commit -m 12th &&
818 git commit -m 13th &&
819 test_must_fail git notes copy HEAD^ HEAD
823 commit e5d4fb5698d564ab8c73551538ecaf2b0c666185
824 Author: A U Thor <author@example.com>
825 Date: Thu Apr 7 15:25:13 2005 -0700
834 commit 7038787dfe22a14c3867ce816dbba39845359719
835 Author: A U Thor <author@example.com>
836 Date: Thu Apr 7 15:24:13 2005 -0700
846 test_expect_success
'git notes copy --stdin' '
847 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
848 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
849 git notes copy --stdin &&
850 git log -2 > output &&
851 test_cmp expect output &&
852 test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" &&
853 test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)"
857 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
858 Author: A U Thor <author@example.com>
859 Date: Thu Apr 7 15:27:13 2005 -0700
863 commit be28d8b4d9951ad940d229ee3b0b9ee3b1ec273d
864 Author: A U Thor <author@example.com>
865 Date: Thu Apr 7 15:26:13 2005 -0700
870 test_expect_success
'git notes copy --for-rewrite (unconfigured)' '
873 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
874 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
875 git notes copy --for-rewrite=foo &&
876 git log -2 > output &&
877 test_cmp expect output
881 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
882 Author: A U Thor <author@example.com>
883 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
904 test_expect_success
'git notes copy --for-rewrite (enabled)' '
905 git config notes.rewriteMode overwrite &&
906 git config notes.rewriteRef "refs/notes/*" &&
907 (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \
908 echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) |
909 git notes copy --for-rewrite=foo &&
910 git log -2 > output &&
911 test_cmp expect output
914 test_expect_success
'git notes copy --for-rewrite (disabled)' '
915 git config notes.rewrite.bar false &&
916 echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) |
917 git notes copy --for-rewrite=bar &&
918 git log -2 > output &&
919 test_cmp expect output
923 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
924 Author: A U Thor <author@example.com>
925 Date: Thu Apr 7 15:27:13 2005 -0700
933 test_expect_success
'git notes copy --for-rewrite (overwrite)' '
934 git notes add -f -m"a fresh note" HEAD^ &&
935 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
936 git notes copy --for-rewrite=foo &&
937 git log -1 > output &&
938 test_cmp expect output
941 test_expect_success
'git notes copy --for-rewrite (ignore)' '
942 git config notes.rewriteMode ignore &&
943 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
944 git notes copy --for-rewrite=foo &&
945 git log -1 > output &&
946 test_cmp expect output
950 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
951 Author: A U Thor <author@example.com>
952 Date: Thu Apr 7 15:27:13 2005 -0700
962 test_expect_success
'git notes copy --for-rewrite (append)' '
963 git notes add -f -m"another fresh note" HEAD^ &&
964 git config notes.rewriteMode concatenate &&
965 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
966 git notes copy --for-rewrite=foo &&
967 git log -1 > output &&
968 test_cmp expect output
972 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
973 Author: A U Thor <author@example.com>
974 Date: Thu Apr 7 15:27:13 2005 -0700
988 test_expect_success
'git notes copy --for-rewrite (append two to one)' '
989 git notes add -f -m"append 1" HEAD^ &&
990 git notes add -f -m"append 2" HEAD^^ &&
991 (echo $(git rev-parse HEAD^) $(git rev-parse HEAD);
992 echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) |
993 git notes copy --for-rewrite=foo &&
994 git log -1 > output &&
995 test_cmp expect output
998 test_expect_success
'git notes copy --for-rewrite (append empty)' '
999 git notes remove HEAD^ &&
1000 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1001 git notes copy --for-rewrite=foo &&
1002 git log -1 > output &&
1003 test_cmp expect output
1007 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1008 Author: A U Thor <author@example.com>
1009 Date: Thu Apr 7 15:27:13 2005 -0700
1017 test_expect_success
'GIT_NOTES_REWRITE_MODE works' '
1018 git notes add -f -m"replacement note 1" HEAD^ &&
1019 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1020 GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo &&
1021 git log -1 > output &&
1022 test_cmp expect output
1026 commit 37a0d4cba38afef96ba54a3ea567e6dac575700b
1027 Author: A U Thor <author@example.com>
1028 Date: Thu Apr 7 15:27:13 2005 -0700
1036 test_expect_success
'GIT_NOTES_REWRITE_REF works' '
1037 git config notes.rewriteMode overwrite &&
1038 git notes add -f -m"replacement note 2" HEAD^ &&
1039 git config --unset-all notes.rewriteRef &&
1040 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1041 GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \
1042 git notes copy --for-rewrite=foo &&
1043 git log -1 > output &&
1044 test_cmp expect output
1047 test_expect_success
'GIT_NOTES_REWRITE_REF overrides config' '
1048 git config notes.rewriteRef refs/notes/other &&
1049 git notes add -f -m"replacement note 3" HEAD^ &&
1050 echo $(git rev-parse HEAD^) $(git rev-parse HEAD) |
1051 GIT_NOTES_REWRITE_REF= git notes copy --for-rewrite=foo &&
1052 git log -1 > output &&
1053 test_cmp expect output
1056 test_expect_success
'git notes copy diagnoses too many or too few parameters' '
1057 test_must_fail git notes copy &&
1058 test_must_fail git notes copy one two three
1061 test_expect_success
'git notes get-ref (no overrides)' '
1062 git config --unset core.notesRef &&
1063 unset GIT_NOTES_REF &&
1064 test "$(git notes get-ref)" = "refs/notes/commits"
1067 test_expect_success
'git notes get-ref (core.notesRef)' '
1068 git config core.notesRef refs/notes/foo &&
1069 test "$(git notes get-ref)" = "refs/notes/foo"
1072 test_expect_success
'git notes get-ref (GIT_NOTES_REF)' '
1073 test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar"
1076 test_expect_success
'git notes get-ref (--ref)' '
1077 test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz"